From 308bf48cad3b5caf97de23a3c86412967915bf0d Mon Sep 17 00:00:00 2001 From: Biplab Dutta Date: Fri, 27 Jun 2025 01:12:32 +0530 Subject: [PATCH 1/2] fix(feature:client): force white canvas background in signature screen --- .../clientSignature/SignatureScreen.android.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt b/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt index 653890797dd..2367eb4ed70 100644 --- a/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt +++ b/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt @@ -18,7 +18,10 @@ import androidclient.feature.client.generated.resources.feature_client_signature import androidclient.feature.client.generated.resources.feature_client_signature_uploaded_successfully import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -150,7 +153,17 @@ internal actual fun SignatureScreen( is SignatureUiState.Initial -> { paths.add(PathState(Path(), drawColor, drawBrush)) - MifosDrawingCanvas(drawColor = drawColor, drawBrush = drawBrush) + + // Force white background here instead of relying on MaterialTheme + // Required to maintain consistent white canvas in both light and dark modes + // for legibility and official document compliance. + Box( + modifier = Modifier + .fillMaxSize() + .background(Color.White), + ) { + MifosDrawingCanvas(drawColor = drawColor, drawBrush = drawBrush) + } } } } From 19fa32bbbb81444c83f29caba43de886aa099885 Mon Sep 17 00:00:00 2001 From: Biplab Dutta Date: Fri, 27 Jun 2025 02:13:13 +0530 Subject: [PATCH 2/2] fix(feature:client): fix client signature reset --- .../core/designsystem/component/DrawingState.kt | 5 +++++ .../clientSignature/SignatureScreen.android.kt | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/DrawingState.kt b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/DrawingState.kt index a274553566e..262194539d7 100644 --- a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/DrawingState.kt +++ b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/DrawingState.kt @@ -40,4 +40,9 @@ class DrawingState { fun resetCurrentPath() { currentPath.value = Path() } + + fun clear() { + paths.clear() + resetCurrentPath() + } } diff --git a/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt b/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt index 2367eb4ed70..18a846d20be 100644 --- a/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt +++ b/feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientSignature/SignatureScreen.android.kt @@ -32,7 +32,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -40,7 +39,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Rect import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.asAndroidBitmap import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.boundsInRoot @@ -49,12 +47,12 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.graphics.applyCanvas import androidx.core.graphics.createBitmap +import com.mifos.core.designsystem.component.DrawingState import com.mifos.core.designsystem.component.MifosCircularProgress import com.mifos.core.designsystem.component.MifosDrawingCanvas import com.mifos.core.designsystem.component.MifosScaffold import com.mifos.core.designsystem.component.MifosSweetError import com.mifos.core.designsystem.icon.MifosIcons -import com.mifos.core.designsystem.utility.PathState import io.github.vinceglb.filekit.PlatformFile import org.jetbrains.compose.resources.stringResource import java.io.ByteArrayOutputStream @@ -80,7 +78,7 @@ internal actual fun SignatureScreen( val drawColor = Color.Black val drawBrush = 5f - val paths = remember { mutableStateListOf() } + val drawingState = remember { DrawingState() } val galleryLauncher = rememberLauncherForActivityResult( contract = ActivityResultContracts.GetContent(), @@ -121,7 +119,7 @@ internal actual fun SignatureScreen( onClick = { navigationSelectedItem = index when (index) { - 0 -> paths.clear() + 0 -> drawingState.clear() 1 -> galleryLauncher.launch("image/*") } }, @@ -152,8 +150,6 @@ internal actual fun SignatureScreen( } is SignatureUiState.Initial -> { - paths.add(PathState(Path(), drawColor, drawBrush)) - // Force white background here instead of relying on MaterialTheme // Required to maintain consistent white canvas in both light and dark modes // for legibility and official document compliance. @@ -162,7 +158,11 @@ internal actual fun SignatureScreen( .fillMaxSize() .background(Color.White), ) { - MifosDrawingCanvas(drawColor = drawColor, drawBrush = drawBrush) + MifosDrawingCanvas( + drawColor = drawColor, + drawBrush = drawBrush, + drawingState = drawingState, + ) } } }