refactor routes
This commit is contained in:
parent
44c0fa20af
commit
35600bda29
@ -0,0 +1,31 @@
|
|||||||
|
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
|
||||||
|
) {
|
||||||
|
AmountScreen(
|
||||||
|
action = action,
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
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,17 +29,11 @@ import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
|||||||
fun DashboardScreen(
|
fun DashboardScreen(
|
||||||
settlementEnabled: Boolean,
|
settlementEnabled: Boolean,
|
||||||
wavePayEnabled: Boolean,
|
wavePayEnabled: Boolean,
|
||||||
onAmountClick: (String) -> Unit,
|
onNavigateAmount: (String) -> Unit
|
||||||
onTransactionClick: () -> Unit,
|
|
||||||
onSettlementClick: () -> Unit,
|
|
||||||
onHistoryClick: () -> Unit,
|
|
||||||
onCardClick: () -> Unit,
|
|
||||||
onWavePayClick: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
|
||||||
ModalNavigationDrawer(
|
ModalNavigationDrawer(
|
||||||
drawerState = drawerState,
|
drawerState = drawerState,
|
||||||
drawerContent = {
|
drawerContent = {
|
||||||
@ -71,7 +65,6 @@ fun DashboardScreen(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable {
|
.clickable {
|
||||||
scope.launch { drawerState.close() }
|
scope.launch { drawerState.close() }
|
||||||
onTransactionClick()
|
|
||||||
}
|
}
|
||||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||||
fontSize = 16.sp
|
fontSize = 16.sp
|
||||||
@ -82,7 +75,6 @@ fun DashboardScreen(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable {
|
.clickable {
|
||||||
scope.launch { drawerState.close() }
|
scope.launch { drawerState.close() }
|
||||||
onHistoryClick()
|
|
||||||
}
|
}
|
||||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||||
fontSize = 16.sp
|
fontSize = 16.sp
|
||||||
@ -93,7 +85,6 @@ fun DashboardScreen(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable(enabled = settlementEnabled) {
|
.clickable(enabled = settlementEnabled) {
|
||||||
scope.launch { drawerState.close() }
|
scope.launch { drawerState.close() }
|
||||||
onSettlementClick()
|
|
||||||
}
|
}
|
||||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||||
color = if (settlementEnabled) Black else White,
|
color = if (settlementEnabled) Black else White,
|
||||||
@ -105,7 +96,6 @@ fun DashboardScreen(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable(enabled = wavePayEnabled) {
|
.clickable(enabled = wavePayEnabled) {
|
||||||
scope.launch { drawerState.close() }
|
scope.launch { drawerState.close() }
|
||||||
onWavePayClick()
|
|
||||||
}
|
}
|
||||||
.padding(horizontal = 24.dp, vertical = 14.dp),
|
.padding(horizontal = 24.dp, vertical = 14.dp),
|
||||||
color = if (wavePayEnabled) Black else White,
|
color = if (wavePayEnabled) Black else White,
|
||||||
@ -176,7 +166,7 @@ fun DashboardScreen(
|
|||||||
contentColor = Primary,
|
contentColor = Primary,
|
||||||
iconTint = Primary,
|
iconTint = Primary,
|
||||||
border = null,
|
border = null,
|
||||||
onClick = { onAmountClick("Sale") },
|
onClick = { onNavigateAmount("Sale") },
|
||||||
)
|
)
|
||||||
SquareButton(
|
SquareButton(
|
||||||
title = "Sign On",
|
title = "Sign On",
|
||||||
@ -186,7 +176,7 @@ fun DashboardScreen(
|
|||||||
contentColor = Primary,
|
contentColor = Primary,
|
||||||
iconTint = Primary,
|
iconTint = Primary,
|
||||||
border = null,
|
border = null,
|
||||||
onClick = { onAmountClick("Sign On") }
|
onClick = { onNavigateAmount("Sign On") }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +193,7 @@ fun DashboardScreen(
|
|||||||
contentColor = Primary,
|
contentColor = Primary,
|
||||||
iconTint = Primary,
|
iconTint = Primary,
|
||||||
border = null,
|
border = null,
|
||||||
onClick = onSettlementClick
|
onClick = {}
|
||||||
)
|
)
|
||||||
SquareButton(
|
SquareButton(
|
||||||
title = "Others",
|
title = "Others",
|
||||||
@ -213,7 +203,7 @@ fun DashboardScreen(
|
|||||||
contentColor = Primary,
|
contentColor = Primary,
|
||||||
iconTint = Primary,
|
iconTint = Primary,
|
||||||
border = null,
|
border = null,
|
||||||
onClick = onCardClick
|
onClick = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,12 +220,7 @@ private fun DashboardScreenPreview() {
|
|||||||
DashboardScreen(
|
DashboardScreen(
|
||||||
settlementEnabled = true,
|
settlementEnabled = true,
|
||||||
wavePayEnabled = true,
|
wavePayEnabled = true,
|
||||||
onAmountClick = {},
|
onNavigateAmount = {}
|
||||||
onTransactionClick = {},
|
|
||||||
onSettlementClick = {},
|
|
||||||
onHistoryClick = {},
|
|
||||||
onCardClick = {},
|
|
||||||
onWavePayClick = {}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.mob.utsmyanmar.ui.navigation
|
package com.mob.utsmyanmar.ui.navigation
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@ -10,11 +11,10 @@ import androidx.navigation.NavType
|
|||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.navArgument
|
import androidx.navigation.navArgument
|
||||||
import com.mob.utsmyanmar.model.ProcessCode
|
import com.mob.utsmyanmar.ui.amount.AmountRoute
|
||||||
import com.mob.utsmyanmar.ui.amount.AmountScreen
|
|
||||||
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingScreen
|
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingScreen
|
||||||
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingViewModel
|
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingViewModel
|
||||||
import com.mob.utsmyanmar.ui.dashboard.DashboardScreen
|
import com.mob.utsmyanmar.ui.dashboard.DashboardRoute
|
||||||
import com.mob.utsmyanmar.ui.pinpad.PinPadRoute
|
import com.mob.utsmyanmar.ui.pinpad.PinPadRoute
|
||||||
import com.mob.utsmyanmar.ui.processing_card.ProcessingCardRoute
|
import com.mob.utsmyanmar.ui.processing_card.ProcessingCardRoute
|
||||||
import com.mob.utsmyanmar.ui.processing_card.ProcessingCardViewModel
|
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.ui.pinpad.PinPadViewModel
|
||||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||||
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
||||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
|
||||||
|
|
||||||
|
@SuppressLint("ContextCastToActivity")
|
||||||
@Composable
|
@Composable
|
||||||
fun AppNavGraph(
|
fun AppNavGraph(
|
||||||
navController: NavHostController
|
navController: NavHostController
|
||||||
@ -38,17 +38,12 @@ fun AppNavGraph(
|
|||||||
startDestination = Routes.Dashboard.route
|
startDestination = Routes.Dashboard.route
|
||||||
) {
|
) {
|
||||||
composable(Routes.Dashboard.route) {
|
composable(Routes.Dashboard.route) {
|
||||||
DashboardScreen(
|
DashboardRoute(
|
||||||
settlementEnabled = true,
|
onNavigateAmount = { action ->
|
||||||
wavePayEnabled = true,
|
|
||||||
onAmountClick = { action ->
|
|
||||||
navController.navigate(Routes.Amount.createRoute(action))
|
navController.navigate(Routes.Amount.createRoute(action))
|
||||||
},
|
},
|
||||||
onTransactionClick = {},
|
settlementEnabled = true,
|
||||||
onSettlementClick = {},
|
wavePayEnabled = true
|
||||||
onHistoryClick = {},
|
|
||||||
onCardClick = {},
|
|
||||||
onWavePayClick = {}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,21 +57,11 @@ fun AppNavGraph(
|
|||||||
) { backStackEntry ->
|
) { backStackEntry ->
|
||||||
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
|
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
|
||||||
|
|
||||||
AmountScreen(
|
AmountRoute(
|
||||||
action = backStackEntry.arguments?.getString("action").orEmpty(),
|
action = backStackEntry.arguments?.getString("action").orEmpty(),
|
||||||
onBackClick = { navController.popBackStack() },
|
sharedViewModel = sharedViewModel,
|
||||||
onCancelClick = { navController.popBackStack() },
|
onBack = { navController.popBackStack() },
|
||||||
onNextClick = { amount ->
|
onNavigateCardWaiting = { navController.navigate(Routes.CardWaiting.route) }
|
||||||
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)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +174,7 @@ fun AppNavGraph(
|
|||||||
|
|
||||||
composable(Routes.PrintReceipt.route) {
|
composable(Routes.PrintReceipt.route) {
|
||||||
PrintReceiptScreen(
|
PrintReceiptScreen(
|
||||||
|
onPrint = {},
|
||||||
onDone = {
|
onDone = {
|
||||||
navController.navigate(Routes.Dashboard.route) {
|
navController.navigate(Routes.Dashboard.route) {
|
||||||
popUpTo(Routes.Dashboard.route) {
|
popUpTo(Routes.Dashboard.route) {
|
||||||
|
|||||||
@ -1,63 +1,230 @@
|
|||||||
package com.mob.utsmyanmar.ui.print_receipt
|
package com.mob.utsmyanmar.ui.print_receipt
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import android.util.Log
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonColors
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
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.text.font.FontWeight
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
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
|
||||||
|
import com.utsmyanmar.paylibs.print.PrintReceipt
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PrintReceiptScreen(
|
fun PrintReceiptScreen(
|
||||||
|
onPrint: () -> Unit,
|
||||||
onDone: () -> Unit
|
onDone: () -> Unit
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
AppBar(title = "Print Receipt")
|
AppBar(title = "Receipt")
|
||||||
}
|
}
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
.background(Color(0xFFF5F5F5))
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
verticalArrangement = Arrangement.Center,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
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 = {},
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.height(50.dp),
|
||||||
|
shape = RoundedCornerShape(12.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Print Receipt",
|
text = "Cancel",
|
||||||
style = MaterialTheme.typography.titleLarge.copy(
|
style = MaterialTheme.typography.bodyLarge.copy(
|
||||||
fontSize = 24.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = FontWeight.SemiBold
|
fontWeight = FontWeight.SemiBold
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.weight(1f)
|
||||||
.padding(top = 24.dp),
|
.height(50.dp),
|
||||||
onClick = onDone
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = Primary,
|
||||||
|
contentColor = White,
|
||||||
|
disabledContainerColor = Primary,
|
||||||
|
disabledContentColor = White,
|
||||||
|
),
|
||||||
|
shape = RoundedCornerShape(12.dp),
|
||||||
|
onClick = { try {
|
||||||
|
NewPrintReceipt.getInstance().testPrint()
|
||||||
|
}catch (e: Exception){
|
||||||
|
Log.d("PrintReceipt", "error with $e")
|
||||||
|
} }
|
||||||
) {
|
) {
|
||||||
Text(text = "Back to Dashboard")
|
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
|
||||||
|
) {
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
@Preview(showBackground = true, showSystemUi = true)
|
||||||
@Composable
|
@Composable
|
||||||
fun PreviewPrintReceiptScreen() {
|
fun PreviewPrintReceiptScreen() {
|
||||||
PrintReceiptScreen { }
|
MaterialTheme {
|
||||||
|
PrintReceiptScreen(
|
||||||
|
onPrint = {},
|
||||||
|
onDone = {}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -75,6 +75,7 @@ dependencies {
|
|||||||
implementation project(path: ':sunmiui-lib')
|
implementation project(path: ':sunmiui-lib')
|
||||||
// implementation 'com.sunmi:printerlibrary:1.0.9'
|
// implementation 'com.sunmi:printerlibrary:1.0.9'
|
||||||
implementation 'com.sunmi:printerlibrary:1.0.23'
|
implementation 'com.sunmi:printerlibrary:1.0.23'
|
||||||
|
implementation 'com.sunmi:printerx:1.0.17'
|
||||||
|
|
||||||
//RxJava
|
//RxJava
|
||||||
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class BaseApplication extends Application {
|
|||||||
mPinPadOptV2 = sunmiPayKernel.mPinPadOptV2;
|
mPinPadOptV2 = sunmiPayKernel.mPinPadOptV2;
|
||||||
mReadCardOptV2 = sunmiPayKernel.mReadCardOptV2;
|
mReadCardOptV2 = sunmiPayKernel.mReadCardOptV2;
|
||||||
mSecurityOptV2 = sunmiPayKernel.mSecurityOptV2;
|
mSecurityOptV2 = sunmiPayKernel.mSecurityOptV2;
|
||||||
|
PayLibsUtils.getInstance().initPrinterX();
|
||||||
PayLibsUtils.getInstance().initLib(mSecurityOptV2,mEMVOptV2,securityOpt,mReadCardOptV2);
|
PayLibsUtils.getInstance().initLib(mSecurityOptV2,mEMVOptV2,securityOpt,mReadCardOptV2);
|
||||||
SunmiSDK.getInstance().initSDK(mReadCardOptV2,basicOptV2);
|
SunmiSDK.getInstance().initSDK(mReadCardOptV2,basicOptV2);
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ dependencies {
|
|||||||
|
|
||||||
// implementation 'com.sunmi:printerlibrary:1.0.9'
|
// implementation 'com.sunmi:printerlibrary:1.0.9'
|
||||||
implementation 'com.sunmi:printerlibrary:1.0.24'
|
implementation 'com.sunmi:printerlibrary:1.0.24'
|
||||||
|
implementation 'com.sunmi:printerx:1.0.17'
|
||||||
//paySDK
|
//paySDK
|
||||||
// implementation project(path:':PayLib-release-1.4.58')
|
// implementation project(path:':PayLib-release-1.4.58')
|
||||||
implementation project(path: ':sunmiui-lib')
|
implementation project(path: ':sunmiui-lib')
|
||||||
|
|||||||
@ -7,6 +7,12 @@ import com.sunmi.pay.hardware.aidlv2.emv.EMVOptV2;
|
|||||||
import com.sunmi.pay.hardware.aidlv2.readcard.ReadCardOptV2;
|
import com.sunmi.pay.hardware.aidlv2.readcard.ReadCardOptV2;
|
||||||
import com.sunmi.pay.hardware.aidlv2.security.SecurityOptV2;
|
import com.sunmi.pay.hardware.aidlv2.security.SecurityOptV2;
|
||||||
import com.sunmi.peripheral.printer.SunmiPrinterService;
|
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 {
|
public class PayLibsUtils {
|
||||||
|
|
||||||
@ -24,6 +30,8 @@ public class PayLibsUtils {
|
|||||||
|
|
||||||
public ReadCardOptV2 readCardOptV2;
|
public ReadCardOptV2 readCardOptV2;
|
||||||
|
|
||||||
|
public PrinterSdk.Printer printer;
|
||||||
|
|
||||||
private PayLibsUtils(){}
|
private PayLibsUtils(){}
|
||||||
|
|
||||||
public static PayLibsUtils getInstance(){
|
public static PayLibsUtils getInstance(){
|
||||||
@ -49,8 +57,21 @@ public class PayLibsUtils {
|
|||||||
this.readCardOptV2 = readCardOptV2;
|
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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
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,6 +77,8 @@ public class PrintReceipt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void clearQueue() throws RemoteException {
|
public void clearQueue() throws RemoteException {
|
||||||
sunmiPrinterService.clearBuffer();
|
sunmiPrinterService.clearBuffer();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user