signature pad fix
This commit is contained in:
parent
ee91e6f787
commit
b3cb166f1a
@ -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")
|
||||
}
|
||||
|
||||
@ -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<DashboardMenuItem> = buildList {
|
||||
): List<DashboardMenuItem> {
|
||||
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(
|
||||
@ -228,6 +229,5 @@ fun buildMenuItems(
|
||||
) { onNavigateAmount("Cash Adv") }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
) {
|
||||
|
||||
|
||||
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)
|
||||
.border(width = 1.dp, color = AppColor.LegacyRed)
|
||||
.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 = {
|
||||
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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user