diff --git a/app/changelog.md b/app/changelog.md index a2b62c5..240a07e 100644 --- a/app/changelog.md +++ b/app/changelog.md @@ -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 \ No newline at end of file +* Amount and Card Number show in signature pad +* fixed recent transaction only working for top 3 +* routed to dashboard after printing receipt \ No newline at end of file diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt b/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt index 5c4f397..f73409e 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt @@ -801,6 +801,14 @@ fun AppNavGraph( } launchSingleTop = true } + }, + onPrintFinished = { + navController.navigate(Routes.Dashboard.route) { + popUpTo(Routes.Dashboard.route) { + inclusive = false + } + launchSingleTop = true + } } ) } diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/print_receipt/PrintReceiptScreen.kt b/app/src/main/java/com/mob/utsmyanmar/ui/print_receipt/PrintReceiptScreen.kt index 723bbfb..d79f5ec 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/print_receipt/PrintReceiptScreen.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/print_receipt/PrintReceiptScreen.kt @@ -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 = {} ) } } \ No newline at end of file