diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a615392..9aac83f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,8 +40,8 @@ android { dimension = "env" applicationIdSuffix = ".uat" versionNameSuffix = "-UAT" - versionCode = 12 - versionName = "3.0" + versionCode = 14 + versionName = "3.2" buildConfigField("String", "ENV", "\"UAT\"") resValue("string", "app_name", "MOB-UAT") } diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardMenuItems.kt b/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardMenuItems.kt index 066884a..65556e4 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardMenuItems.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardMenuItems.kt @@ -25,24 +25,25 @@ class DashboardMenuItem( val onClick: () -> Unit ) -val settlementEnabled = false -val voidEnabled = true -val refundEnabled = true -val preAuthEnabled = true -val preAuthVoidEnabled = true -val preAuthCompleteEnabled = true -val preAuthCompleteVoidEnabled = true -val cashAdvEnabled = true - fun buildMenuItems( onNavigateAmount: (String) -> Unit, onNavigateSignOn: () -> Unit, onNavigateSettlement: () -> Unit, onNavigateHistory: () -> Unit, onNavigateAction: (String) -> Unit -): List = buildList { +): List { + val sp = SystemParamsOperation.getInstance() + val settlementEnabled = sp.settlementStatus + val voidEnabled = sp.voidStatus + val refundEnabled = sp.refundStatus + val preAuthEnabled = sp.preAuthStatus + val preAuthVoidEnabled = sp.preAuthStatus + val preAuthCompleteEnabled = sp.preAuthStatus + val preAuthCompleteVoidEnabled = sp.preAuthStatus + val cashAdvEnabled = sp.cashAdvanceStatus + val mmqrEnabled = sp.mmqrStatus + return buildList { - val mmqrEnabled = SystemParamsOperation.getInstance().mmqrStatus add( DashboardMenuItem( @@ -59,175 +60,174 @@ fun buildMenuItems( ) - if (mmqrEnabled) { + if (mmqrEnabled) { + add( + DashboardMenuItem( + "MMQR", + { + Image( + painter = painterResource(R.drawable.ic_mmqr_logo), + contentDescription = null, + modifier = Modifier.height(48.dp) + ) + } + ) { } + ) + } add( DashboardMenuItem( - "MMQR", - { - Image( - painter = painterResource(R.drawable.ic_mmqr_logo), - contentDescription = null, - modifier = Modifier.height(48.dp) - ) - } - ) { } - ) - } - add( - DashboardMenuItem( - "History", - { - Icon( - painterResource(R.drawable.ic_history), - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateHistory() } - ) - - add( - DashboardMenuItem( - "Sign On", - { - Icon( - painterResource(R.drawable.ic_sign_on), - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateSignOn() } - ) - - if (settlementEnabled) { - add( - DashboardMenuItem( - "Settlement", + "History", { Icon( - painterResource(R.drawable.ic_settlement), + painterResource(R.drawable.ic_history), contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed ) } - ) { onNavigateSettlement() } + ) { onNavigateHistory() } ) - } - if (voidEnabled) { add( DashboardMenuItem( - "Void", + "Sign On", { Icon( - Icons.Default.Lock, + painterResource(R.drawable.ic_sign_on), contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed ) } - ) { onNavigateAction("Void") } + ) { onNavigateSignOn() } ) + + if (settlementEnabled) { + add( + DashboardMenuItem( + "Settlement", + { + Icon( + painterResource(R.drawable.ic_settlement), + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateSettlement() } + ) + } + + if (voidEnabled) { + add( + DashboardMenuItem( + "Void", + { + Icon( + Icons.Default.Lock, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAction("Void") } + ) + } + + if (refundEnabled) { + add( + DashboardMenuItem( + "Refund", + { + Icon( + Icons.Default.Replay, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAction("Refund") } + ) + } + + if (preAuthEnabled) { + add( + DashboardMenuItem( + "Pre-Auth", + { + Icon( + Icons.Default.Lock, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAmount("Pre-Auth") } + ) + } + + if (preAuthVoidEnabled) { + add( + DashboardMenuItem( + "Pre-Auth Void", + { + Icon( + Icons.Default.LockOpen, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAction("Pre-Auth Void") } + ) + } + + if (preAuthCompleteEnabled) { + add( + DashboardMenuItem( + "Pre-Auth Complete", + { + Icon( + Icons.Default.CreditCard, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAction("Pre-Auth Complete") } + ) + } + + if (preAuthCompleteVoidEnabled) { + add( + DashboardMenuItem( + "Pre-Auth Comp Void", + { + Icon( + Icons.Default.SwapHoriz, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAction("Pre-Auth Complete Void") } + ) + } + + if (cashAdvEnabled) { + add( + DashboardMenuItem( + "Cash Adv", + { + Icon( + Icons.Default.AccountBalanceWallet, + contentDescription = null, + modifier = Modifier.size(32.dp), + tint = Color.LegacyRed + ) + } + ) { onNavigateAmount("Cash Adv") } + ) + } } - - if (refundEnabled) { - add( - DashboardMenuItem( - "Refund", - { - Icon( - Icons.Default.Replay, - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateAction("Refund") } - ) - } - - if (preAuthEnabled) { - add( - DashboardMenuItem( - "Pre-Auth", - { - Icon( - Icons.Default.Lock, - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateAmount("Pre-Auth") } - ) - } - - if (preAuthVoidEnabled) { - add( - DashboardMenuItem( - "Pre-Auth Void", - { - Icon( - Icons.Default.LockOpen, - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateAction("Pre-Auth Void") } - ) - } - - if (preAuthCompleteEnabled) { - add( - DashboardMenuItem( - "Pre-Auth Complete", - { - Icon( - Icons.Default.CreditCard, - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateAction("Pre-Auth Complete") } - ) - } - - if (preAuthCompleteVoidEnabled) { - add( - DashboardMenuItem( - "Pre-Auth Comp Void", - { - Icon( - Icons.Default.SwapHoriz, - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateAction("Pre-Auth Complete Void") } - ) - } - - if (cashAdvEnabled) { - add( - DashboardMenuItem( - "Cash Adv", - { - Icon( - Icons.Default.AccountBalanceWallet, - contentDescription = null, - modifier = Modifier.size(32.dp), - tint = Color.LegacyRed - ) - } - ) { onNavigateAmount("Cash Adv") } - ) - } - - } diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/signature_pad/SignaturePad.kt b/app/src/main/java/com/mob/utsmyanmar/ui/signature_pad/SignaturePad.kt index 1a829a3..cfcce97 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/signature_pad/SignaturePad.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/signature_pad/SignaturePad.kt @@ -1,6 +1,7 @@ package com.mob.utsmyanmar.ui.signature_pad import android.graphics.Bitmap +import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -15,10 +16,13 @@ import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Scaffold import androidx.compose.material3.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.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview @@ -37,6 +41,8 @@ fun SignaturePad( onConfirm: (Bitmap?, ByteArray?) -> Unit = { _, _ -> } ) { var signaturePadAdapter: SignaturePadAdapter? = null + var selectedMode by remember { mutableStateOf(SignatureMode.Digital) } + val isManualMode = selectedMode == SignatureMode.Manual val scaledWidth = 300 @@ -69,33 +75,102 @@ fun SignaturePad( .padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp) ) { - SignaturePadView( - onReady = { signaturePadAdapter = it }, - modifier = Modifier - .fillMaxWidth() - .height(200.dp) - .border(width = 1.dp, color = AppColor.LegacyRed) - ) + + + if (isManualMode) { + Card( + modifier = Modifier + .fillMaxWidth() + .height(200.dp), + shape = RoundedCornerShape(8.dp), + colors = CardDefaults.cardColors(containerColor = Color.White), + border = androidx.compose.foundation.BorderStroke( + width = 1.dp, + color = AppColor.Gray.copy(alpha = 0.35f) + ) + ) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = androidx.compose.ui.Alignment.CenterHorizontally + ) { + Text( + text = "Manual Signature", + style = MaterialTheme.typography.titleMedium, + color = AppColor.Gray + ) + Text( + text = "Customer need to sign on paper", + style = MaterialTheme.typography.bodySmall, + color = AppColor.Gray.copy(alpha = 0.7f) + ) + } + } + } else { + SignaturePadView( + onReady = { signaturePadAdapter = it }, + modifier = Modifier + .fillMaxWidth() + .height(200.dp) + .background(AppColor.White) + .border(width = 1.dp, color = AppColor.LegacyRed, shape = RoundedCornerShape(8.dp)), + ) + } + + Column( + modifier = Modifier.fillMaxWidth(), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + SignatureModeOption( + title = "Digital", + subtitle = "Sign on screen", + selected = !isManualMode, + onClick = { selectedMode = SignatureMode.Digital }, + modifier = Modifier.fillMaxWidth() + ) + SignatureModeOption( + title = "Manual", + subtitle = "Sign on paper", + selected = isManualMode, + onClick = { selectedMode = SignatureMode.Manual }, + modifier = Modifier.fillMaxWidth() + ) + } Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp) ) { - OutlinedButton( - onClick = { signaturePadAdapter?.clear() }, + Button( + onClick = { + if (!isManualMode) { + signaturePadAdapter?.clear() + } + }, + colors = ButtonDefaults.buttonColors( + containerColor = AppColor.White, + contentColor = Color.White + ), modifier = Modifier .weight(1f) - .height(50.dp) + .height(50.dp), + enabled = !isManualMode ) { - Text("Clear") + Text("Clear", color = AppColor.Black) } Button( onClick = { - val rawBitmap = signaturePadAdapter?.getSignatureBitmap() - val bitmap = rawBitmap?.let { scaleBitmap(it) } - val signatureBlob = bitmap?.let { bitmapToBlob(it) } - onConfirm(bitmap, signatureBlob) + if (isManualMode) { + onConfirm(null, null) + } else { + val rawBitmap = signaturePadAdapter?.getSignatureBitmap() + val bitmap = rawBitmap?.let { scaleBitmap(it) } + val signatureBlob = bitmap?.let { bitmapToBlob(it) } + onConfirm(bitmap, signatureBlob) + } }, modifier = Modifier .weight(1f)