Compare commits

..

No commits in common. "6ddf0dda6c838b691774b81c8c12502e311db63c" and "feb6ea449fbcea7acbce0707b8e236f08ce56686" have entirely different histories.

10 changed files with 319 additions and 324 deletions

View File

@ -1,3 +0,0 @@
## Working agreements
- use Scaffold and AppBar() in every main Screen

View File

@ -1,48 +1,12 @@
package com.mob.utsmyanmar.ui.amount
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBackIosNew
import androidx.compose.material.icons.rounded.Backspace
import androidx.compose.material.icons.rounded.KeyboardArrowLeft
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.mob.utsmyanmar.ui.components.appbar.AppBar
import com.mob.utsmyanmar.ui.components.NumericEntryScreen
import com.mob.utsmyanmar.ui.preview.P2Preview
import com.mob.utsmyanmar.ui.theme.Color
@Composable
fun AmountScreen(
@ -52,14 +16,7 @@ fun AmountScreen(
) {
var amount by remember { mutableStateOf("") }
Scaffold(
topBar = {
AppBar(title = title, icon = Icons.Default.ArrowBackIosNew, onIconClick = onBackClick)
}
) { paddingValues ->
NumericEntryScreen(
modifier = Modifier.padding(paddingValues),
title = title,
prompt = "Enter $title",
displayValue = formatAmount(amount.ifEmpty { "0" }),
@ -82,215 +39,6 @@ fun AmountScreen(
confirmEnabled = amount.isNotEmpty(),
canDelete = amount.isNotEmpty()
)
}
}
@Composable
fun NumericEntryScreen(
title: String,
prompt: String,
displayValue: String,
supportingText: String,
confirmText: String,
onBackClick: () -> Unit,
onCancelClick: () -> Unit,
onConfirmClick: () -> Unit,
onKeyClick: (String) -> Unit,
onDeleteClick: () -> Unit,
modifier: Modifier = Modifier,
prefixLabel: String? = null,
errorMessage: String? = null,
confirmEnabled: Boolean = true,
canDelete: Boolean = true,
keys: List<List<String>> = listOf(
listOf("1", "2", "3"),
listOf("4", "5", "6"),
listOf("7", "8", "9"),
listOf(".", "0", "00")
)
) {
Box(
modifier = modifier
.fillMaxSize()
.background(Color.IvoryBeige)
.navigationBarsPadding()
.statusBarsPadding()
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 20.dp)
) {
Text(
text = prompt,
color = Color.Gray,
fontSize = 11.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(modifier = Modifier.height(8.dp))
Row(
modifier = Modifier.align(Alignment.CenterHorizontally),
verticalAlignment = Alignment.Bottom
) {
if (!prefixLabel.isNullOrBlank()) {
Text(
text = prefixLabel,
color = Color.LegacyRed,
fontSize = 13.sp,
fontWeight = FontWeight.Medium,
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
)
}
Text(
text = displayValue,
color = Color.LegacyRed,
fontSize = 32.sp,
fontWeight = FontWeight.Bold
)
}
Spacer(modifier = Modifier.height(12.dp))
Text(
text = supportingText,
color = if (errorMessage == null) Color.Gray else Color.Error,
fontSize = 11.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(modifier = Modifier.height(80.dp))
NumericKeypad(
keys = keys,
onKeyClick = onKeyClick
)
Spacer(modifier = Modifier.weight(1f))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
Button(
onClick = onCancelClick,
modifier = Modifier
.weight(1f)
.height(56.dp),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
containerColor = Color.White,
contentColor = Color.LegacyRed
)
) {
Text("Cancel")
}
Button(
onClick = onConfirmClick,
modifier = Modifier
.weight(1f)
.height(56.dp),
enabled = confirmEnabled,
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
containerColor = Color.LegacyRed,
contentColor = Color.White,
disabledContainerColor = Color.LegacyRed.copy(alpha = 0.5f),
disabledContentColor = Color.White
)
) {
Text(
text = confirmText,
fontSize = 14.sp,
fontWeight = FontWeight.Medium
)
}
}
Spacer(modifier = Modifier.height(18.dp))
}
Card(
modifier = Modifier
.align(Alignment.TopEnd)
.padding(top = 25.dp, end = 20.dp)
.clickable(enabled = canDelete) {
onDeleteClick()
},
shape = RoundedCornerShape(18.dp),
colors = CardDefaults.cardColors(containerColor = Color.White),
elevation = CardDefaults.cardElevation(defaultElevation = 6.dp)
) {
Icon(
imageVector = Icons.Rounded.Backspace,
contentDescription = "Delete",
tint = if (canDelete) Color.LegacyRed else Color.Gray,
modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp)
)
}
}
}
@Composable
private fun NumericKeypad(
keys: List<List<String>>,
onKeyClick: (String) -> Unit
) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(6.dp)
) {
keys.forEach { row ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
row.forEach { key ->
KeypadButton(
text = key,
modifier = Modifier.weight(1f),
onClick = { onKeyClick(key) }
)
}
}
}
}
}
@Composable
private fun KeypadButton(
text: String,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
val enabled = text.isNotBlank()
Box(
modifier = modifier
.height(66.dp)
.shadow(
elevation = 2.dp,
shape = RoundedCornerShape(8.dp),
clip = false
)
.background(
color = Color.White,
shape = RoundedCornerShape(8.dp)
)
.clickable(enabled = enabled) { onClick() },
contentAlignment = Alignment.Center
) {
Text(
text = text,
color = if (enabled) Color.LegacyRed else Color.White,
fontSize = 24.sp,
fontWeight = FontWeight.Normal,
textAlign = TextAlign.Center
)
}
}
private fun formatAmount(value: String): String {
@ -341,23 +89,3 @@ private fun appendAmountValue(current: String, value: String): String {
fun PreviewAmountScreen() {
AmountScreen { }
}
@Preview(showBackground = true)
@Composable
private fun PreviewNumericEntryScreen() {
NumericEntryScreen(
title = "Amount",
prompt = "Enter Amount",
displayValue = "12,500",
supportingText = "Enter the amount to continue",
confirmText = "Next",
onBackClick = {},
onCancelClick = {},
onConfirmClick = {},
onKeyClick = {},
onDeleteClick = {},
prefixLabel = "MMK",
confirmEnabled = true,
canDelete = true
)
}

View File

@ -0,0 +1,270 @@
package com.mob.utsmyanmar.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Backspace
import androidx.compose.material.icons.rounded.KeyboardArrowLeft
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.mob.utsmyanmar.ui.theme.Color
@Composable
fun NumericEntryScreen(
title: String,
prompt: String,
displayValue: String,
supportingText: String,
confirmText: String,
onBackClick: () -> Unit,
onCancelClick: () -> Unit,
onConfirmClick: () -> Unit,
onKeyClick: (String) -> Unit,
onDeleteClick: () -> Unit,
modifier: Modifier = Modifier,
prefixLabel: String? = null,
errorMessage: String? = null,
confirmEnabled: Boolean = true,
canDelete: Boolean = true,
keys: List<List<String>> = listOf(
listOf("1", "2", "3"),
listOf("4", "5", "6"),
listOf("7", "8", "9"),
listOf(".", "0", "00")
)
) {
Box(
modifier = modifier
.fillMaxSize()
.background(Color.IvoryBeige)
.navigationBarsPadding()
.statusBarsPadding()
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 20.dp)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(56.dp),
contentAlignment = Alignment.Center
) {
IconButton(
onClick = onBackClick,
modifier = Modifier.align(Alignment.CenterStart)
) {
Icon(
imageVector = Icons.Rounded.KeyboardArrowLeft,
contentDescription = "Back",
tint = Color.LegacyRed
)
}
Text(
text = title,
color = Color.LegacyRed,
fontSize = 14.sp,
fontWeight = FontWeight.Bold
)
}
Spacer(modifier = Modifier.height(36.dp))
Text(
text = prompt,
color = Color.Gray,
fontSize = 11.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(modifier = Modifier.height(8.dp))
Row(
modifier = Modifier.align(Alignment.CenterHorizontally),
verticalAlignment = Alignment.Bottom
) {
if (!prefixLabel.isNullOrBlank()) {
Text(
text = prefixLabel,
color = Color.LegacyRed,
fontSize = 13.sp,
fontWeight = FontWeight.Medium,
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
)
}
Text(
text = displayValue,
color = Color.LegacyRed,
fontSize = 32.sp,
fontWeight = FontWeight.Bold
)
}
Spacer(modifier = Modifier.height(12.dp))
Text(
text = supportingText,
color = if (errorMessage == null) Color.Gray else Color.Error,
fontSize = 11.sp,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(modifier = Modifier.height(28.dp))
NumericKeypad(
keys = keys,
onKeyClick = onKeyClick
)
Spacer(modifier = Modifier.weight(1f))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
Button(
onClick = onCancelClick,
modifier = Modifier
.weight(1f)
.height(56.dp),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
containerColor = Color.White,
contentColor = Color.LegacyRed
)
) {
Text("Cancel")
}
Button(
onClick = onConfirmClick,
modifier = Modifier
.weight(1f)
.height(56.dp),
enabled = confirmEnabled,
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(
containerColor = Color.LegacyRed,
contentColor = Color.White,
disabledContainerColor = Color.LegacyRed.copy(alpha = 0.5f),
disabledContentColor = Color.White
)
) {
Text(
text = confirmText,
fontSize = 14.sp,
fontWeight = FontWeight.Medium
)
}
}
Spacer(modifier = Modifier.height(18.dp))
}
Card(
modifier = Modifier
.align(Alignment.TopEnd)
.padding(top = 110.dp, end = 20.dp)
.clickable(enabled = canDelete) {
onDeleteClick()
},
shape = RoundedCornerShape(18.dp),
colors = CardDefaults.cardColors(containerColor = Color.White),
elevation = CardDefaults.cardElevation(defaultElevation = 6.dp)
) {
Icon(
imageVector = Icons.Rounded.Backspace,
contentDescription = "Delete",
tint = if (canDelete) Color.LegacyRed else Color.Gray,
modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp)
)
}
}
}
@Composable
private fun NumericKeypad(
keys: List<List<String>>,
onKeyClick: (String) -> Unit
) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(6.dp)
) {
keys.forEach { row ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
row.forEach { key ->
KeypadButton(
text = key,
modifier = Modifier.weight(1f),
onClick = { onKeyClick(key) }
)
}
}
}
}
}
@Composable
private fun KeypadButton(
text: String,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
val enabled = text.isNotBlank()
Box(
modifier = modifier
.height(66.dp)
.shadow(
elevation = 2.dp,
shape = RoundedCornerShape(8.dp),
clip = false
)
.background(
color = Color.White,
shape = RoundedCornerShape(8.dp)
)
.clickable(enabled = enabled) { onClick() },
contentAlignment = Alignment.Center
) {
Text(
text = text,
color = if (enabled) Color.LegacyRed else Color.White,
fontSize = 24.sp,
fontWeight = FontWeight.Normal,
textAlign = TextAlign.Center
)
}
}

View File

@ -24,7 +24,7 @@ import com.mob.utsmyanmar.ui.print_receipt.PrintReceiptScreen
import com.mob.utsmyanmar.ui.refund_rrn.InputRrnRoute
import com.mob.utsmyanmar.ui.sign_on.SignOnResultScreen
import com.mob.utsmyanmar.ui.sign_on.SignOnRoute
import com.mob.utsmyanmar.ui.sending_to_host.ProcessingRoute
import com.mob.utsmyanmar.ui.sending_to_host.SendingToHostRoute
import com.mob.utsmyanmar.ui.settlement.SettlementScreen
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultRoute
import com.mob.utsmyanmar.ui.sale_void.TranDetailPage
@ -118,7 +118,7 @@ fun AppNavGraph(
onBack = { navController.popBackStack() },
onStartSettlement = {
sharedViewModel.transactionsType.value = com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType.SETTLEMENT
navController.navigate(Routes.Processing.route) {
navController.navigate(Routes.SendingToHost.route) {
popUpTo(Routes.Settlement.route) {
inclusive = true
}
@ -147,7 +147,7 @@ fun AppNavGraph(
onProceedVoid = { payDetail ->
sharedViewModel.transactionsType.value = com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType.VOID
sharedViewModel.payDetail.value = payDetail
navController.navigate(Routes.Processing.route) {
navController.navigate(Routes.SendingToHost.route) {
popUpTo(Routes.VoidTranDetail.route) {
inclusive = true
}
@ -320,8 +320,8 @@ fun AppNavGraph(
launchSingleTop = true
}
},
onNavigateProcessing = {
navController.navigate(Routes.Processing.route) {
onNavigateSendingToHost = {
navController.navigate(Routes.SendingToHost.route) {
popUpTo(Routes.PinPad.route) {
inclusive = true
}
@ -338,8 +338,8 @@ fun AppNavGraph(
InputRrnRoute(
sharedViewModel = sharedViewModel,
onBack = { navController.popBackStack() },
onNavigateProcessing = {
navController.navigate(Routes.Processing.route) {
onNavigateSendingToHost = {
navController.navigate(Routes.SendingToHost.route) {
popUpTo(Routes.InputRrn.route) {
inclusive = true
}
@ -349,14 +349,14 @@ fun AppNavGraph(
)
}
composable(Routes.Processing.route) {
composable(Routes.SendingToHost.route) {
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
ProcessingRoute(
SendingToHostRoute(
sharedViewModel = sharedViewModel,
onNavigateTransactionResult = {
navController.navigate(Routes.TransactionResult.route) {
popUpTo(Routes.Processing.route) {
popUpTo(Routes.SendingToHost.route) {
inclusive = true
}
launchSingleTop = true

View File

@ -23,7 +23,7 @@ sealed class Routes(val route: String) {
data object ProcessingCard : Routes("processing_card")
data object PinPad : Routes("pin_pad")
data object InputRrn : Routes("input_rrn")
data object Processing : Routes("processing")
data object SendingToHost : Routes("sending_to_host")
data object TransactionResult : Routes("transaction_result")
data object PrintReceipt : Routes("print_receipt")
}

View File

@ -18,7 +18,7 @@ fun PinPadRoute(
sharedViewModel: SharedViewModel,
transProcessViewModel: TransProcessViewModel,
onNavigateInputRrn: () -> Unit,
onNavigateProcessing: () -> Unit,
onNavigateSendingToHost: () -> Unit,
onBack: () -> Unit
) {
val pinText by pinPadViewModel.pinText.collectAsStateWithLifecycle()
@ -41,7 +41,7 @@ fun PinPadRoute(
if (sharedViewModel.transactionsType.value == TransactionsType.REFUND) {
onNavigateInputRrn()
} else {
onNavigateProcessing()
onNavigateSendingToHost()
}
}

View File

@ -5,7 +5,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.mob.utsmyanmar.ui.amount.NumericEntryScreen
import com.mob.utsmyanmar.ui.components.NumericEntryScreen
import com.mob.utsmyanmar.viewmodel.SharedViewModel
import com.utsmyanmar.paylibs.utils.POSUtil
@ -15,7 +15,7 @@ private const val RRN_MAX_LENGTH = 12
fun InputRrnRoute(
sharedViewModel: SharedViewModel,
onBack: () -> Unit,
onNavigateProcessing: () -> Unit
onNavigateSendingToHost: () -> Unit
) {
var rrn by rememberSaveable {
mutableStateOf(sharedViewModel.rrNNo.value.orEmpty())
@ -42,7 +42,7 @@ fun InputRrnRoute(
payDetail.referNo = trimmedRrn
sharedViewModel.payDetail.value = payDetail
}
onNavigateProcessing()
onNavigateSendingToHost()
},
onKeyClick = { value ->
rrn = appendRrnValue(rrn, value)

View File

@ -8,7 +8,7 @@ import kotlinx.coroutines.delay
private const val MOCK_HOST_DELAY_MS = 2000L
@Composable
fun ProcessingRoute(
fun SendingToHostRoute(
sharedViewModel: SharedViewModel,
onNavigateTransactionResult: () -> Unit
) {
@ -18,5 +18,5 @@ fun ProcessingRoute(
onNavigateTransactionResult()
}
ProcessingScreen()
SendingToHostScreen()
}

View File

@ -25,7 +25,7 @@ import com.mob.utsmyanmar.ui.theme.Primary
import com.mob.utsmyanmar.ui.theme.White
@Composable
fun ProcessingScreen() {
fun SendingToHostScreen() {
Scaffold(
containerColor = White
) { paddingValues ->
@ -57,7 +57,7 @@ fun ProcessingScreen() {
Spacer(modifier = Modifier.height(20.dp))
Text(
text = "Processing",
text = "Sending Data",
color = White,
fontSize = 24.sp,
fontWeight = FontWeight.Bold
@ -66,7 +66,7 @@ fun ProcessingScreen() {
Spacer(modifier = Modifier.height(10.dp))
Text(
text = "Please wait while your transaction is being processed.",
text = "Please wait while we send transaction data to host.",
color = White,
fontSize = 15.sp,
textAlign = TextAlign.Center
@ -77,7 +77,7 @@ fun ProcessingScreen() {
Spacer(modifier = Modifier.height(24.dp))
Text(
text = "Transaction processing in progress.",
text = "Mock host communication in progress.",
color = Black,
fontSize = 14.sp,
textAlign = TextAlign.Center

View File

@ -347,12 +347,12 @@ public class ISOSocket {
* If it is not secondary, go with primary
*/
if (!isSwitchIp) {
// serverIP = getIp();
// serverPort = getPort();
serverIP = getIp();
serverPort = getPort();
// serverIP = "posuat.myanmarorientalbank.com";
// serverPort = 5033;
serverIP = "192.168.100.9";
serverPort = 5001;
// serverIP = "10.255.255.195";
// serverPort = 5555;
} else {
isSwitchIp = false;
}