last sync caller
This commit is contained in:
parent
211b092c2d
commit
a286a8258c
@ -102,7 +102,8 @@ fun DashboardScreen2(
|
||||
onNavigateAction: (String) -> Unit = {},
|
||||
onNavigateNotifications: () -> Unit = {},
|
||||
dashboardUiState: DashboardUiState = DashboardUiState(),
|
||||
deviceInfo: DeviceInfoUiState = DeviceInfoUiState()
|
||||
deviceInfo: DeviceInfoUiState = DeviceInfoUiState(),
|
||||
onClickLastSync: () -> Unit = {},
|
||||
) {
|
||||
|
||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||
@ -112,7 +113,13 @@ fun DashboardScreen2(
|
||||
var activeHostAction by remember { mutableStateOf("Log-On") }
|
||||
var isHostActionRunning by remember { mutableStateOf(false) }
|
||||
var dialogMessage by remember { mutableStateOf("") }
|
||||
var reversalEnabled by remember { mutableStateOf(runCatching { SystemParamsOperation.getInstance().isReversalOn }.getOrDefault(false)) }
|
||||
var reversalEnabled by remember {
|
||||
mutableStateOf(
|
||||
runCatching { SystemParamsOperation.getInstance().isReversalOn }.getOrDefault(
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val isOnline = true
|
||||
|
||||
@ -322,7 +329,9 @@ fun DashboardScreen2(
|
||||
title = "Reversal", subTitle = "Enable / Disable Reversal",
|
||||
onClick = {
|
||||
reversalEnabled = !reversalEnabled
|
||||
runCatching { SystemParamsOperation.getInstance().setReversalFlag(reversalEnabled) }
|
||||
runCatching {
|
||||
SystemParamsOperation.getInstance().setReversalFlag(reversalEnabled)
|
||||
}
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
@ -336,7 +345,9 @@ fun DashboardScreen2(
|
||||
checked = reversalEnabled,
|
||||
onCheckedChange = { isChecked ->
|
||||
reversalEnabled = isChecked
|
||||
runCatching { SystemParamsOperation.getInstance().setReversalFlag(isChecked) }
|
||||
runCatching {
|
||||
SystemParamsOperation.getInstance().setReversalFlag(isChecked)
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
@ -429,7 +440,9 @@ fun DashboardScreen2(
|
||||
.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
SummaryCard()
|
||||
SummaryCard(
|
||||
onClickLastSync
|
||||
)
|
||||
}
|
||||
//pager section
|
||||
Box(
|
||||
@ -499,7 +512,9 @@ private fun AdvertisingArea() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SummaryCard() {
|
||||
private fun SummaryCard(
|
||||
onClickLastSync: () -> Unit
|
||||
) {
|
||||
var isRotating by remember { mutableStateOf(false) }
|
||||
val rotation by animateFloatAsState(
|
||||
targetValue = if (isRotating) 360f else 0f,
|
||||
@ -563,14 +578,17 @@ private fun SummaryCard() {
|
||||
indication = null
|
||||
) {
|
||||
if (!isRotating) isRotating = true
|
||||
onClickLastSync()
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Sync,
|
||||
contentDescription = null,
|
||||
tint = Color.LegacyRed,
|
||||
modifier = Modifier.size(22.dp).rotate(rotation)
|
||||
tint = Color.CrimsonRed,
|
||||
modifier = Modifier
|
||||
.size(22.dp)
|
||||
.rotate(rotation)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -643,18 +661,125 @@ private fun buildMenuItems(
|
||||
onNavigateSettlement: () -> Unit,
|
||||
onNavigateAction: (String) -> Unit
|
||||
): List<DashboardMenuItem> = listOf(
|
||||
DashboardMenuItem("Sale", { Icon(painterResource(R.drawable.ic_terminal), contentDescription = null, modifier = Modifier.size(40.dp), tint = Color.LegacyRed) }) { onNavigateAmount("Sale") },
|
||||
DashboardMenuItem("MMQR", { Image(painter = painterResource(R.drawable.ic_mmqr_logo), contentDescription = null, modifier = Modifier.height(48.dp)) }) { },
|
||||
DashboardMenuItem("History", { Icon(painterResource(R.drawable.ic_history), contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { },
|
||||
DashboardMenuItem("Sign On", { Icon(painterResource(R.drawable.ic_sign_on), contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateSignOn() },
|
||||
DashboardMenuItem("Settlement", { Icon(painterResource(R.drawable.ic_settlement), contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateSettlement() },
|
||||
DashboardMenuItem("Void", { Icon(Icons.Default.Lock, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Void") },
|
||||
DashboardMenuItem("Refund", { Icon(Icons.Default.Replay, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Refund") },
|
||||
DashboardMenuItem("Pre-Auth", { Icon(Icons.Default.Lock, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Pre-Auth") },
|
||||
DashboardMenuItem("Pre-Auth Void", { Icon(Icons.Default.LockOpen, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Pre-Auth Void") },
|
||||
DashboardMenuItem("Pre-Auth Complete", { Icon(Icons.Default.CreditCard, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Pre-Auth Complete") },
|
||||
DashboardMenuItem("Pre-Auth Complete Void", { Icon(Icons.Default.SwapHoriz, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Pre-Auth Complete Void") },
|
||||
DashboardMenuItem("Cash Out", { Icon(Icons.Default.AccountBalanceWallet, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Cash Out") },
|
||||
DashboardMenuItem(
|
||||
"Sale",
|
||||
{
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_terminal),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(40.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAmount("Sale") },
|
||||
DashboardMenuItem(
|
||||
"MMQR",
|
||||
{
|
||||
Image(
|
||||
painter = painterResource(R.drawable.ic_mmqr_logo),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.height(48.dp)
|
||||
)
|
||||
}) { },
|
||||
DashboardMenuItem(
|
||||
"History",
|
||||
{
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_history),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { },
|
||||
DashboardMenuItem(
|
||||
"Sign On",
|
||||
{
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_sign_on),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateSignOn() },
|
||||
DashboardMenuItem(
|
||||
"Settlement",
|
||||
{
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_settlement),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateSettlement() },
|
||||
DashboardMenuItem(
|
||||
"Void",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.Lock,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Void") },
|
||||
DashboardMenuItem(
|
||||
"Refund",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.Replay,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Refund") },
|
||||
DashboardMenuItem(
|
||||
"Pre-Auth",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.Lock,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Pre-Auth") },
|
||||
DashboardMenuItem(
|
||||
"Pre-Auth Void",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.LockOpen,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Pre-Auth Void") },
|
||||
DashboardMenuItem(
|
||||
"Pre-Auth Complete",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.CreditCard,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Pre-Auth Complete") },
|
||||
DashboardMenuItem(
|
||||
"Pre-Auth Complete Void",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.SwapHoriz,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Pre-Auth Complete Void") },
|
||||
DashboardMenuItem(
|
||||
"Cash Out",
|
||||
{
|
||||
Icon(
|
||||
Icons.Default.AccountBalanceWallet,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = Color.LegacyRed
|
||||
)
|
||||
}) { onNavigateAction("Cash Out") },
|
||||
)
|
||||
|
||||
@Composable
|
||||
@ -877,11 +1002,51 @@ private fun TrnxRow(record: TrnxRecord) {
|
||||
}
|
||||
|
||||
private val previewTransactions = listOf(
|
||||
TrnxRecord(1L, "Sale", "MMK 10,000", "**** 1234", "06/10 14:32", isVoided = false, isApproved = true),
|
||||
TrnxRecord(2L, "Void", "MMK 5,500", "**** 5678", "06/10 13:10", isVoided = true, isApproved = false),
|
||||
TrnxRecord(3L, "Refund", "MMK 2,000", "**** 9012", "06/09 09:45", isVoided = false, isApproved = true),
|
||||
TrnxRecord(4L, "Sale", "MMK 30,000", "**** 3456", "06/09 08:00", isVoided = false, isApproved = true),
|
||||
TrnxRecord(5L, "Settlement", "MMK 0", "----", "06/08 18:00", isVoided = false, isApproved = true),
|
||||
TrnxRecord(
|
||||
1L,
|
||||
"Sale",
|
||||
"MMK 10,000",
|
||||
"**** 1234",
|
||||
"06/10 14:32",
|
||||
isVoided = false,
|
||||
isApproved = true
|
||||
),
|
||||
TrnxRecord(
|
||||
2L,
|
||||
"Void",
|
||||
"MMK 5,500",
|
||||
"**** 5678",
|
||||
"06/10 13:10",
|
||||
isVoided = true,
|
||||
isApproved = false
|
||||
),
|
||||
TrnxRecord(
|
||||
3L,
|
||||
"Refund",
|
||||
"MMK 2,000",
|
||||
"**** 9012",
|
||||
"06/09 09:45",
|
||||
isVoided = false,
|
||||
isApproved = true
|
||||
),
|
||||
TrnxRecord(
|
||||
4L,
|
||||
"Sale",
|
||||
"MMK 30,000",
|
||||
"**** 3456",
|
||||
"06/09 08:00",
|
||||
isVoided = false,
|
||||
isApproved = true
|
||||
),
|
||||
TrnxRecord(
|
||||
5L,
|
||||
"Settlement",
|
||||
"MMK 0",
|
||||
"----",
|
||||
"06/08 18:00",
|
||||
isVoided = false,
|
||||
isApproved = true
|
||||
),
|
||||
)
|
||||
|
||||
@P3Preview
|
||||
|
||||
@ -20,6 +20,7 @@ import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingViewModel
|
||||
import com.mob.utsmyanmar.ui.dashboard.DashboardScreen2
|
||||
import com.mob.utsmyanmar.ui.dashboard.DashboardViewModel
|
||||
import com.mob.utsmyanmar.ui.device_info.DeviceInfoViewModel
|
||||
import com.mob.utsmyanmar.ui.disable.DisableScreen
|
||||
import com.mob.utsmyanmar.ui.functions.FunctionsScreen
|
||||
import com.mob.utsmyanmar.ui.input_amount.AmountRoute
|
||||
import com.mob.utsmyanmar.ui.notification.NotificationDetailScreen
|
||||
@ -41,7 +42,6 @@ import com.mob.utsmyanmar.ui.settlement.SettlementScreen
|
||||
import com.mob.utsmyanmar.ui.settlement.SettlementViewModel
|
||||
import com.mob.utsmyanmar.ui.sign_on.SignOnResultScreen
|
||||
import com.mob.utsmyanmar.ui.sign_on.SignOnRoute
|
||||
import com.mob.utsmyanmar.ui.disable.DisableScreen
|
||||
import com.mob.utsmyanmar.ui.tms_setup.TmsSetupRoute
|
||||
import com.mob.utsmyanmar.ui.tms_setup.TmsSetupViewModel
|
||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultEvent
|
||||
@ -108,6 +108,7 @@ fun AppNavGraph(
|
||||
val dashboardUiState by dashboardViewModel.uiState.collectAsStateWithLifecycle()
|
||||
val deviceInfoViewModel: DeviceInfoViewModel = hiltViewModel()
|
||||
val deviceInfo by deviceInfoViewModel.uiState.collectAsStateWithLifecycle()
|
||||
val tmsSetupViewModel: TmsSetupViewModel = hiltViewModel()
|
||||
androidx.compose.runtime.LaunchedEffect(Unit) { deviceInfoViewModel.loadDeviceInfo() }
|
||||
DashboardScreen2(
|
||||
dashboardUiState = dashboardUiState,
|
||||
@ -148,6 +149,9 @@ fun AppNavGraph(
|
||||
},
|
||||
onNavigateNotifications = {
|
||||
navController.navigate(Routes.NotificationList.route) { launchSingleTop = true }
|
||||
},
|
||||
onClickLastSync = {
|
||||
tmsSetupViewModel.downloadConfigs()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@ -150,27 +150,6 @@ class TmsSetupViewModel @Inject constructor(
|
||||
viewModelScope.launch { _navigateToDashboard.emit(Unit) }
|
||||
}
|
||||
|
||||
// private fun formatNetworkError(error: Throwable): String {
|
||||
// return when (error) {
|
||||
// is javax.net.ssl.SSLHandshakeException ->
|
||||
// "SSL handshake failed: ${error.message ?: "Certificate or protocol mismatch"}"
|
||||
// is javax.net.ssl.SSLException ->
|
||||
// "SSL/TLS error: ${error.message ?: "Secure connection could not be established"}"
|
||||
// is java.security.cert.CertificateException ->
|
||||
// "Server certificate error: ${error.message ?: "Certificate is invalid or untrusted"}"
|
||||
// is java.net.UnknownHostException ->
|
||||
// "Host not found: ${error.message ?: "Check server URL and network connection"}"
|
||||
// is java.net.ConnectException ->
|
||||
// "Connection refused: ${error.message ?: "Server is unreachable"}"
|
||||
// is java.net.SocketTimeoutException ->
|
||||
// "Connection timed out: ${error.message ?: "Server did not respond in time"}"
|
||||
// is retrofit2.HttpException ->
|
||||
// "HTTP ${error.code()} ${error.message()}"
|
||||
// else ->
|
||||
// error.message ?: "Unknown network error"
|
||||
// }
|
||||
// }
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun buildRequest(): SiriusRequest {
|
||||
return try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user