|
@@ -1,95 +1,96 @@
|
|
|
package com.ys.bdtp.adm.mvvm.ui.screen.project
|
|
|
|
|
|
+import android.net.ConnectivityManager
|
|
|
+import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
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.runtime.Composable
|
|
|
-import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.foundation.layout.*
|
|
|
+import androidx.compose.runtime.*
|
|
|
import androidx.compose.ui.Modifier
|
|
|
-import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
-import com.ys.bdtp.adm.R
|
|
|
+import com.ys.bdtp.adm.app.isNet
|
|
|
+import com.ys.bdtp.adm.app.theme.underColor
|
|
|
+import com.ys.bdtp.adm.mvvm.model.FailureResponse
|
|
|
+import com.ys.bdtp.adm.mvvm.model.SuccessResponse
|
|
|
+import com.ys.bdtp.adm.mvvm.model.vo.request.Account
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.compose.Blank
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.compose.Div
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.Head
|
|
|
-import com.ys.bdtp.adm.mvvm.ui.compose.TaskType
|
|
|
-import com.ys.bdtp.adm.mvvm.ui.compose.HeadLeft
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.HeadRight
|
|
|
+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 ProjectScreen() {
|
|
|
+ val vm by rememberViewModel<ProjectViewModel>()
|
|
|
+ val cm by rememberInstance<ConnectivityManager>()
|
|
|
+
|
|
|
+ var account by remember { mutableStateOf<Account?>(null) }
|
|
|
+ val scope = rememberCoroutineScope()
|
|
|
+
|
|
|
+ LaunchedEffect(Unit) {
|
|
|
+ // isNet 联网,进行网络通信,获取账号信息也判断 token是否能用
|
|
|
+ if (isNet(cm)) {
|
|
|
+ scope.launch {
|
|
|
+ when (val response = vm.getAccount()) {
|
|
|
+ is SuccessResponse -> {
|
|
|
+ val a = response.data
|
|
|
+ account = a
|
|
|
+ vm.setCurrentAccount(a)
|
|
|
+ }
|
|
|
|
|
|
- Column(modifier = Modifier.fillMaxSize().background(Color.White)) {
|
|
|
+ is FailureResponse -> {
|
|
|
+ // 纯联网问题
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Column(
|
|
|
+ modifier = Modifier.fillMaxSize()
|
|
|
+ ) {
|
|
|
Head(
|
|
|
- left = { HeadLeft() },
|
|
|
+ left = {
|
|
|
+ ProjectHeadLeft()
|
|
|
+ },
|
|
|
right = {
|
|
|
HeadRight(
|
|
|
- role = { "管家" },
|
|
|
- click = { println("heiheihei") }
|
|
|
+ role = { "项目管家" },
|
|
|
+ click = {}
|
|
|
)
|
|
|
}
|
|
|
)
|
|
|
-
|
|
|
- Spacer(
|
|
|
- modifier = Modifier.fillMaxWidth().height(1.dp).background(Color(0xFFEFF0F1))
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
- Row {
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxHeight()
|
|
|
- .wrapContentWidth()
|
|
|
- .padding(horizontal = 32.dp, vertical = 42.dp)
|
|
|
- ) {
|
|
|
- // 工作分类
|
|
|
- Column(
|
|
|
- horizontalAlignment = Alignment.CenterHorizontally
|
|
|
- ) {
|
|
|
- TaskType(R.drawable.project_task_cad, "CAD核查")
|
|
|
- Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TaskType(R.drawable.project_task_space, "空间模型核查")
|
|
|
- Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TaskType(R.drawable.project_task_electric, "机电核查")
|
|
|
- Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TaskType(R.drawable.project_task_relation, "交付关系")
|
|
|
- Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TaskType(R.drawable.project_task_offline, "离线数据")
|
|
|
+ Div(Div.Row)
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxHeight()
|
|
|
+ .wrapContentWidth()
|
|
|
+ .background(underColor)
|
|
|
+ .padding(horizontal = 32.dp, vertical = 40.dp)
|
|
|
+ ) {
|
|
|
+ account?.let {
|
|
|
+ if (it.projects.isEmpty()) {
|
|
|
+ Blank()
|
|
|
+ } else {
|
|
|
+ ProjectContent(it.projects)
|
|
|
}
|
|
|
-
|
|
|
- // 项目切换
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- Spacer(modifier = Modifier.width(1.dp).fillMaxHeight().background(Color(0xFFE5E5E5)))
|
|
|
-
|
|
|
- Column(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxHeight()
|
|
|
- .wrapContentWidth()
|
|
|
- .padding(horizontal = 32.dp, vertical = 42.dp)
|
|
|
- ) {
|
|
|
- //ProjectBlank()
|
|
|
- ProjectTask()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Preview(
|
|
|
- widthDp = 1137,
|
|
|
- heightDp = 711,
|
|
|
+ widthDp = 1280,
|
|
|
+ heightDp = 800,
|
|
|
+ showBackground = true,
|
|
|
+ backgroundColor = 0xFFFFFFFF
|
|
|
)
|
|
|
@Composable
|
|
|
-fun PreviewProjectScreen() {
|
|
|
+fun PreviewProject() {
|
|
|
ProjectScreen()
|
|
|
}
|