fix last 10 trans in Dashboard
This commit is contained in:
parent
d32b233d9e
commit
2937a747c8
@ -4,8 +4,10 @@ import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.animation.core.LinearEasing
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.tween
|
||||
@ -100,6 +102,7 @@ import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@Composable
|
||||
fun DashboardScreen2(
|
||||
onNavigateAmount: (String) -> Unit = {},
|
||||
@ -473,8 +476,8 @@ fun DashboardScreen2(
|
||||
|
||||
@Composable
|
||||
private fun AdvertisingArea(
|
||||
modifier: Modifier = Modifier,
|
||||
carouselUrls: List<String> = emptyList(),
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val imageModels: List<Any> = carouselUrls.ifEmpty {
|
||||
listOf(R.drawable.sunmi1, R.drawable.sunmi2, R.drawable.sunmi3)
|
||||
@ -529,7 +532,7 @@ private fun SummaryCard(
|
||||
var now by remember { mutableLongStateOf(System.currentTimeMillis()) }
|
||||
LaunchedEffect(Unit) {
|
||||
while (true) {
|
||||
delay(30_000)
|
||||
delay(30_000.milliseconds)
|
||||
now = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
@ -987,10 +990,10 @@ private fun TrnxRow(record: TrnxRecord) {
|
||||
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = if (record.isVoided) "${record.typeLabel} (Voided)" else record.typeLabel,
|
||||
text =record.typeLabel,
|
||||
fontSize = 13.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = if (record.isVoided) Color.Gray else Color.Black
|
||||
color = Color.Black
|
||||
)
|
||||
Text(
|
||||
text = record.maskedCard,
|
||||
@ -1063,6 +1066,7 @@ private val previewTransactions = listOf(
|
||||
),
|
||||
)
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@P3Preview
|
||||
@P2Preview
|
||||
@Composable
|
||||
@ -1081,6 +1085,7 @@ fun PreviewItem() {
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@Composable
|
||||
private fun rememberIsOnline() = run {
|
||||
val context = LocalContext.current
|
||||
|
||||
@ -29,14 +29,14 @@ class DashboardViewModel @Inject constructor(
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
repository.getAllTrans().asFlow().collect { payDetails ->
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
recentTransactions = payDetails.take(10).map { pd -> pd.toRecord() }
|
||||
)
|
||||
repository.getLastTenTransactions().asFlow().collect { payDetails ->
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
recentTransactions = payDetails.map { pd -> pd.toRecord() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshLastSyncTime()
|
||||
loadCarouselUrls()
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.NavType
|
||||
@ -15,6 +16,7 @@ import com.mob.utsmyanmar.model.ProcessCode
|
||||
import com.mob.utsmyanmar.ui.cardwaiting.CardWaitingScreen
|
||||
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.dashboard.SeeMoreScreen
|
||||
import com.mob.utsmyanmar.ui.device_info.DeviceInfoViewModel
|
||||
import com.mob.utsmyanmar.ui.functions.FunctionsScreen
|
||||
@ -78,9 +80,12 @@ fun AppNavGraph(
|
||||
composable(Routes.Dashboard.route) {
|
||||
val sharedViewModel: SharedViewModel = hiltViewModel(activity)
|
||||
val transProcessViewModel: TransProcessViewModel = hiltViewModel(activity)
|
||||
val dashboardViewModel: DashboardViewModel = hiltViewModel(activity)
|
||||
val dashboardUiState = dashboardViewModel.uiState.collectAsStateWithLifecycle().value
|
||||
|
||||
transProcessViewModel.resetTransactionStatus()
|
||||
DashboardScreen2(
|
||||
dashboardUiState = dashboardUiState,
|
||||
onNavigateAmount = { action ->
|
||||
when (action) {
|
||||
"Sale" -> {
|
||||
|
||||
@ -145,6 +145,9 @@ public interface PayDetailDao {
|
||||
@Query("SELECT * FROM paydetail ORDER BY PID DESC LIMIT 3")
|
||||
LiveData<List<PayDetail>> getLastThreeTransactions();
|
||||
|
||||
@Query("SELECT * FROM paydetail ORDER BY PID DESC LIMIT 10")
|
||||
LiveData<List<PayDetail>> getLastTenTransactions();
|
||||
|
||||
@Query("SELECT * FROM paydetail ORDER BY PID DESC LIMIT 1")
|
||||
LiveData<PayDetail> getLastTransaction();
|
||||
|
||||
|
||||
@ -113,6 +113,10 @@ public class Repository {
|
||||
|
||||
public LiveData<List<PayDetail>> getLastThreeTransactions(){ return payDetailDao.getLastThreeTransactions();}
|
||||
|
||||
|
||||
|
||||
public LiveData<List<PayDetail>> getLastTenTransactions() { return payDetailDao.getLastTenTransactions(); }
|
||||
|
||||
public LiveData<List<PayDetail>> getVoidableTransactions(int transType){
|
||||
return payDetailDao.getVoidableTransactions(transType);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user