|
@@ -6,8 +6,11 @@ import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.runtime.*
|
|
|
import androidx.compose.ui.Modifier
|
|
|
+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.tools.isNet
|
|
|
import com.ys.bdtp.adm.app.theme.underColor
|
|
|
import com.ys.bdtp.adm.mvvm.model.nt.FailureResponse
|
|
@@ -15,25 +18,36 @@ import com.ys.bdtp.adm.mvvm.model.nt.SuccessResponse
|
|
|
import com.ys.bdtp.adm.mvvm.model.db.entity.task.ProjectEntity
|
|
|
import com.ys.bdtp.adm.mvvm.model.db.entity.UserEntity
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.*
|
|
|
-import com.ys.bdtp.adm.mvvm.ui.screen.home.LocalNavHostController
|
|
|
-import com.ys.bdtp.adm.mvvm.ui.screen.home.Route
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.screen.main.LocalNavHostController
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.screen.main.Route
|
|
|
import com.ys.bdtp.adm.mvvm.vm.project.ProjectViewModel
|
|
|
import kotlinx.coroutines.launch
|
|
|
import org.kodein.di.compose.rememberInstance
|
|
|
import org.kodein.di.compose.rememberViewModel
|
|
|
|
|
|
-
|
|
|
+/**
|
|
|
+ * 项目界面
|
|
|
+ */
|
|
|
@OptIn(ExperimentalFoundationApi::class)
|
|
|
@Composable
|
|
|
fun Project() {
|
|
|
+ val nav = LocalNavHostController.current!!
|
|
|
val vm by rememberViewModel<ProjectViewModel>()
|
|
|
val cm by rememberInstance<ConnectivityManager>()
|
|
|
- val nav = LocalNavHostController.current!!
|
|
|
val scope = rememberCoroutineScope()
|
|
|
- var user by remember { mutableStateOf<UserEntity?>(null) }
|
|
|
+ // var user by remember { mutableStateOf<UserEntity?>(null) }
|
|
|
var projects by remember { mutableStateOf<List<ProjectEntity>>(emptyList()) }
|
|
|
-
|
|
|
var popupState by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+ val lifecycleOwner = LocalLifecycleOwner.current
|
|
|
+ /*val userFlow = vm.userFlow
|
|
|
+ val userFlowLifecycleAware = remember(vm.userFlow, lifecycleOwner) {
|
|
|
+ userFlow.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
|
|
|
+ }
|
|
|
+
|
|
|
+ val user by userFlowLifecycleAware.collectAsState(null, scope.coroutineContext)*/
|
|
|
+ val user by vm.userFlow.collectAsState()
|
|
|
+
|
|
|
LaunchedEffect(Unit) {
|
|
|
// isNet 联网,进行网络通信,获取账号信息也判断 token是否能用
|
|
|
if (isNet(cm)) {
|
|
@@ -42,7 +56,7 @@ fun Project() {
|
|
|
val account = response.data
|
|
|
vm.setCurrentAccount(account)
|
|
|
val up = vm.getUserWithProjectsById(account.id)
|
|
|
- user = up.user
|
|
|
+
|
|
|
projects = up.projects
|
|
|
}
|
|
|
|
|
@@ -66,7 +80,7 @@ fun Project() {
|
|
|
}
|
|
|
} else {
|
|
|
val up = vm.getUserWithProjectsById(u.id)
|
|
|
- user = up.user
|
|
|
+ //user = up.user
|
|
|
projects = up.projects
|
|
|
}
|
|
|
}
|
|
@@ -75,6 +89,8 @@ fun Project() {
|
|
|
Column(
|
|
|
modifier = Modifier.fillMaxSize()
|
|
|
) {
|
|
|
+ println("user:::::: $user ")
|
|
|
+ println("user:::::: $user ")
|
|
|
Head(
|
|
|
left = {
|
|
|
ProjectHeadLeft()
|