Kaynağa Gözat

增加退出编辑的选项

Ulric 5 gün önce
ebeveyn
işleme
e6547e18f9

+ 4 - 4
app/src/main/java/com/ys/imageProcess/ui/work/ViewToolBar.kt

@@ -87,14 +87,14 @@ fun ViewToolBar(
             }
 
             val text: String = when (it) {
-                Back -> "退出"
+                Back -> if (state.editMode) "退出编辑" else "首页"
                 ZoomIn -> "放大"
                 ZoomOut -> "缩小"
                 FitScreen -> "适应屏幕"
                 ShowContour -> if (state.editMode) "调整轮廓" else "显示轮廓"
-                ShowLength -> if (state.editMode) "调整长度" else "显示长度"
-                ShowWidth -> if (state.editMode) "调整宽度" else "显示宽度"
-                SwitchEdit -> if (state.editMode) "保存" else "调整"
+                ShowLength -> if (state.editMode) "调整中线" else "显示中线"
+                ShowWidth -> if (state.editMode) "调整宽线" else "显示宽线"
+                SwitchEdit -> if (state.editMode) "保存" else "编辑"
             }
 
             Button(

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

@@ -139,9 +139,16 @@ fun WorkScreen(
                         .height(80.dp),
                     imageState
                 ) { action ->
-                    viewModel.executeImageAction(action)
-                    if (action == ViewAction.Back && back != null) {
-                        back()
+                    if (action == ViewAction.Back) {
+                        if (imageState.editMode) {
+                            viewModel.handleActions(ViewAction.SwitchEdit)
+                        } else {
+                            if (back != null) {
+                                back()
+                            }
+                        }
+                    } else {
+                        viewModel.handleActions(action)
                     }
                 }
             }

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

@@ -280,7 +280,7 @@ class WorkViewModel : ViewModel() {
         return Pair(pathIndex, pointIndex)
     }
 
-    fun executeImageAction(action: ViewAction) {
+    fun handleActions(action: ViewAction) {
         when (action) {
             ViewAction.Back -> {}