Ulric 3 هفته پیش
والد
کامیت
f4a3a73f60

+ 11 - 0
app/src/main/java/com/ys/imageProcess/ui/work/EditToolBar.kt

@@ -0,0 +1,11 @@
+package com.ys.imageProcess.ui.work
+
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+
+@Composable
+fun EditToolBar(
+    modifier: Modifier = Modifier,
+    state: ImageState = ImageState(),
+    action: (ViewAction) -> Unit
+) {}

+ 9 - 7
app/src/main/java/com/ys/imageProcess/ui/work/ToolView.kt → app/src/main/java/com/ys/imageProcess/ui/work/ViewToolBar.kt

@@ -17,7 +17,7 @@ import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import com.ys.imageProcess.R
 import com.ys.imageProcess.ui.theme.Blue
-import com.ys.imageProcess.ui.work.ImageAction.*
+import com.ys.imageProcess.ui.work.ViewAction.*
 
 /**
  * 操作类型
@@ -28,8 +28,8 @@ import com.ys.imageProcess.ui.work.ImageAction.*
  * @property ShowWidth 显示宽
  * @property ShowContour 显示轮廓
  */
-enum class ImageAction {
-    Back, ZoomIn, ZoomOut, FitScreen, ShowContour, ShowLength, ShowWidth;
+enum class ViewAction {
+    Back, ZoomIn, ZoomOut, FitScreen, ShowContour, ShowLength, ShowWidth, ToEdit;
 
     fun icon(): Int {
         return when (this) {
@@ -40,6 +40,7 @@ enum class ImageAction {
             ShowContour -> R.drawable.show_contour
             ShowLength -> R.drawable.show_length
             ShowWidth -> R.drawable.show_width2
+            ToEdit -> R.drawable.edit_path2
         }
     }
 }
@@ -53,17 +54,17 @@ data class ImageState(
 )
 
 @Composable
-fun ToolView(
+fun ViewToolBar(
     modifier: Modifier = Modifier,
     state: ImageState = ImageState(),
-    action: (ImageAction) -> Unit
+    action: (ViewAction) -> Unit
 ) {
     Row(
         modifier.background(Color.LightGray),
         horizontalArrangement = Arrangement.SpaceEvenly,
         verticalAlignment = Alignment.CenterVertically
     ) {
-        ImageAction.entries.forEach { it ->
+        ViewAction.entries.forEach { it ->
             val enabled: Boolean = when (it) {
                 FitScreen -> !state.isFitScreen
                 else -> true
@@ -77,6 +78,7 @@ fun ToolView(
                 ShowContour -> if (state.showContour) Blue else Color.DarkGray
                 ShowLength -> if (state.showLength) Blue else Color.DarkGray
                 ShowWidth -> if (state.showWidth) Blue else Color.DarkGray
+                ToEdit -> Color.DarkGray
             }
 
             Button(
@@ -103,7 +105,7 @@ fun ToolView(
 @Preview(device = "id:pixel_tablet")
 @Composable
 private fun ToolPreview() {
-    ToolView {}
+    ViewToolBar {}
 }
 
 const val zoomStep = 1.5f

+ 2 - 2
app/src/main/java/com/ys/imageProcess/ui/work/WorkScreen.kt

@@ -120,14 +120,14 @@ fun WorkScreen(
                             .padding(20.dp)
                     )
                 }
-                ToolView(
+                ViewToolBar(
                     Modifier
                         .fillMaxWidth()
                         .height(80.dp),
                     imageState
                 ) { action ->
                     viewModel.executeImageAction(action)
-                    if (action == ImageAction.Back && back != null) {
+                    if (action == ViewAction.Back && back != null) {
                         back()
                     }
                 }

+ 11 - 9
app/src/main/java/com/ys/imageProcess/viewModel/WorkViewModel.kt

@@ -17,7 +17,7 @@ import com.ys.imageProcess.cv.Process
 import com.ys.imageProcess.cv.Process.DetectResult
 import com.ys.imageProcess.data.ProcessDataStore
 import com.ys.imageProcess.ocr.OCRModelLoader
-import com.ys.imageProcess.ui.work.ImageAction
+import com.ys.imageProcess.ui.work.ViewAction
 import com.ys.imageProcess.ui.work.ImageState
 import com.ys.imageProcess.ui.work.maxZoom
 import com.ys.imageProcess.ui.work.minZoom
@@ -196,24 +196,26 @@ class WorkViewModel : ViewModel() {
         mapData.value = map
     }
 
-    fun executeImageAction(action: ImageAction) {
+    fun executeImageAction(action: ViewAction) {
         when (action) {
-            ImageAction.Back -> {}
+            ViewAction.Back -> {}
 
-            ImageAction.ZoomIn -> zoomIn()
+            ViewAction.ZoomIn -> zoomIn()
 
-            ImageAction.ZoomOut -> zoomOut()
+            ViewAction.ZoomOut -> zoomOut()
 
-            ImageAction.FitScreen -> fitScreen()
+            ViewAction.FitScreen -> fitScreen()
 
-            ImageAction.ShowContour -> imageState.value =
+            ViewAction.ShowContour -> imageState.value =
                 imageState.value.copy(showContour = !imageState.value.showContour)
 
-            ImageAction.ShowLength -> imageState.value =
+            ViewAction.ShowLength -> imageState.value =
                 imageState.value.copy(showLength = !imageState.value.showLength)
 
-            ImageAction.ShowWidth -> imageState.value =
+            ViewAction.ShowWidth -> imageState.value =
                 imageState.value.copy(showWidth = !imageState.value.showWidth)
+
+            ViewAction.ToEdit -> {}
         }
 
         updateVisibleArea()