更新
This commit is contained in:
@@ -9,6 +9,7 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -17,13 +18,13 @@ import androidx.paging.Pager
|
||||
import androidx.paging.PagingConfig
|
||||
import androidx.paging.PagingData
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.aiosman.riderpro.data.AccountProfile
|
||||
import com.aiosman.riderpro.data.AccountProfileEntity
|
||||
import com.aiosman.riderpro.data.MomentPagingSource
|
||||
import com.aiosman.riderpro.data.MomentRemoteDataSource
|
||||
import com.aiosman.riderpro.data.TestMomentServiceImpl
|
||||
import com.aiosman.riderpro.data.TestUserServiceImpl
|
||||
import com.aiosman.riderpro.data.UserService
|
||||
import com.aiosman.riderpro.model.MomentItem
|
||||
import com.aiosman.riderpro.model.MomentEntity
|
||||
import com.aiosman.riderpro.ui.composables.StatusBarMaskLayout
|
||||
import com.aiosman.riderpro.ui.index.tabs.profile.CarGroup
|
||||
import com.aiosman.riderpro.ui.index.tabs.profile.MomentPostUnit
|
||||
@@ -31,15 +32,15 @@ import com.aiosman.riderpro.ui.index.tabs.profile.RidingStyle
|
||||
import com.aiosman.riderpro.ui.index.tabs.profile.UserInformation
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun AccountProfile(id:String) {
|
||||
// val model = MyProfileViewModel
|
||||
val userService: UserService = TestUserServiceImpl()
|
||||
var userProfile by remember { mutableStateOf<AccountProfile?>(null) }
|
||||
var userProfile by remember { mutableStateOf<AccountProfileEntity?>(null) }
|
||||
val momentService = TestMomentServiceImpl()
|
||||
var momentsFlow by remember { mutableStateOf<Flow<PagingData<MomentItem>>?>(null) }
|
||||
|
||||
var momentsFlow by remember { mutableStateOf<Flow<PagingData<MomentEntity>>?>(null) }
|
||||
val scope = rememberCoroutineScope()
|
||||
LaunchedEffect(Unit) {
|
||||
userProfile = userService.getUserProfile(id)
|
||||
momentsFlow = Pager(
|
||||
@@ -73,7 +74,21 @@ fun AccountProfile(id:String) {
|
||||
item {
|
||||
CarGroup()
|
||||
userProfile?.let {
|
||||
UserInformation(isSelf = false, accountProfile = it)
|
||||
UserInformation(
|
||||
isSelf = false,
|
||||
accountProfileEntity = it,
|
||||
onFollowClick = {
|
||||
scope.launch {
|
||||
if (it.isFollowing) {
|
||||
userService.unFollowUser(id)
|
||||
userProfile = userProfile?.copy(isFollowing = false)
|
||||
} else {
|
||||
userService.followUser(id)
|
||||
userProfile = userProfile?.copy(isFollowing = true)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
RidingStyle()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user