|
@@ -1,34 +1,22 @@
|
|
|
package com.ys.bdtp.adm.mvvm.ui.screen.task
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
-import androidx.compose.foundation.layout.Box
|
|
|
-import androidx.compose.foundation.layout.Column
|
|
|
-import androidx.compose.foundation.layout.Row
|
|
|
-import androidx.compose.foundation.layout.Spacer
|
|
|
-import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
-import androidx.compose.foundation.layout.fillMaxSize
|
|
|
-import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
-import androidx.compose.foundation.layout.height
|
|
|
-import androidx.compose.foundation.layout.padding
|
|
|
-import androidx.compose.foundation.layout.width
|
|
|
-import androidx.compose.foundation.layout.wrapContentWidth
|
|
|
+import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.runtime.*
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
-import androidx.compose.ui.platform.LocalLifecycleOwner
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
-import androidx.lifecycle.Lifecycle
|
|
|
-import androidx.lifecycle.flowWithLifecycle
|
|
|
import com.ys.bdtp.adm.app.theme.underColor
|
|
|
-import com.ys.bdtp.adm.mvvm.model.Data
|
|
|
+import com.ys.bdtp.adm.app.tools.lifecycleState
|
|
|
import com.ys.bdtp.adm.mvvm.model.State
|
|
|
import com.ys.bdtp.adm.mvvm.model.db.entity.task.ProjectEntity
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.Back
|
|
|
-import com.ys.bdtp.adm.mvvm.ui.compose.Head
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.Ending
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.compose.Head
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.LogoutPopup
|
|
|
-import com.ys.bdtp.adm.mvvm.ui.screen.main.*
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.screen.main.LocalNavHostController
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.screen.main.taskToLogin
|
|
|
import com.ys.bdtp.adm.mvvm.vm.task.TaskViewModel
|
|
|
import kotlinx.coroutines.launch
|
|
|
import org.kodein.di.compose.rememberViewModel
|
|
@@ -37,16 +25,10 @@ import org.kodein.di.compose.rememberViewModel
|
|
|
fun Task(projectId: String) {
|
|
|
val nav = LocalNavHostController.current!!
|
|
|
val vm by rememberViewModel<TaskViewModel>()
|
|
|
- var project by remember { mutableStateOf<ProjectEntity?>(null) }
|
|
|
var popupState by remember { mutableStateOf(false) }
|
|
|
val scope = rememberCoroutineScope()
|
|
|
|
|
|
- val lifecycleOwner = LocalLifecycleOwner.current
|
|
|
- val userFlowLifecycleAware = remember(vm.userStateFlow, lifecycleOwner) {
|
|
|
- vm.userStateFlow.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
|
|
|
- }
|
|
|
-
|
|
|
- val userState = userFlowLifecycleAware.collectAsState(Data.loading())
|
|
|
+ val userState = lifecycleState(vm.userFlow)
|
|
|
|
|
|
if (userState.value.state == State.Success) {
|
|
|
val user = userState.value.data
|
|
@@ -55,11 +37,10 @@ fun Task(projectId: String) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- LaunchedEffect(Unit) {
|
|
|
- project = vm.getProject(projectId)
|
|
|
+ val project by produceState<ProjectEntity?>(null, projectId) {
|
|
|
+ value = vm.getProject(projectId)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Column(modifier = Modifier.fillMaxSize().background(Color.White)) {
|
|
|
Head {
|
|
|
Back(
|
|
@@ -75,7 +56,7 @@ fun Task(projectId: String) {
|
|
|
userClick = { popupState = !popupState }
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (popupState) {
|
|
|
LogoutPopup(
|
|
|
click = {
|