Compare commits
No commits in common. "38bc26d821fa39fc9a8da79f5b65e14da2365ba5" and "48add553800290333a827d793041118790e3fe93" have entirely different histories.
38bc26d821
...
48add55380
@ -18,7 +18,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.mob.utsmyanmar"
|
||||
minSdk = 25
|
||||
minSdk = 23
|
||||
//noinspection OldTargetApi
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
@ -43,8 +43,8 @@ android {
|
||||
dimension = "env"
|
||||
applicationIdSuffix = ".uat"
|
||||
versionNameSuffix = "-UAT"
|
||||
versionCode = 11
|
||||
versionName = "2.9"
|
||||
versionCode = 10
|
||||
versionName = "2.8"
|
||||
buildConfigField("String", "ENV", "\"UAT\"")
|
||||
resValue("string", "app_name", "MOB-UAT")
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.mob.utsmyanmar.ui.cardwaiting
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@ -39,9 +38,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.res.painterResource
|
||||
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
|
||||
@ -137,33 +134,33 @@ private fun CardWaitingScreenContent(
|
||||
Text(
|
||||
text = "AMOUNT TO PAY",
|
||||
color = Color.Black,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
style = MaterialTheme.typography.labelSmall
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
|
||||
// Row(verticalAlignment = Alignment.Bottom) {
|
||||
Text(
|
||||
text = amount,
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.displayLarge
|
||||
)
|
||||
Row(verticalAlignment = Alignment.Bottom) {
|
||||
Text(
|
||||
text = amount,
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.displayMedium
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
|
||||
Text(
|
||||
text = "MMK",
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.displaySmall.copy(fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.padding(bottom = 6.dp)
|
||||
)
|
||||
// }
|
||||
Text(
|
||||
text = "MMK",
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
modifier = Modifier.padding(bottom = 6.dp)
|
||||
)
|
||||
}
|
||||
|
||||
// Spacer(modifier = Modifier.height(32.dp))
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
|
||||
ContactlessCircle(isLoading = uiState.isLoading)
|
||||
|
||||
// Spacer(modifier = Modifier.height(24.dp))
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
Text(
|
||||
text = when {
|
||||
@ -209,9 +206,12 @@ private fun CardWaitingScreenContent(
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
InsertCardRow(onMockClick = onMockClick)
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
|
||||
Spacer(modifier = Modifier.height(18.dp))
|
||||
|
||||
Text(
|
||||
text = uiState.alertMessage,
|
||||
color = Color.Black,
|
||||
@ -219,13 +219,23 @@ private fun CardWaitingScreenContent(
|
||||
textAlign = TextAlign.Center,
|
||||
lineHeight = 16.sp
|
||||
)
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
|
||||
Spacer(modifier = Modifier.height(18.dp))
|
||||
|
||||
// StatusPanel(uiState = uiState)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
ManualEntryAction(onManualEntryClick = onManualEntryClick)
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
|
||||
Spacer(modifier = Modifier.height(18.dp))
|
||||
|
||||
CardLogoRow()
|
||||
|
||||
Spacer(modifier = Modifier.height(34.dp))
|
||||
|
||||
PoweredByMob()
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
}
|
||||
}
|
||||
@ -282,7 +292,7 @@ private fun CircleBorder(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InsertCardRow(onMockClick: () -> Unit) {
|
||||
private fun InsertCardRow(onMockClick: ()->Unit) {
|
||||
Row(
|
||||
modifier = Modifier.height(44.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
@ -291,8 +301,7 @@ private fun InsertCardRow(onMockClick: () -> Unit) {
|
||||
painter = painterResource(id = R.drawable.ic_insert_card),
|
||||
contentDescription = null,
|
||||
tint = Color.LegacyRed,
|
||||
modifier = Modifier
|
||||
.size(28.dp)
|
||||
modifier = Modifier.size(28.dp)
|
||||
.clickable(onClick = onMockClick)
|
||||
)
|
||||
|
||||
@ -386,49 +395,13 @@ private fun CardLogoRow() {
|
||||
.fillMaxWidth()
|
||||
.height(42.dp)
|
||||
.padding(horizontal = 14.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
CardLogo(
|
||||
icon = painterResource(R.drawable.logo_visa),
|
||||
name = "visa",
|
||||
)
|
||||
CardLogo(
|
||||
icon = painterResource(R.drawable.logo_master),
|
||||
name = "master",
|
||||
)
|
||||
CardLogo(
|
||||
icon = painterResource(R.drawable.logo_mpu),
|
||||
name = "master",
|
||||
)
|
||||
CardLogo(
|
||||
icon = painterResource(R.drawable.logo_union_pay),
|
||||
name = "master",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CardLogo(
|
||||
icon: Painter,
|
||||
name: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Surface(
|
||||
modifier = modifier,
|
||||
shape = RoundedCornerShape(4.dp),
|
||||
color = Color.White
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = icon,
|
||||
contentDescription = name,
|
||||
modifier = Modifier.height(30.dp)
|
||||
)
|
||||
Text("VISA", style = MaterialTheme.typography.titleLarge)
|
||||
Text("MC", style = MaterialTheme.typography.titleMedium)
|
||||
Text("MPU", style = MaterialTheme.typography.titleLarge)
|
||||
Text("UnionPay", style = MaterialTheme.typography.labelMedium)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +104,7 @@ fun SummaryCard(
|
||||
onClickLastSync: () -> Unit,
|
||||
lastSyncTime: Long?,
|
||||
totalSaleCount: Int,
|
||||
totalSaleAmount: Long,
|
||||
settlementStatusText: String,
|
||||
settlementDateTimeText: String
|
||||
totalSaleAmount: Long
|
||||
) {
|
||||
var now by remember { mutableLongStateOf(System.currentTimeMillis()) }
|
||||
LaunchedEffect(Unit) {
|
||||
@ -147,8 +145,8 @@ fun SummaryCard(
|
||||
|
||||
SummaryItem(
|
||||
title = "Settlement",
|
||||
value = settlementStatusText,
|
||||
subtitle = settlementDateTimeText,
|
||||
value = "Completed",
|
||||
subtitle = "Today 11:00 PM",
|
||||
icon = Icons.Default.Check,
|
||||
iconBg = Color.CrimsonRed
|
||||
)
|
||||
|
||||
@ -394,9 +394,7 @@ fun DashboardScreen2(
|
||||
onClickLastSync = onClickLastSync,
|
||||
lastSyncTime = dashboardUiState.lastSyncTime,
|
||||
totalSaleCount = dashboardUiState.totalSaleCount,
|
||||
totalSaleAmount = dashboardUiState.totalSaleAmount,
|
||||
settlementStatusText = dashboardUiState.settlementStatusText,
|
||||
settlementDateTimeText = dashboardUiState.settlementDateTimeText
|
||||
totalSaleAmount = dashboardUiState.totalSaleAmount
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
}
|
||||
|
||||
@ -15,7 +15,5 @@ data class DashboardUiState(
|
||||
val lastSyncTime: Long? = null,
|
||||
val carouselUrls: List<String> = emptyList(),
|
||||
val totalSaleCount: Int = 0,
|
||||
val totalSaleAmount: Long = 0L,
|
||||
val settlementStatusText: String = "Pending",
|
||||
val settlementDateTimeText: String = "--/-- --:--"
|
||||
val totalSaleAmount: Long = 0L
|
||||
)
|
||||
|
||||
@ -6,7 +6,6 @@ import androidx.lifecycle.asFlow
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.utsmyanmar.baselib.repo.Repository
|
||||
import com.utsmyanmar.paylibs.model.PayDetail
|
||||
import com.utsmyanmar.paylibs.system.SystemDateTime
|
||||
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
|
||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
@ -18,7 +17,6 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import java.math.BigDecimal
|
||||
import java.text.DecimalFormat
|
||||
import java.util.Calendar
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@ -33,23 +31,11 @@ class DashboardViewModel @Inject constructor(
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
repository.getLastTenTransactions().asFlow().collect { payDetails ->
|
||||
val latestSettlement = payDetails.lastOrNull {
|
||||
it.transactionType == TransactionsType.SETTLEMENT.value
|
||||
}
|
||||
val isCurrentBusinessSettlement = latestSettlement?.isCurrentBusinessSettlement() == true
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
recentTransactions = payDetails.map { pd -> pd.toRecord() },
|
||||
totalSaleCount = payDetails.totalSaleCount(),
|
||||
totalSaleAmount = payDetails.totalSaleAmount(),
|
||||
settlementStatusText = if (isCurrentBusinessSettlement) {
|
||||
"Completed"
|
||||
} else {
|
||||
"Pending"
|
||||
},
|
||||
settlementDateTimeText = latestSettlement
|
||||
?.let { buildDateTime(it.TradeDate, it.TradeTime) }
|
||||
?: "--/-- --:--"
|
||||
totalSaleAmount = payDetails.totalSaleAmount()
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -126,18 +112,3 @@ private fun buildDateTime(date: String?, time: String?): String {
|
||||
val t = (time ?: "").padStart(6, '0')
|
||||
return "${d.take(2)}/${d.drop(2).take(2)} ${t.take(2)}:${t.drop(2).take(2)}"
|
||||
}
|
||||
|
||||
private fun PayDetail.isCurrentBusinessSettlement(): Boolean {
|
||||
if (transactionType != TransactionsType.SETTLEMENT.value) return false
|
||||
if (TradeDate != SystemDateTime.getMMDD()) return false
|
||||
|
||||
val now = Calendar.getInstance()
|
||||
val cutoff = Calendar.getInstance().apply {
|
||||
set(Calendar.HOUR_OF_DAY, 23)
|
||||
set(Calendar.MINUTE, 0)
|
||||
set(Calendar.SECOND, 0)
|
||||
set(Calendar.MILLISECOND, 0)
|
||||
}
|
||||
|
||||
return now.before(cutoff)
|
||||
}
|
||||
|
||||
@ -49,23 +49,17 @@ fun InputAmount(
|
||||
title: String = "Amount",
|
||||
onBackClick: () -> Unit = {},
|
||||
onChargeClick: (String) -> Unit = {}
|
||||
) {
|
||||
){
|
||||
|
||||
var amount by remember { mutableStateOf("") }
|
||||
val prefixLabel = "MMK"
|
||||
val supportingText = "Enter the amount to continue"
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
AppBar(
|
||||
title = "Amount",
|
||||
icon = Icons.AutoMirrored.Rounded.ArrowBack,
|
||||
onIconClick = onBackClick
|
||||
)
|
||||
},
|
||||
topBar = { AppBar(title = "Amount", icon = Icons.AutoMirrored.Rounded.ArrowBack, onIconClick = onBackClick) },
|
||||
containerColor = Color.IvoryBeige
|
||||
) { paddingValues ->
|
||||
|
||||
) {paddingValues ->
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(paddingValues)
|
||||
@ -78,10 +72,9 @@ fun InputAmount(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.weight(2f),
|
||||
) {
|
||||
){
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
modifier = Modifier.align(Alignment.CenterEnd)
|
||||
.clickable(enabled = true) {
|
||||
amount = amount.dropLast(1)
|
||||
},
|
||||
@ -109,28 +102,26 @@ fun InputAmount(
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Row(
|
||||
// modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
// verticalAlignment = Alignment.Bottom
|
||||
// ) {
|
||||
Text(
|
||||
text = formatAmount(amount.ifEmpty { "0" }),
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.displayLarge
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
if (prefixLabel.isNotBlank()) {
|
||||
Text(
|
||||
text = prefixLabel,
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
|
||||
)
|
||||
}
|
||||
|
||||
if (prefixLabel.isNotBlank()) {
|
||||
Text(
|
||||
text = prefixLabel,
|
||||
text = formatAmount(amount.ifEmpty { "0" }),
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.displaySmall.copy(fontWeight = FontWeight.Medium),
|
||||
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
|
||||
style = MaterialTheme.typography.displayLarge
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
|
||||
Spacer(modifier = Modifier.height(14.dp))
|
||||
|
||||
Text(
|
||||
@ -141,14 +132,14 @@ fun InputAmount(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//second container
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(3f),
|
||||
verticalArrangement = Arrangement.Bottom
|
||||
) {
|
||||
){
|
||||
NumericKeypad(
|
||||
keys = amountKeys,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
@ -157,14 +148,14 @@ fun InputAmount(
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
//third container
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(0.5f)
|
||||
) {
|
||||
){
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
@ -187,8 +178,7 @@ fun InputAmount(
|
||||
onClick = {
|
||||
if (amount.isNotEmpty()) {
|
||||
onChargeClick(amount)
|
||||
}
|
||||
},
|
||||
} },
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(56.dp),
|
||||
@ -201,14 +191,14 @@ fun InputAmount(
|
||||
disabledContentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
text = "Next",
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Text(
|
||||
text = "Next",
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,6 +250,6 @@ private fun formatAmount(value: String): String {
|
||||
@P2Preview
|
||||
@P3Preview
|
||||
@Composable
|
||||
fun PreviewInputAmount() {
|
||||
fun PreviewInputAmount(){
|
||||
InputAmount();
|
||||
}
|
||||
@ -1,18 +1,13 @@
|
||||
package com.mob.utsmyanmar.ui.print_receipt
|
||||
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
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.padding
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
@ -25,10 +20,8 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@ -39,19 +32,15 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
||||
import com.mob.utsmyanmar.ui.theme.Color
|
||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultEvent
|
||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultState
|
||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||
import com.utsmyanmar.paylibs.print.PrintReceipt
|
||||
import com.utsmyanmar.paylibs.utils.POSUtil
|
||||
import com.utsmyanmar.paylibs.utils.PrintStatus
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
private enum class ReceiptCopy(val label: String) {
|
||||
MERCHANT("MERCHANT COPY"),
|
||||
CUSTOMER("CUSTOMER COPY")
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PrintReceiptScreen(
|
||||
@ -61,59 +50,12 @@ fun PrintReceiptScreen(
|
||||
onDone: () -> 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) }
|
||||
var nextCopy by remember { mutableStateOf(ReceiptCopy.CUSTOMER) }
|
||||
var isPrinting by remember { mutableStateOf(false) }
|
||||
|
||||
suspend fun animatePrint() {
|
||||
receiptOffsetY.animateTo(
|
||||
targetValue = -1500f,
|
||||
animationSpec = tween(durationMillis = animationDuration, easing = FastOutSlowInEasing)
|
||||
)
|
||||
delay(1000.milliseconds)
|
||||
receiptOffsetY.animateTo(
|
||||
targetValue = 0f,
|
||||
animationSpec = tween(durationMillis = 0, easing = FastOutSlowInEasing)
|
||||
)
|
||||
val scope = rememberCoroutineScope();
|
||||
val receiptOffsetY = remember {
|
||||
Animatable(0f);
|
||||
}
|
||||
val animationDuration = 3000;
|
||||
|
||||
fun isReprintMode() = sharedViewModel.isReprint.value == true
|
||||
|
||||
fun doPrint(copy: ReceiptCopy, onFinished: () -> 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
|
||||
)
|
||||
onPrint()
|
||||
scope.launch {
|
||||
isPrinting = true
|
||||
animatePrint()
|
||||
isPrinting = false
|
||||
nextCopy = if (reprint) ReceiptCopy.CUSTOMER
|
||||
else if (actualCopy == ReceiptCopy.MERCHANT) ReceiptCopy.CUSTOMER else ReceiptCopy.MERCHANT
|
||||
onFinished()
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
val reprint = isReprintMode()
|
||||
if (reprint) {
|
||||
currentCopy = ReceiptCopy.CUSTOMER
|
||||
nextCopy = ReceiptCopy.CUSTOMER
|
||||
}
|
||||
sharedViewModel.isReprint.value = false
|
||||
when {
|
||||
merchant_copy_autoprint && !reprint -> doPrint(ReceiptCopy.MERCHANT) { }
|
||||
customer_copy_autoprint -> doPrint(ReceiptCopy.CUSTOMER) { }
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
@ -132,11 +74,10 @@ fun PrintReceiptScreen(
|
||||
|
||||
ReceiptPreview(
|
||||
state = state,
|
||||
copyLabel = currentCopy.label,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.verticalScroll(rememberScrollState())
|
||||
.graphicsLayer {
|
||||
.graphicsLayer{
|
||||
translationY = receiptOffsetY.value
|
||||
}
|
||||
)
|
||||
@ -165,7 +106,6 @@ fun PrintReceiptScreen(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(50.dp),
|
||||
enabled = !isPrinting,
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.LegacyRed,
|
||||
contentColor = Color.White,
|
||||
@ -174,7 +114,35 @@ fun PrintReceiptScreen(
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
onClick = {
|
||||
doPrint(nextCopy) { }
|
||||
onPrint()
|
||||
// try {
|
||||
// PrintReceipt.getInstance().printNow()
|
||||
// scope.launch {
|
||||
// launch {
|
||||
// receiptOffsetY.animateTo(
|
||||
// targetValue = -1500f,
|
||||
// animationSpec = tween(
|
||||
// durationMillis = animationDuration,
|
||||
// easing = FastOutSlowInEasing
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// delay(5000)
|
||||
// launch {
|
||||
// receiptOffsetY.animateTo(
|
||||
// targetValue = 0f,
|
||||
// animationSpec = tween(
|
||||
// durationMillis = 0,
|
||||
// easing = FastOutSlowInEasing
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// } catch (e: Exception) {
|
||||
//
|
||||
// Log.d("PrintReceipt", "error with $e")
|
||||
//
|
||||
// }
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
@ -192,7 +160,6 @@ fun PrintReceiptScreen(
|
||||
@Composable
|
||||
fun ReceiptPreview(
|
||||
state: TransactionResultState,
|
||||
copyLabel: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(
|
||||
@ -217,12 +184,6 @@ fun ReceiptPreview(
|
||||
text = "Transaction Receipt",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = copyLabel,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = Color.Gray
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
ReceiptDivider()
|
||||
ReceiptRow("Merchant", state.payDetail?.merchantName.toString() )
|
||||
@ -263,16 +224,16 @@ fun ReceiptRow(
|
||||
.padding(vertical = 6.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = Color.Gray
|
||||
)
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = Color.Gray
|
||||
)
|
||||
|
||||
Text(
|
||||
text = value,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Text(
|
||||
text = value,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,4 +259,4 @@ fun PreviewPrintReceiptScreen() {
|
||||
onDone = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="152.4dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="152.4"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:pathData="M60.4,25.7h31.5v56.6h-31.5z"
|
||||
android:fillColor="#FF5F00"/>
|
||||
<path
|
||||
android:pathData="M62.4,54c0,-11 5.1,-21.5 13.7,-28.3c-15.6,-12.3 -38.3,-9.6 -50.6,6.1C13.3,47.4 16,70 31.7,82.3c13.1,10.3 31.4,10.3 44.5,0C67.5,75.5 62.4,65 62.4,54z"
|
||||
android:fillColor="#EB001B"/>
|
||||
<path
|
||||
android:pathData="M134.4,54c0,19.9 -16.1,36 -36,36c-8.1,0 -15.9,-2.7 -22.2,-7.7c15.6,-12.3 18.3,-34.9 6,-50.6c-1.8,-2.2 -3.8,-4.3 -6,-6c15.6,-12.3 38.3,-9.6 50.5,6.1C131.7,38.1 134.4,45.9 134.4,54z"
|
||||
android:fillColor="#F79E1B"/>
|
||||
</vector>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 59 KiB |
File diff suppressed because one or more lines are too long
@ -1,18 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="800dp"
|
||||
android:height="800dp"
|
||||
android:viewportWidth="750"
|
||||
android:viewportHeight="471">
|
||||
<path
|
||||
android:pathData="M278.2,334.23l33.36,-195.76h53.36l-33.38,195.76H278.2L278.2,334.23z"
|
||||
android:fillColor="#0E4595"/>
|
||||
<path
|
||||
android:pathData="M524.31,142.69c-10.57,-3.97 -27.14,-8.22 -47.82,-8.22c-52.72,0 -89.86,26.55 -90.18,64.6c-0.3,28.13 26.51,43.82 46.75,53.19c20.77,9.6 27.75,15.72 27.65,24.28c-0.13,13.12 -16.59,19.12 -31.92,19.12c-21.35,0 -32.7,-2.97 -50.22,-10.27l-6.88,-3.11l-7.49,43.82c12.46,5.47 35.51,10.2 59.44,10.44c56.09,0 92.5,-26.25 92.92,-66.88c0.2,-22.27 -14.02,-39.22 -44.8,-53.19c-18.65,-9.06 -30.07,-15.1 -29.95,-24.27c0,-8.14 9.67,-16.84 30.56,-16.84c17.45,-0.27 30.09,3.53 39.94,7.5l4.78,2.26L524.31,142.69"
|
||||
android:fillColor="#0E4595"/>
|
||||
<path
|
||||
android:pathData="M661.61,138.46h-41.23c-12.77,0 -22.33,3.49 -27.94,16.23l-79.24,179.4h56.03c0,0 9.16,-24.12 11.23,-29.42c6.12,0 60.56,0.08 68.34,0.08c1.6,6.85 6.49,29.33 6.49,29.33h49.51L661.61,138.46L661.61,138.46zM596.2,264.87c4.41,-11.28 21.26,-54.72 21.26,-54.72c-0.31,0.52 4.38,-11.33 7.07,-18.68l3.61,16.88c0,0 10.22,46.73 12.35,56.53h-44.29V264.87L596.2,264.87z"
|
||||
android:fillColor="#0E4595"/>
|
||||
<path
|
||||
android:pathData="M45.88,138.46L45.2,142.54C66.29,147.64 85.13,155.03 101.62,164.23L148.97,333.91L205.42,333.85L289.43,138.46L232.9,138.46L180.66,271.96L175.1,244.83C174.84,243.99 174.56,243.15 174.27,242.31L156.11,154.99C152.88,142.6 143.51,138.9 131.92,138.46L45.88,138.46z"
|
||||
android:fillColor="#0e4595"/>
|
||||
</vector>
|
||||
@ -12,7 +12,7 @@ android {
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 25
|
||||
minSdk = 23
|
||||
//noinspection ExpiredTargetSdkVersion
|
||||
targetSdk = 30
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ android {
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 25
|
||||
minSdk = 23
|
||||
//noinspection ExpiredTargetSdkVersion
|
||||
targetSdk = 30
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ android {
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 25
|
||||
targetSdk = 36
|
||||
minSdk = 23
|
||||
targetSdk = 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ android {
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 25
|
||||
targetSdk = 36
|
||||
minSdk = 23
|
||||
targetSdk = 30
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
|
||||
@ -7,7 +7,7 @@ android {
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 25
|
||||
minSdk = 23
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user