Browse Source

@fun: remove HeadLeft

bai 2 years ago
parent
commit
12527223df

app/src/main/java/com/ys/bdtp/adm/mvvm/ui/compose/HeadRight.kt → app/src/main/java/com/ys/bdtp/adm/mvvm/ui/compose/Ending.kt


+ 0 - 77
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/compose/HeadLeft.kt

@@ -1,77 +0,0 @@
-package com.ys.bdtp.adm.mvvm.ui.compose
-
-import androidx.compose.foundation.Image
-import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.*
-import androidx.compose.material.IconButton
-import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.res.painterResource
-import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.font.FontWeight.Companion.Bold
-import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import com.ys.bdtp.adm.R
-import com.ys.bdtp.adm.app.theme.divColor
-import com.ys.bdtp.adm.app.theme.textBlackColor
-
-
-@Composable
-fun HeadLeft(
-    title: String,
-    back: (() -> Unit)? = null,
-) {
-    Row(
-        verticalAlignment = Alignment.CenterVertically,
-        horizontalArrangement = Arrangement.Start
-    ) {
-
-        Spacer(modifier = Modifier.width(16.dp))
-
-        IconButton(
-            modifier = Modifier.size(56.dp),
-            onClick = {
-                back?.invoke()
-            }
-        ) {
-            Image(
-                painter = painterResource(R.drawable.arrow_back),
-                contentDescription = "",
-                modifier = Modifier.size(24.dp)
-            )
-        }
-
-        Spacer(
-            modifier = Modifier
-                .width(1.dp)
-                .height(16.dp)
-                .background(divColor)
-        )
-
-        Spacer(
-            modifier = Modifier
-                .width(16.dp)
-                .background(divColor)
-        )
-
-        Text(text = title, fontSize = 16.sp, fontWeight = FontWeight.Bold, color = textBlackColor)
-
-        Spacer(
-            modifier = Modifier
-                .width(16.dp)
-                .background(divColor)
-        )
-
-    }
-}
-
-
-@Preview(backgroundColor = 0xFF000000)
-@Composable
-fun PreviewHeadLeft() {
-    HeadLeft("京东")
-}

+ 20 - 18
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/offline/Offline.kt

@@ -19,9 +19,7 @@ import androidx.compose.ui.unit.dp
 import androidx.lifecycle.Lifecycle
 import androidx.lifecycle.flowWithLifecycle
 import com.ys.bdtp.adm.mvvm.model.Data
-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.LogoutPopup
+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.offlineToLogin
 import com.ys.bdtp.adm.mvvm.vm.offline.OfflineViewModel
@@ -42,21 +40,25 @@ fun Offline(projectId: String) {
     val projectsState = lifecycleWare.collectAsState(Data.loading())
 
     Column(modifier = Modifier.background(Color.White)) {
-        Head(
-            left = {
-                OfflineHeadLeft(back = { nav.navigateUp() })
-            },
-            right = {
-                Ending(
-                    notice = "21",
-                    role = "管家",
-                    noticeClick = {},
-                    userClick = {
-                        popupState = !popupState
-                    }
-                )
-            }
-        )
+        Head {
+            Back(
+                title = "离线数据",
+                back = {
+                    nav.navigateUp()
+                }
+            )
+
+            Ending(
+                notice = "21",
+                role = "物业管家",
+                noticeClick = {
+
+                },
+                userClick = {
+                    popupState = !popupState
+                }
+            )
+        }
 
         if (popupState) {
             LogoutPopup(

+ 27 - 17
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/project/Project.kt

@@ -2,17 +2,19 @@ package com.ys.bdtp.adm.mvvm.ui.screen.project
 
 import androidx.compose.foundation.ExperimentalFoundationApi
 import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.wrapContentWidth
+import androidx.compose.foundation.layout.*
+import androidx.compose.material.Text
 import androidx.compose.runtime.*
+import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
 import androidx.lifecycle.Lifecycle
 import androidx.lifecycle.flowWithLifecycle
+import com.ys.bdtp.adm.app.theme.textBlackColor
 import com.ys.bdtp.adm.app.theme.underColor
 import com.ys.bdtp.adm.mvvm.model.Data
 import com.ys.bdtp.adm.mvvm.model.State
@@ -44,21 +46,29 @@ fun Project() {
     Column(
         modifier = Modifier.fillMaxSize()
     ) {
-        Head(
-            left = {
-                ProjectHeadLeft()
-            },
-            right = {
-                Ending(
-                    notice = "21",
-                    role =  "项目管家" ,
-                    noticeClick = {},
-                    userClick = {
-                        popupState = !popupState
-                    }
+        Head {
+            Row(
+                verticalAlignment = Alignment.CenterVertically,
+                horizontalArrangement = Arrangement.Start
+            ) {
+                Spacer(modifier = Modifier.width(32.dp))
+                Text(
+                    text = "禹数数字化交付工具",
+                    fontSize = 16.sp,
+                    color = textBlackColor,
+                    fontWeight = FontWeight.Medium
                 )
             }
-        )
+
+            Ending(
+                notice = "21",
+                role = "项目管家",
+                noticeClick = {},
+                userClick = {
+                    popupState = !popupState
+                }
+            )
+        }
 
         if (popupState) {
             LogoutPopup(

+ 0 - 31
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/project/ProjectHeadLeft.kt

@@ -1,31 +0,0 @@
-package com.ys.bdtp.adm.mvvm.ui.screen.project
-
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.width
-import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import com.ys.bdtp.adm.app.theme.textBlackColor
-
-@Composable
-fun ProjectHeadLeft() {
-    Row(
-        verticalAlignment = Alignment.CenterVertically,
-        horizontalArrangement = Arrangement.Start
-    ) {
-        Spacer(modifier = Modifier.width(32.dp))
-        Text(text = "禹数数字化交付工具", fontSize = 16.sp, color = textBlackColor)
-    }
-}
-
-@Preview
-@Composable
-fun PreviewProjectHeadLeft() {
-    ProjectHeadLeft()
-}

+ 16 - 17
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/task/Task.kt

@@ -24,6 +24,7 @@ import com.ys.bdtp.adm.app.theme.underColor
 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.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.LogoutPopup
@@ -60,23 +61,21 @@ fun Task(projectId: String) {
 
 
     Column(modifier = Modifier.fillMaxSize().background(Color.White)) {
-        Head(
-            left = {
-                TaskHeadLeft(
-                    title = "${project?.projectName}",
-                    click = {
-                        nav.navigateUp()
-                    })
-            },
-            right = {
-                Ending(
-                    notice = "21",
-                    role = "管家",
-                    noticeClick = {},
-                    userClick = { popupState = !popupState }
-                )
-            }
-        )
+        Head {
+            Back(
+                title = "${project?.projectName}",
+                back = {
+                    nav.navigateUp()
+                }
+            )
+            Ending(
+                notice = "21",
+                role = "管家",
+                noticeClick = {},
+                userClick = { popupState = !popupState }
+            )
+        }
+       
         if (popupState) {
             LogoutPopup(
                 click = {

+ 20 - 29
app/src/main/java/com/ys/bdtp/adm/mvvm/ui/screen/task/Tasks.kt

@@ -1,23 +1,10 @@
 package com.ys.bdtp.adm.mvvm.ui.screen.task
 
 import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.Arrangement
-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.*
 import androidx.compose.foundation.lazy.LazyColumn
 import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
+import androidx.compose.runtime.*
 import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
@@ -25,26 +12,30 @@ import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
-import com.ys.bdtp.adm.mvvm.ui.compose.Head
-import com.ys.bdtp.adm.mvvm.ui.compose.HeadLeft
+import com.ys.bdtp.adm.mvvm.ui.compose.Back
 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.screen.main.LocalNavHostController
 
 @Composable
 fun Tasks() {
     var value by remember { mutableStateOf("") }
+    val nav = LocalNavHostController.current!!
     Column(modifier = Modifier.fillMaxSize().background(Color.White)) {
-        Head(
-            left = { HeadLeft("") },
-            right = {
-                Ending(
-                    notice = "21",
-                    role = "管家",
-                    noticeClick = {},
-                    userClick = { println("heiheihei") }
-                )
-            }
-        )
-
+        Head {
+            Back(
+                title = "",
+                back = {
+                    nav.navigateUp()
+                }
+            )
+            Ending(
+                notice = "21",
+                role = "管家",
+                noticeClick = {},
+                userClick = { println("heiheihei") }
+            )
+        }
         Spacer(
             modifier = Modifier.fillMaxWidth().height(1.dp).background(Color(0xFFEFF0F1))
         )