File tree Expand file tree Collapse file tree
artmaker/src/main/java/io/artmaker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ fun ArtMaker(
8080 finishedImage?.let { onFinishDrawing(it) }
8181 }
8282
83+ LaunchedEffect (key1 = state.canErase) {
84+ if (! state.canErase) {
85+ isEraserActive = false
86+ }
87+ }
88+
8389 Scaffold (
8490 floatingActionButton = {
8591 AnimatedVisibility (
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ data class ArtMakerUIState(
2828 val canRedo : Boolean = false ,
2929 val canUndo : Boolean = false ,
3030 val canClear : Boolean = false ,
31+ val canErase : Boolean = false ,
3132 val shouldUseStylusOnly : Boolean = false ,
3233 val shouldDetectPressure : Boolean = false ,
3334 val canShowEnableStylusDialog : Boolean = true ,
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ internal class ArtMakerViewModel(
104104 canRedo = state.canRedo,
105105 canUndo = state.canUndo,
106106 canClear = state.canClear,
107+ canErase = state.canErase,
107108 )
108109 }
109110 }
Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ internal fun ArtMakerControlMenu(
150150 )
151151 },
152152 onItemClicked = onActivateEraser,
153+ enabled = state.canErase,
153154 )
154155 MenuItem (
155156 imageVector = ImageVector .vectorResource(id = R .drawable.ic_undo),
Original file line number Diff line number Diff line change @@ -72,9 +72,11 @@ internal class DrawingManager {
7272 }
7373
7474 private fun updateCurrentShape (offset : Offset , pressure : Float ) {
75- val idx = _pathList .lastIndex
76- _pathList [idx].points.add(offset)
77- _pathList [idx].alphas.add(pressure)
75+ if (pathList.isNotEmpty()) {
76+ val idx = _pathList .lastIndex
77+ _pathList [idx].points.add(offset)
78+ _pathList [idx].alphas.add(pressure)
79+ }
7880 }
7981
8082 private fun undoLastShapePoint () {
You can’t perform that action at this time.
0 commit comments