|
@@ -1,47 +1,52 @@
|
|
|
package com.ys.bdtp.adm.mvvm.ui.screen.cad
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
-import androidx.compose.foundation.layout.Column
|
|
|
-import androidx.compose.foundation.layout.fillMaxSize
|
|
|
-import androidx.compose.runtime.Composable
|
|
|
-import androidx.compose.runtime.collectAsState
|
|
|
-import androidx.compose.runtime.mutableStateOf
|
|
|
-import androidx.compose.runtime.remember
|
|
|
-import androidx.compose.runtime.getValue
|
|
|
-import androidx.compose.runtime.setValue
|
|
|
+import androidx.compose.foundation.layout.*
|
|
|
+import androidx.compose.foundation.lazy.LazyColumn
|
|
|
+import androidx.compose.foundation.lazy.items
|
|
|
+import androidx.compose.material.Text
|
|
|
+import androidx.compose.runtime.*
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
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.lifecycle.Lifecycle
|
|
|
-import androidx.lifecycle.flowWithLifecycle
|
|
|
-import com.ys.bdtp.adm.mvvm.model.Data
|
|
|
-import com.ys.bdtp.adm.mvvm.model.State
|
|
|
-import com.ys.bdtp.adm.mvvm.model.db.entity.task.FloorEntity
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.compose.ui.unit.sp
|
|
|
+import com.ys.bdtp.adm.app.theme.textBlackColor
|
|
|
+import com.ys.bdtp.adm.app.theme.trDivColor
|
|
|
+import com.ys.bdtp.adm.app.theme.underColor
|
|
|
+import com.ys.bdtp.adm.app.theme.whiteColor
|
|
|
+import com.ys.bdtp.adm.mvvm.model.db.entity.task.CadEntity
|
|
|
+import com.ys.bdtp.adm.mvvm.model.db.relation.FloorWithCads
|
|
|
+import com.ys.bdtp.adm.mvvm.model.db.relation.ProjectWithBuildingAndFloors
|
|
|
import com.ys.bdtp.adm.mvvm.ui.compose.*
|
|
|
import com.ys.bdtp.adm.mvvm.ui.screen.main.LocalNavHostController
|
|
|
+import com.ys.bdtp.adm.mvvm.ui.screen.main.cadToLogin
|
|
|
import com.ys.bdtp.adm.mvvm.vm.cad.CadViewModel
|
|
|
+import kotlinx.coroutines.launch
|
|
|
import org.kodein.di.compose.rememberViewModel
|
|
|
|
|
|
@Composable
|
|
|
fun CadScreen(projectId: String) {
|
|
|
- var selectState by remember { mutableStateOf<SelectState>(SelectState.Left) }
|
|
|
val nav = LocalNavHostController.current!!
|
|
|
val vm by rememberViewModel<CadViewModel>()
|
|
|
+ val scope = rememberCoroutineScope()
|
|
|
+
|
|
|
+ var popupState by remember { mutableStateOf(false) }
|
|
|
+ var floor by remember { mutableStateOf<FloorWithCads?>(null) }
|
|
|
+ var selectState by remember { mutableStateOf<SelectState>(SelectState.Left) }
|
|
|
+ var project by remember { mutableStateOf<ProjectWithBuildingAndFloors?>(null) }
|
|
|
|
|
|
- val lifecycleOwner = LocalLifecycleOwner.current
|
|
|
- val lifecycleWare = remember(lifecycleOwner) {
|
|
|
- vm.getProjectWithBuildingAndFloors(projectId)
|
|
|
- .flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
|
|
|
+ LaunchedEffect(Unit) {
|
|
|
+ project = vm.getProject(projectId)
|
|
|
}
|
|
|
- val projectData = lifecycleWare.collectAsState(Data.loading())
|
|
|
- var floorState by remember { mutableStateOf<FloorEntity?>(null) }
|
|
|
+
|
|
|
Column(modifier = Modifier.background(Color.White)) {
|
|
|
Head(
|
|
|
left = {
|
|
|
- CadHeadLeft(
|
|
|
+ HeadLeft(
|
|
|
title = "CAD图纸核查",
|
|
|
- click = {
|
|
|
+ back = {
|
|
|
nav.navigateUp()
|
|
|
}
|
|
|
)
|
|
@@ -58,41 +63,85 @@ fun CadScreen(projectId: String) {
|
|
|
HeadRight(
|
|
|
role = { "物业管家" },
|
|
|
click = {
|
|
|
-
|
|
|
+ popupState = !popupState
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
)
|
|
|
- Div(Div.Row)
|
|
|
- Body(
|
|
|
- modifier = Modifier.fillMaxSize(),
|
|
|
- side = {
|
|
|
- when (projectData.value.state) {
|
|
|
- is State.Loading -> {
|
|
|
|
|
|
+ if (popupState) {
|
|
|
+ LogoutPopup(
|
|
|
+ click = {
|
|
|
+ scope.launch {
|
|
|
+ vm.logout()
|
|
|
}
|
|
|
- is State.Success -> {
|
|
|
- val project = projectData.value.data
|
|
|
- if (project != null) {
|
|
|
- CadSide(
|
|
|
- buildings = project.buildings,
|
|
|
- click = { floorEntity ->
|
|
|
- floorState = floorEntity
|
|
|
- }
|
|
|
+ popupState = false
|
|
|
+ nav.cadToLogin()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
- )
|
|
|
+ Div(Div.Row)
|
|
|
+ Row(modifier = Modifier.fillMaxSize()) {
|
|
|
+ // side
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .width(280.dp)
|
|
|
+ .fillMaxHeight()
|
|
|
+ .background(color = underColor)
|
|
|
+ ) {
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .wrapContentHeight()
|
|
|
+ .padding(top = 20.dp, start = 32.dp)
|
|
|
+ ) {
|
|
|
+ Text(text = "选择楼层", fontSize = 16.sp, color = textBlackColor)
|
|
|
+ }
|
|
|
+ if (project != null) {
|
|
|
+ ExpandList(
|
|
|
+ items = project!!.buildings,
|
|
|
+ click = {
|
|
|
+ scope.launch {
|
|
|
+ floor = vm.getFloorWithCads(it.id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Div(Div.Col)
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(whiteColor)
|
|
|
+ .padding(horizontal = 50.dp, vertical = 50.dp)
|
|
|
+ ) {
|
|
|
+ val title = if (selectState == SelectState.Left) "土建图纸核查" else "机电图纸核查"
|
|
|
+ Table(
|
|
|
+ name = {
|
|
|
+ Text(text = title, color = textBlackColor, fontSize = 16.sp)
|
|
|
+ },
|
|
|
+ th = {
|
|
|
+ CadDrawingTitle()
|
|
|
+ },
|
|
|
+ tr = {
|
|
|
+ LazyColumn(modifier = Modifier.fillMaxSize()) {
|
|
|
+ floor?.let {
|
|
|
+ items(it.cads) { cad: CadEntity ->
|
|
|
+ Box {
|
|
|
+ CadDrawingItem(cad)
|
|
|
+ Spacer(
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.BottomCenter)
|
|
|
+ .fillMaxWidth().height(1.dp)
|
|
|
+ .background(trDivColor)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- is State.Failure -> {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- content = {
|
|
|
- CadContent(selectState, floorState)
|
|
|
- },
|
|
|
- div = { Div(Div.Col) }
|
|
|
- )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|