last sync caller
This commit is contained in:
parent
211b092c2d
commit
a286a8258c
@ -102,7 +102,8 @@ fun DashboardScreen2(
|
|||||||
onNavigateAction: (String) -> Unit = {},
|
onNavigateAction: (String) -> Unit = {},
|
||||||
onNavigateNotifications: () -> Unit = {},
|
onNavigateNotifications: () -> Unit = {},
|
||||||
dashboardUiState: DashboardUiState = DashboardUiState(),
|
dashboardUiState: DashboardUiState = DashboardUiState(),
|
||||||
deviceInfo: DeviceInfoUiState = DeviceInfoUiState()
|
deviceInfo: DeviceInfoUiState = DeviceInfoUiState(),
|
||||||
|
onClickLastSync: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||||
@ -112,7 +113,13 @@ fun DashboardScreen2(
|
|||||||
var activeHostAction by remember { mutableStateOf("Log-On") }
|
var activeHostAction by remember { mutableStateOf("Log-On") }
|
||||||
var isHostActionRunning by remember { mutableStateOf(false) }
|
var isHostActionRunning by remember { mutableStateOf(false) }
|
||||||
var dialogMessage by remember { mutableStateOf("") }
|
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
|
val isOnline = true
|
||||||
|
|
||||||
@ -322,7 +329,9 @@ fun DashboardScreen2(
|
|||||||
title = "Reversal", subTitle = "Enable / Disable Reversal",
|
title = "Reversal", subTitle = "Enable / Disable Reversal",
|
||||||
onClick = {
|
onClick = {
|
||||||
reversalEnabled = !reversalEnabled
|
reversalEnabled = !reversalEnabled
|
||||||
runCatching { SystemParamsOperation.getInstance().setReversalFlag(reversalEnabled) }
|
runCatching {
|
||||||
|
SystemParamsOperation.getInstance().setReversalFlag(reversalEnabled)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
Icon(
|
Icon(
|
||||||
@ -336,7 +345,9 @@ fun DashboardScreen2(
|
|||||||
checked = reversalEnabled,
|
checked = reversalEnabled,
|
||||||
onCheckedChange = { isChecked ->
|
onCheckedChange = { isChecked ->
|
||||||
reversalEnabled = isChecked
|
reversalEnabled = isChecked
|
||||||
runCatching { SystemParamsOperation.getInstance().setReversalFlag(isChecked) }
|
runCatching {
|
||||||
|
SystemParamsOperation.getInstance().setReversalFlag(isChecked)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -429,7 +440,9 @@ fun DashboardScreen2(
|
|||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
SummaryCard()
|
SummaryCard(
|
||||||
|
onClickLastSync
|
||||||
|
)
|
||||||
}
|
}
|
||||||
//pager section
|
//pager section
|
||||||
Box(
|
Box(
|
||||||
@ -499,13 +512,15 @@ private fun AdvertisingArea() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SummaryCard() {
|
private fun SummaryCard(
|
||||||
|
onClickLastSync: () -> Unit
|
||||||
|
) {
|
||||||
var isRotating by remember { mutableStateOf(false) }
|
var isRotating by remember { mutableStateOf(false) }
|
||||||
val rotation by animateFloatAsState(
|
val rotation by animateFloatAsState(
|
||||||
targetValue = if(isRotating) 360f else 0f,
|
targetValue = if (isRotating) 360f else 0f,
|
||||||
animationSpec = tween(durationMillis = 3000, easing = LinearEasing),
|
animationSpec = tween(durationMillis = 3000, easing = LinearEasing),
|
||||||
label = "sync rotating",
|
label = "sync rotating",
|
||||||
finishedListener = {isRotating = false}
|
finishedListener = { isRotating = false }
|
||||||
)
|
)
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -559,18 +574,21 @@ private fun SummaryCard() {
|
|||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.background(Color.CrimsonRed.copy(alpha = 0.1f))
|
.background(Color.CrimsonRed.copy(alpha = 0.1f))
|
||||||
.clickable(
|
.clickable(
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = null
|
indication = null
|
||||||
){
|
) {
|
||||||
if(!isRotating) isRotating = true
|
if (!isRotating) isRotating = true
|
||||||
},
|
onClickLastSync()
|
||||||
contentAlignment = Alignment.Center
|
},
|
||||||
){
|
contentAlignment = Alignment.Center,
|
||||||
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Sync,
|
imageVector = Icons.Default.Sync,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = Color.LegacyRed,
|
tint = Color.CrimsonRed,
|
||||||
modifier = Modifier.size(22.dp).rotate(rotation)
|
modifier = Modifier
|
||||||
|
.size(22.dp)
|
||||||
|
.rotate(rotation)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -643,18 +661,125 @@ private fun buildMenuItems(
|
|||||||
onNavigateSettlement: () -> Unit,
|
onNavigateSettlement: () -> Unit,
|
||||||
onNavigateAction: (String) -> Unit
|
onNavigateAction: (String) -> Unit
|
||||||
): List<DashboardMenuItem> = listOf(
|
): List<DashboardMenuItem> = listOf(
|
||||||
DashboardMenuItem("Sale", { Icon(painterResource(R.drawable.ic_terminal), contentDescription = null, modifier = Modifier.size(40.dp), tint = Color.LegacyRed) }) { onNavigateAmount("Sale") },
|
DashboardMenuItem(
|
||||||
DashboardMenuItem("MMQR", { Image(painter = painterResource(R.drawable.ic_mmqr_logo), contentDescription = null, modifier = Modifier.height(48.dp)) }) { },
|
"Sale",
|
||||||
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() },
|
Icon(
|
||||||
DashboardMenuItem("Settlement", { Icon(painterResource(R.drawable.ic_settlement), contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateSettlement() },
|
painterResource(R.drawable.ic_terminal),
|
||||||
DashboardMenuItem("Void", { Icon(Icons.Default.Lock, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Void") },
|
contentDescription = null,
|
||||||
DashboardMenuItem("Refund", { Icon(Icons.Default.Replay, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Refund") },
|
modifier = Modifier.size(40.dp),
|
||||||
DashboardMenuItem("Pre-Auth", { Icon(Icons.Default.Lock, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Pre-Auth") },
|
tint = Color.LegacyRed
|
||||||
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") },
|
}) { onNavigateAmount("Sale") },
|
||||||
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(
|
||||||
DashboardMenuItem("Cash Out", { Icon(Icons.Default.AccountBalanceWallet, contentDescription = null, modifier = Modifier.size(32.dp), tint = Color.LegacyRed) }) { onNavigateAction("Cash Out") },
|
"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
|
@Composable
|
||||||
@ -877,11 +1002,51 @@ private fun TrnxRow(record: TrnxRecord) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val previewTransactions = listOf(
|
private val previewTransactions = listOf(
|
||||||
TrnxRecord(1L, "Sale", "MMK 10,000", "**** 1234", "06/10 14:32", isVoided = false, isApproved = true),
|
TrnxRecord(
|
||||||
TrnxRecord(2L, "Void", "MMK 5,500", "**** 5678", "06/10 13:10", isVoided = true, isApproved = false),
|
1L,
|
||||||
TrnxRecord(3L, "Refund", "MMK 2,000", "**** 9012", "06/09 09:45", isVoided = false, isApproved = true),
|
"Sale",
|
||||||
TrnxRecord(4L, "Sale", "MMK 30,000", "**** 3456", "06/09 08:00", isVoided = false, isApproved = true),
|
"MMK 10,000",
|
||||||
TrnxRecord(5L, "Settlement", "MMK 0", "----", "06/08 18:00", isVoided = false, isApproved = true),
|
"**** 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
|
@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.DashboardScreen2
|
||||||
import com.mob.utsmyanmar.ui.dashboard.DashboardViewModel
|
import com.mob.utsmyanmar.ui.dashboard.DashboardViewModel
|
||||||
import com.mob.utsmyanmar.ui.device_info.DeviceInfoViewModel
|
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.functions.FunctionsScreen
|
||||||
import com.mob.utsmyanmar.ui.input_amount.AmountRoute
|
import com.mob.utsmyanmar.ui.input_amount.AmountRoute
|
||||||
import com.mob.utsmyanmar.ui.notification.NotificationDetailScreen
|
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.settlement.SettlementViewModel
|
||||||
import com.mob.utsmyanmar.ui.sign_on.SignOnResultScreen
|
import com.mob.utsmyanmar.ui.sign_on.SignOnResultScreen
|
||||||
import com.mob.utsmyanmar.ui.sign_on.SignOnRoute
|
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.TmsSetupRoute
|
||||||
import com.mob.utsmyanmar.ui.tms_setup.TmsSetupViewModel
|
import com.mob.utsmyanmar.ui.tms_setup.TmsSetupViewModel
|
||||||
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultEvent
|
import com.mob.utsmyanmar.ui.transaction_result.TransactionResultEvent
|
||||||
@ -108,6 +108,7 @@ fun AppNavGraph(
|
|||||||
val dashboardUiState by dashboardViewModel.uiState.collectAsStateWithLifecycle()
|
val dashboardUiState by dashboardViewModel.uiState.collectAsStateWithLifecycle()
|
||||||
val deviceInfoViewModel: DeviceInfoViewModel = hiltViewModel()
|
val deviceInfoViewModel: DeviceInfoViewModel = hiltViewModel()
|
||||||
val deviceInfo by deviceInfoViewModel.uiState.collectAsStateWithLifecycle()
|
val deviceInfo by deviceInfoViewModel.uiState.collectAsStateWithLifecycle()
|
||||||
|
val tmsSetupViewModel: TmsSetupViewModel = hiltViewModel()
|
||||||
androidx.compose.runtime.LaunchedEffect(Unit) { deviceInfoViewModel.loadDeviceInfo() }
|
androidx.compose.runtime.LaunchedEffect(Unit) { deviceInfoViewModel.loadDeviceInfo() }
|
||||||
DashboardScreen2(
|
DashboardScreen2(
|
||||||
dashboardUiState = dashboardUiState,
|
dashboardUiState = dashboardUiState,
|
||||||
@ -148,6 +149,9 @@ fun AppNavGraph(
|
|||||||
},
|
},
|
||||||
onNavigateNotifications = {
|
onNavigateNotifications = {
|
||||||
navController.navigate(Routes.NotificationList.route) { launchSingleTop = true }
|
navController.navigate(Routes.NotificationList.route) { launchSingleTop = true }
|
||||||
|
},
|
||||||
|
onClickLastSync = {
|
||||||
|
tmsSetupViewModel.downloadConfigs()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -150,27 +150,6 @@ class TmsSetupViewModel @Inject constructor(
|
|||||||
viewModelScope.launch { _navigateToDashboard.emit(Unit) }
|
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")
|
@SuppressLint("MissingPermission")
|
||||||
private fun buildRequest(): SiriusRequest {
|
private fun buildRequest(): SiriusRequest {
|
||||||
return try {
|
return try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user