auto route to dashboard after print finished in sale
This commit is contained in:
parent
b2e8e13a81
commit
beb6ddcba8
@ -4,4 +4,6 @@
|
||||
* config auto update after transaction
|
||||
* signature removed on void
|
||||
* "Enter Password" color to LegacyRed
|
||||
* Amount and Card Number show in signature pad
|
||||
* Amount and Card Number show in signature pad
|
||||
* fixed recent transaction only working for top 3
|
||||
* routed to dashboard after printing receipt
|
||||
@ -801,6 +801,14 @@ fun AppNavGraph(
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
},
|
||||
onPrintFinished = {
|
||||
navController.navigate(Routes.Dashboard.route) {
|
||||
popUpTo(Routes.Dashboard.route) {
|
||||
inclusive = false
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@ -58,12 +58,12 @@ fun PrintReceiptScreen(
|
||||
transactionResultViewModel: TransactionResultViewModel,
|
||||
sharedViewModel: SharedViewModel,
|
||||
onPrint: () -> Unit,
|
||||
onDone: () -> Unit
|
||||
onDone: () -> Unit,
|
||||
onPrintFinished : () -> Unit,
|
||||
) {
|
||||
val state by transactionResultViewModel.state.collectAsStateWithLifecycle()
|
||||
val scope = rememberCoroutineScope()
|
||||
val receiptOffsetY = remember { Animatable(0f) }
|
||||
val animationDuration = 5000
|
||||
val merchant_copy_autoprint = true
|
||||
val customer_copy_autoprint = false
|
||||
var currentCopy by remember { mutableStateOf(ReceiptCopy.MERCHANT) }
|
||||
@ -73,7 +73,7 @@ fun PrintReceiptScreen(
|
||||
suspend fun animatePrint() {
|
||||
receiptOffsetY.animateTo(
|
||||
targetValue = -1500f,
|
||||
animationSpec = tween(durationMillis = animationDuration, easing = FastOutSlowInEasing)
|
||||
animationSpec = tween(durationMillis = 5000, easing = FastOutSlowInEasing)
|
||||
)
|
||||
delay(1000.milliseconds)
|
||||
receiptOffsetY.animateTo(
|
||||
@ -84,21 +84,30 @@ fun PrintReceiptScreen(
|
||||
|
||||
fun isReprintMode() = sharedViewModel.isReprint.value == true
|
||||
|
||||
fun doPrint(copy: ReceiptCopy, onFinished: () -> Unit) {
|
||||
fun doPrint(copy: ReceiptCopy, onFinished: (printFinished: ReceiptCopy) -> Unit) {
|
||||
val reprint = isReprintMode()
|
||||
val actualCopy = if (reprint && copy == ReceiptCopy.MERCHANT) ReceiptCopy.CUSTOMER else copy
|
||||
currentCopy = actualCopy
|
||||
|
||||
sharedViewModel.setPrintStatus(
|
||||
if (actualCopy == ReceiptCopy.MERCHANT) PrintStatus.FIRST_PRINT else PrintStatus.SECOND_PRINT
|
||||
if (actualCopy == ReceiptCopy.MERCHANT)
|
||||
PrintStatus.FIRST_PRINT
|
||||
else
|
||||
PrintStatus.SECOND_PRINT
|
||||
)
|
||||
onPrint()
|
||||
scope.launch {
|
||||
isPrinting = true
|
||||
animatePrint()
|
||||
isPrinting = false
|
||||
nextCopy = if (reprint) ReceiptCopy.CUSTOMER
|
||||
else if (actualCopy == ReceiptCopy.MERCHANT) ReceiptCopy.CUSTOMER else ReceiptCopy.MERCHANT
|
||||
onFinished()
|
||||
val upcomingCopy = if (reprint) ReceiptCopy.CUSTOMER
|
||||
else if (actualCopy == ReceiptCopy.MERCHANT) ReceiptCopy.CUSTOMER
|
||||
else ReceiptCopy.MERCHANT
|
||||
|
||||
currentCopy = upcomingCopy
|
||||
nextCopy = upcomingCopy
|
||||
|
||||
onFinished(actualCopy)
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +183,12 @@ fun PrintReceiptScreen(
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
onClick = {
|
||||
doPrint(nextCopy) { }
|
||||
doPrint(nextCopy) { printFinished ->
|
||||
if (printFinished == ReceiptCopy.CUSTOMER) {
|
||||
onPrintFinished()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
@ -295,7 +309,8 @@ fun PreviewPrintReceiptScreen() {
|
||||
sharedViewModel = hiltViewModel(),
|
||||
transactionResultViewModel = hiltViewModel(),
|
||||
onPrint = {},
|
||||
onDone = {}
|
||||
onDone = {},
|
||||
onPrintFinished = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user