Compare commits
No commits in common. "ee2f9df3518e6c6944b5e4f799c5bbf21e188dbb" and "44c0fa20af5a3907d634594512290f4b85a50619" have entirely different histories.
ee2f9df351
...
44c0fa20af
@ -1,34 +0,0 @@
|
||||
package com.mob.utsmyanmar.ui.amount
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.mob.utsmyanmar.model.ProcessCode
|
||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
||||
|
||||
@Composable
|
||||
fun AmountRoute(
|
||||
action: String,
|
||||
sharedViewModel: SharedViewModel,
|
||||
onBack: () -> Unit,
|
||||
onNavigateCardWaiting: () -> Unit
|
||||
) {
|
||||
val canGoBack = !action.equals("Sale", ignoreCase = true)
|
||||
|
||||
AmountScreen(
|
||||
action = action,
|
||||
canGoBack = canGoBack,
|
||||
onBackClick = onBack,
|
||||
onCancelClick = onBack,
|
||||
onNextClick = { amount ->
|
||||
sharedViewModel.amount.value = amount
|
||||
sharedViewModel.setAmountExist(true)
|
||||
sharedViewModel.setCardDataExist(false)
|
||||
sharedViewModel.setTransMenu(null)
|
||||
sharedViewModel.transactionsType.value = TransactionsType.SALE
|
||||
sharedViewModel.processCode.value =
|
||||
ProcessCode.SALE_PURCHASE + ProcessCode.SMART + ProcessCode.TO_ACCOUNT
|
||||
|
||||
onNavigateCardWaiting()
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package com.mob.utsmyanmar.ui.amount
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@ -33,14 +32,10 @@ import com.mob.utsmyanmar.R
|
||||
@Composable
|
||||
fun AmountScreen(
|
||||
action: String,
|
||||
canGoBack: Boolean = true,
|
||||
onBackClick: () -> Unit,
|
||||
onCancelClick: () -> Unit = {},
|
||||
onNextClick: (String) -> Unit = {}
|
||||
) {
|
||||
BackHandler(enabled = canGoBack) {
|
||||
onBackClick()
|
||||
}
|
||||
|
||||
var amount by remember {
|
||||
mutableStateOf("0")
|
||||
@ -58,7 +53,6 @@ fun AmountScreen(
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
if (canGoBack) {
|
||||
IconButton(onClick = onBackClick) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_left_arrow),
|
||||
@ -67,7 +61,6 @@ fun AmountScreen(
|
||||
tint = White
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = Primary
|
||||
@ -111,27 +104,6 @@ fun AmountScreen(
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp)
|
||||
) {
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
onNextClick(normalizeAmount(amount))
|
||||
},
|
||||
modifier = Modifier
|
||||
.weight(if (canGoBack) 1f else 2f)
|
||||
.height(68.dp),
|
||||
shape = RoundedCornerShape(18.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Primary,
|
||||
contentColor = White
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Enter",
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
|
||||
if (canGoBack) {
|
||||
Button(
|
||||
onClick = onCancelClick,
|
||||
modifier = Modifier
|
||||
@ -150,6 +122,25 @@ fun AmountScreen(
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
onNextClick(normalizeAmount(amount))
|
||||
},
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(68.dp),
|
||||
shape = RoundedCornerShape(18.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Primary,
|
||||
contentColor = White
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Enter",
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +356,6 @@ private fun AmountScreenPreview() {
|
||||
|
||||
AmountScreen(
|
||||
action = "Amount",
|
||||
canGoBack = true,
|
||||
onBackClick = {}
|
||||
)
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ fun CardWaitingScreen(
|
||||
}
|
||||
}
|
||||
|
||||
BackHandler(enabled = uiState.canGoBack) {
|
||||
BackHandler {
|
||||
viewModel.onBackPressed()
|
||||
}
|
||||
|
||||
@ -90,7 +90,6 @@ fun CardWaitingScreen(
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
if (uiState.canGoBack) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_left_arrow),
|
||||
@ -98,7 +97,6 @@ fun CardWaitingScreen(
|
||||
tint = White
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = Primary
|
||||
|
||||
@ -3,6 +3,5 @@ package com.mob.utsmyanmar.ui.cardwaiting
|
||||
data class CardWaitingUiState(
|
||||
val alertMessage: String = "Please insert, tap, or swipe card",
|
||||
val isLoading: Boolean = false,
|
||||
val isFallback: Boolean = false,
|
||||
val canGoBack: Boolean = true
|
||||
val isFallback: Boolean = false
|
||||
)
|
||||
@ -61,11 +61,6 @@ class CardWaitingViewModel(
|
||||
retryCounter = 0
|
||||
fallbackCounter = SystemParamsOperation.getInstance().fallbackCounter
|
||||
fallbackEnabled = SystemParamsOperation.getInstance().fallbackEnabled
|
||||
val isSaleTransaction = sharedViewModel.transactionsType.value == TransactionsType.SALE
|
||||
|
||||
_uiState.update {
|
||||
it.copy(canGoBack = !isSaleTransaction)
|
||||
}
|
||||
|
||||
if (sharedViewModel.transactionsType.value == TransactionsType.REFUND) {
|
||||
sharedViewModel.enableCardStatusIcon(false, false, false, false)
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
package com.mob.utsmyanmar.ui.dashboard
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun DashboardRoute(
|
||||
onNavigateAmount: (String) -> Unit,
|
||||
settlementEnabled: Boolean,
|
||||
wavePayEnabled: Boolean,
|
||||
) {
|
||||
DashboardScreen(
|
||||
settlementEnabled = settlementEnabled,
|
||||
wavePayEnabled = wavePayEnabled,
|
||||
onNavigateAmount = onNavigateAmount
|
||||
)
|
||||
}
|
||||
@ -29,11 +29,17 @@ import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
||||
fun DashboardScreen(
|
||||
settlementEnabled: Boolean,
|
||||
wavePayEnabled: Boolean,
|
||||
onNavigateAmount: (String) -> Unit
|
||||
onAmountClick: (String) -> Unit,
|
||||
onTransactionClick: () -> Unit,
|
||||
onSettlementClick: () -> Unit,
|
||||
onHistoryClick: () -> Unit,
|
||||
onCardClick: () -> Unit,
|
||||
onWavePayClick: () -> Unit
|
||||
) {
|
||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
|
||||
ModalNavigationDrawer(
|
||||
drawerState = drawerState,
|
||||
drawerContent = {
|
||||
@ -65,6 +71,7 @@ fun DashboardScreen(
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
scope.launch { drawerState.close() }
|
||||
onTransactionClick()
|
||||
}
|
||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||
fontSize = 16.sp
|
||||
@ -75,6 +82,7 @@ fun DashboardScreen(
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
scope.launch { drawerState.close() }
|
||||
onHistoryClick()
|
||||
}
|
||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||
fontSize = 16.sp
|
||||
@ -85,6 +93,7 @@ fun DashboardScreen(
|
||||
.fillMaxWidth()
|
||||
.clickable(enabled = settlementEnabled) {
|
||||
scope.launch { drawerState.close() }
|
||||
onSettlementClick()
|
||||
}
|
||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||
color = if (settlementEnabled) Black else White,
|
||||
@ -96,6 +105,7 @@ fun DashboardScreen(
|
||||
.fillMaxWidth()
|
||||
.clickable(enabled = wavePayEnabled) {
|
||||
scope.launch { drawerState.close() }
|
||||
onWavePayClick()
|
||||
}
|
||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||
color = if (wavePayEnabled) Black else White,
|
||||
@ -166,7 +176,7 @@ fun DashboardScreen(
|
||||
contentColor = Primary,
|
||||
iconTint = Primary,
|
||||
border = null,
|
||||
onClick = { onNavigateAmount("Sale") },
|
||||
onClick = { onAmountClick("Sale") },
|
||||
)
|
||||
SquareButton(
|
||||
title = "Sign On",
|
||||
@ -176,7 +186,7 @@ fun DashboardScreen(
|
||||
contentColor = Primary,
|
||||
iconTint = Primary,
|
||||
border = null,
|
||||
onClick = { onNavigateAmount("Sign On") }
|
||||
onClick = { onAmountClick("Sign On") }
|
||||
)
|
||||
}
|
||||
|
||||
@ -193,7 +203,7 @@ fun DashboardScreen(
|
||||
contentColor = Primary,
|
||||
iconTint = Primary,
|
||||
border = null,
|
||||
onClick = {}
|
||||
onClick = onSettlementClick
|
||||
)
|
||||
SquareButton(
|
||||
title = "Others",
|
||||
@ -203,7 +213,7 @@ fun DashboardScreen(
|
||||
contentColor = Primary,
|
||||
iconTint = Primary,
|
||||
border = null,
|
||||
onClick = {}
|
||||
onClick = onCardClick
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -220,7 +230,12 @@ private fun DashboardScreenPreview() {
|
||||
DashboardScreen(
|
||||
settlementEnabled = true,
|
||||
wavePayEnabled = true,
|
||||
onNavigateAmount = {}
|
||||
onAmountClick = {},
|
||||
onTransactionClick = {},
|
||||
onSettlementClick = {},
|
||||
onHistoryClick = {},
|
||||
onCardClick = {},
|
||||
onWavePayClick = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.mob.utsmyanmar.ui.navigation
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@ -11,10 +10,11 @@ import androidx.navigation.NavType
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.navArgument
|
||||
import com.mob.utsmyanmar.ui.amount.AmountRoute
|
||||
import com.mob.utsmyanmar.model.ProcessCode
|
||||
import com.mob.utsmyanmar.ui.amount.AmountScreen
|
||||
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingScreen
|
||||
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingViewModel
|
||||
import com.mob.utsmyanmar.ui.dashboard.DashboardRoute
|
||||
import com.mob.utsmyanmar.ui.dashboard.DashboardScreen
|
||||
import com.mob.utsmyanmar.ui.pinpad.PinPadRoute
|
||||
import com.mob.utsmyanmar.ui.processing_card.ProcessingCardRoute
|
||||
import com.mob.utsmyanmar.ui.processing_card.ProcessingCardViewModel
|
||||
@ -25,8 +25,8 @@ import com.mob.utsmyanmar.viewmodel.EmvTransactionProcessViewModel
|
||||
import com.mob.utsmyanmar.ui.pinpad.PinPadViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
||||
|
||||
@SuppressLint("ContextCastToActivity")
|
||||
@Composable
|
||||
fun AppNavGraph(
|
||||
navController: NavHostController
|
||||
@ -38,17 +38,17 @@ fun AppNavGraph(
|
||||
startDestination = Routes.Dashboard.route
|
||||
) {
|
||||
composable(Routes.Dashboard.route) {
|
||||
DashboardRoute(
|
||||
onNavigateAmount = { action ->
|
||||
navController.navigate(Routes.Amount.createRoute(action)) {
|
||||
popUpTo(Routes.Dashboard.route) {
|
||||
inclusive = false
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
},
|
||||
DashboardScreen(
|
||||
settlementEnabled = true,
|
||||
wavePayEnabled = true
|
||||
wavePayEnabled = true,
|
||||
onAmountClick = { action ->
|
||||
navController.navigate(Routes.Amount.createRoute(action))
|
||||
},
|
||||
onTransactionClick = {},
|
||||
onSettlementClick = {},
|
||||
onHistoryClick = {},
|
||||
onCardClick = {},
|
||||
onWavePayClick = {}
|
||||
)
|
||||
}
|
||||
|
||||
@ -62,17 +62,20 @@ fun AppNavGraph(
|
||||
) { backStackEntry ->
|
||||
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
|
||||
|
||||
AmountRoute(
|
||||
AmountScreen(
|
||||
action = backStackEntry.arguments?.getString("action").orEmpty(),
|
||||
sharedViewModel = sharedViewModel,
|
||||
onBack = { navController.popBackStack() },
|
||||
onNavigateCardWaiting = {
|
||||
navController.navigate(Routes.CardWaiting.route) {
|
||||
popUpTo(Routes.Amount.route) {
|
||||
inclusive = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
onBackClick = { navController.popBackStack() },
|
||||
onCancelClick = { navController.popBackStack() },
|
||||
onNextClick = { amount ->
|
||||
sharedViewModel.amount.value = amount
|
||||
sharedViewModel.setAmountExist(true)
|
||||
sharedViewModel.setCardDataExist(false)
|
||||
sharedViewModel.setTransMenu(null)
|
||||
sharedViewModel.transactionsType.value = TransactionsType.SALE
|
||||
sharedViewModel.processCode.value =
|
||||
ProcessCode.SALE_PURCHASE + ProcessCode.SMART + ProcessCode.TO_ACCOUNT
|
||||
|
||||
navController.navigate(Routes.CardWaiting.route)
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -91,12 +94,7 @@ fun AppNavGraph(
|
||||
viewModel = cardWaitingViewModel,
|
||||
onManualEntry = {},
|
||||
onProcessingCard = {
|
||||
navController.navigate(Routes.ProcessingCard.route) {
|
||||
popUpTo(Routes.CardWaiting.route) {
|
||||
inclusive = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
navController.navigate(Routes.ProcessingCard.route)
|
||||
},
|
||||
onTimeout = { navController.popBackStack() },
|
||||
onBack = { navController.popBackStack() },
|
||||
@ -130,12 +128,7 @@ fun AppNavGraph(
|
||||
ProcessingCardRoute(
|
||||
viewModel = processingCardViewModel,
|
||||
onNavigatePinPad = {
|
||||
navController.navigate(Routes.PinPad.route) {
|
||||
popUpTo(Routes.ProcessingCard.route) {
|
||||
inclusive = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
navController.navigate(Routes.PinPad.route)
|
||||
},
|
||||
onNavigateInputAmount = { navController.popBackStack(Routes.Amount.route, false) },
|
||||
onNavigateProcessing = {},
|
||||
@ -157,8 +150,8 @@ fun AppNavGraph(
|
||||
transProcessViewModel = transProcessViewModel,
|
||||
onNavigateTransactionResult = {
|
||||
navController.navigate(Routes.TransactionResult.route) {
|
||||
popUpTo(Routes.PinPad.route) {
|
||||
inclusive = true
|
||||
popUpTo(Routes.Dashboard.route) {
|
||||
inclusive = false
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
@ -196,7 +189,6 @@ fun AppNavGraph(
|
||||
|
||||
composable(Routes.PrintReceipt.route) {
|
||||
PrintReceiptScreen(
|
||||
onPrint = {},
|
||||
onDone = {
|
||||
navController.navigate(Routes.Dashboard.route) {
|
||||
popUpTo(Routes.Dashboard.route) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.mob.utsmyanmar.ui.pinpad
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@ -10,7 +9,6 @@ import com.mob.utsmyanmar.model.PinPadStatus
|
||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
||||
import com.utsmyanmar.paylibs.Constant
|
||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
||||
|
||||
@Composable
|
||||
fun PinPadRoute(
|
||||
@ -23,11 +21,6 @@ fun PinPadRoute(
|
||||
val pinText by pinPadViewModel.pinText.collectAsStateWithLifecycle()
|
||||
val alertMsg by pinPadViewModel.alertMsg.collectAsStateWithLifecycle()
|
||||
val pinStatus by pinPadViewModel.pinStatus.collectAsStateWithLifecycle()
|
||||
val canGoBack = sharedViewModel.transactionsType.value != TransactionsType.SALE
|
||||
|
||||
BackHandler(enabled = canGoBack) {
|
||||
onBack()
|
||||
}
|
||||
|
||||
LaunchedEffect(pinStatus) {
|
||||
when (pinStatus) {
|
||||
@ -59,7 +52,6 @@ fun PinPadRoute(
|
||||
PinPadScreen(
|
||||
pinText = pinText,
|
||||
alertMessage = alertMsg,
|
||||
canGoBack = canGoBack,
|
||||
onBack = onBack,
|
||||
onKeyboardReady = { keyboard ->
|
||||
pinPadViewModel.startPinPadProcess(keyboard)
|
||||
|
||||
@ -42,7 +42,6 @@ import com.utsmyanmar.baselib.ui.CustomPinPadKeyboard
|
||||
fun PinPadScreen(
|
||||
pinText: String,
|
||||
alertMessage: String?,
|
||||
canGoBack: Boolean,
|
||||
onBack: () -> Unit,
|
||||
onKeyboardReady: (CustomPinPadKeyboard) -> Unit
|
||||
) {
|
||||
@ -69,7 +68,6 @@ fun PinPadScreen(
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
if (canGoBack) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_left_arrow),
|
||||
@ -77,7 +75,6 @@ fun PinPadScreen(
|
||||
tint = White
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = Primary
|
||||
@ -166,11 +163,7 @@ fun PinPadScreen(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = if (canGoBack) {
|
||||
"Cancel on device or use back to exit."
|
||||
} else {
|
||||
"Cancel on device to exit."
|
||||
},
|
||||
text = "Cancel on device or use back to exit.",
|
||||
color = Black,
|
||||
fontSize = 14.sp,
|
||||
textAlign = TextAlign.Center
|
||||
|
||||
@ -1,236 +1,63 @@
|
||||
package com.mob.utsmyanmar.ui.print_receipt
|
||||
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
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.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
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.theme.Primary
|
||||
import com.mob.utsmyanmar.ui.theme.White
|
||||
import com.utsmyanmar.paylibs.print.NewPrintReceipt
|
||||
|
||||
@Composable
|
||||
fun PrintReceiptScreen(
|
||||
onPrint: () -> Unit,
|
||||
onDone: () -> Unit
|
||||
) {
|
||||
BackHandler {
|
||||
onDone()
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
AppBar(title = "Receipt")
|
||||
AppBar(title = "Print Receipt")
|
||||
}
|
||||
) { paddingValues ->
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(paddingValues)
|
||||
.fillMaxSize()
|
||||
.background(Color(0xFFF5F5F5))
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
|
||||
ReceiptPreview(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.verticalScroll(rememberScrollState())
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
|
||||
OutlinedButton(
|
||||
onClick = onDone,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(50.dp),
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = "Cancel",
|
||||
style = MaterialTheme.typography.bodyLarge.copy(
|
||||
fontSize = 16.sp,
|
||||
text = "Print Receipt",
|
||||
style = MaterialTheme.typography.titleLarge.copy(
|
||||
fontSize = 24.sp,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Button(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(50.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Primary,
|
||||
contentColor = White,
|
||||
disabledContainerColor = Primary,
|
||||
disabledContentColor = White,
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
onClick = {
|
||||
onPrint()
|
||||
try {
|
||||
NewPrintReceipt.getInstance().testPrint()
|
||||
} catch (e: Exception) {
|
||||
Log.d("PrintReceipt", "error with $e")
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = "Print",
|
||||
style = MaterialTheme.typography.bodyLarge.copy(
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ReceiptPreview(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(Color.White)
|
||||
.border(
|
||||
width = 1.dp,
|
||||
color = Color.LightGray,
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
)
|
||||
.padding(20.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
.padding(top = 24.dp),
|
||||
onClick = onDone
|
||||
) {
|
||||
|
||||
Text(
|
||||
text = "MOB POS",
|
||||
fontSize = 24.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontFamily = FontFamily.Monospace
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Transaction Receipt",
|
||||
fontSize = 14.sp,
|
||||
fontFamily = FontFamily.Monospace
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
ReceiptDivider()
|
||||
|
||||
ReceiptRow("Merchant", "MOB UTS Myanmar")
|
||||
ReceiptRow("Terminal ID", "POS001")
|
||||
ReceiptRow("Transaction", "SALE")
|
||||
ReceiptRow("Amount", "500.00 MMK")
|
||||
ReceiptRow("Card Type", "MPU")
|
||||
ReceiptRow("Card No", "1234 **** **** 5678")
|
||||
ReceiptRow("Status", "SUCCESS")
|
||||
ReceiptRow("Date", "13/05/2026")
|
||||
ReceiptRow("Time", "14:30:22")
|
||||
ReceiptRow("Ref No", "REF123456789")
|
||||
|
||||
ReceiptDivider()
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Thank You",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
fontFamily = FontFamily.Monospace
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Text(
|
||||
text = "Please keep this receipt",
|
||||
fontSize = 12.sp,
|
||||
fontFamily = FontFamily.Monospace
|
||||
)
|
||||
Text(text = "Back to Dashboard")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ReceiptRow(
|
||||
label: String,
|
||||
value: String
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 6.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = label,
|
||||
fontSize = 13.sp,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
color = Color.DarkGray
|
||||
)
|
||||
|
||||
Text(
|
||||
text = value,
|
||||
fontSize = 13.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
fontFamily = FontFamily.Monospace
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ReceiptDivider() {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 10.dp),
|
||||
text = "--------------------------------",
|
||||
fontFamily = FontFamily.Monospace,
|
||||
color = Color.Gray
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, showSystemUi = true)
|
||||
@Composable
|
||||
fun PreviewPrintReceiptScreen() {
|
||||
MaterialTheme {
|
||||
PrintReceiptScreen(
|
||||
onPrint = {},
|
||||
onDone = {}
|
||||
)
|
||||
}
|
||||
PrintReceiptScreen { }
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
||||
|
||||
@Composable
|
||||
fun TransactionResultRoute(
|
||||
@ -20,7 +19,6 @@ fun TransactionResultRoute(
|
||||
onShowPrinterDialog: (String) -> Unit
|
||||
) {
|
||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||
val canGoBack = sharedViewModel.transactionsType.value != TransactionsType.SALE
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.onEvent(
|
||||
@ -43,7 +41,6 @@ fun TransactionResultRoute(
|
||||
|
||||
TransactionResultScreen(
|
||||
state = state,
|
||||
canGoBack = canGoBack,
|
||||
onEvent = {
|
||||
viewModel.onEvent(it, sharedViewModel)
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.mob.utsmyanmar.ui.transaction_result
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -47,21 +46,14 @@ import com.mob.utsmyanmar.ui.theme.White
|
||||
@Composable
|
||||
fun TransactionResultScreen(
|
||||
state: TransactionResultState,
|
||||
canGoBack: Boolean,
|
||||
onEvent: (TransactionResultEvent) -> Unit,
|
||||
) {
|
||||
BackHandler(enabled = !canGoBack) {}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
AppBar(
|
||||
title = "Transaction Results",
|
||||
icon = if (canGoBack) Icons.Default.ChevronLeft else null,
|
||||
onIconClick = if (canGoBack) {
|
||||
{ onEvent(TransactionResultEvent.BackClick) }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
icon = Icons.Default.ChevronLeft,
|
||||
onIconClick = { TransactionResultEvent.BackClick }
|
||||
)
|
||||
}
|
||||
) { paddingValues ->
|
||||
@ -262,7 +254,6 @@ fun TransactionResultScreenPreview() {
|
||||
message = "Transaction Approved",
|
||||
isLoading = false
|
||||
),
|
||||
canGoBack = true,
|
||||
onEvent = {}
|
||||
)
|
||||
}
|
||||
|
||||
@ -75,7 +75,6 @@ dependencies {
|
||||
implementation project(path: ':sunmiui-lib')
|
||||
// implementation 'com.sunmi:printerlibrary:1.0.9'
|
||||
implementation 'com.sunmi:printerlibrary:1.0.23'
|
||||
implementation 'com.sunmi:printerx:1.0.17'
|
||||
|
||||
//RxJava
|
||||
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
||||
|
||||
@ -98,7 +98,7 @@ public class BaseApplication extends Application {
|
||||
mPinPadOptV2 = sunmiPayKernel.mPinPadOptV2;
|
||||
mReadCardOptV2 = sunmiPayKernel.mReadCardOptV2;
|
||||
mSecurityOptV2 = sunmiPayKernel.mSecurityOptV2;
|
||||
PayLibsUtils.getInstance().initPrinterX();
|
||||
|
||||
PayLibsUtils.getInstance().initLib(mSecurityOptV2,mEMVOptV2,securityOpt,mReadCardOptV2);
|
||||
SunmiSDK.getInstance().initSDK(mReadCardOptV2,basicOptV2);
|
||||
|
||||
|
||||
@ -66,7 +66,6 @@ dependencies {
|
||||
|
||||
// implementation 'com.sunmi:printerlibrary:1.0.9'
|
||||
implementation 'com.sunmi:printerlibrary:1.0.24'
|
||||
implementation 'com.sunmi:printerx:1.0.17'
|
||||
//paySDK
|
||||
// implementation project(path:':PayLib-release-1.4.58')
|
||||
implementation project(path: ':sunmiui-lib')
|
||||
|
||||
@ -7,12 +7,6 @@ import com.sunmi.pay.hardware.aidlv2.emv.EMVOptV2;
|
||||
import com.sunmi.pay.hardware.aidlv2.readcard.ReadCardOptV2;
|
||||
import com.sunmi.pay.hardware.aidlv2.security.SecurityOptV2;
|
||||
import com.sunmi.peripheral.printer.SunmiPrinterService;
|
||||
import com.sunmi.printerx.PrinterSdk;
|
||||
import com.sunmi.printerx.SdkException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import sunmi.sunmiui.utils.LogUtil;
|
||||
|
||||
public class PayLibsUtils {
|
||||
|
||||
@ -30,8 +24,6 @@ public class PayLibsUtils {
|
||||
|
||||
public ReadCardOptV2 readCardOptV2;
|
||||
|
||||
public PrinterSdk.Printer printer;
|
||||
|
||||
private PayLibsUtils(){}
|
||||
|
||||
public static PayLibsUtils getInstance(){
|
||||
@ -57,21 +49,8 @@ public class PayLibsUtils {
|
||||
this.readCardOptV2 = readCardOptV2;
|
||||
}
|
||||
|
||||
public void initPrinterX() throws SdkException {
|
||||
PrinterSdk.getInstance().getPrinter(
|
||||
context,
|
||||
new PrinterSdk.PrinterListen() {
|
||||
@Override
|
||||
public void onDefPrinter(PrinterSdk.Printer defPrinter) {
|
||||
LogUtil.d("PayLibsUtils", "init printer : " + defPrinter);
|
||||
printer = defPrinter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrinters(List<PrinterSdk.Printer> list) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
package com.utsmyanmar.paylibs.print;
|
||||
|
||||
import com.sunmi.printerx.PrinterSdk;
|
||||
import com.sunmi.printerx.SdkException;
|
||||
import com.sunmi.printerx.style.TextStyle;
|
||||
|
||||
public class NewPrintReceipt {
|
||||
|
||||
private static NewPrintReceipt instance;
|
||||
|
||||
private PrinterSdk.Printer printer;
|
||||
|
||||
private NewPrintReceipt() {}
|
||||
|
||||
public static synchronized NewPrintReceipt getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new NewPrintReceipt();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void setPrinter(PrinterSdk.Printer printer) {
|
||||
this.printer = printer;
|
||||
}
|
||||
|
||||
public void testPrint() throws SdkException {
|
||||
|
||||
if (printer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
printer.lineApi().addText("testing", TextStyle.getStyle());
|
||||
printer.lineApi().autoOut();
|
||||
}
|
||||
}
|
||||
@ -77,8 +77,6 @@ public class PrintReceipt {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void clearQueue() throws RemoteException {
|
||||
sunmiPrinterService.clearBuffer();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user