Compare commits

...

2 Commits

Author SHA1 Message Date
moon
13aed803ae image array get from tms 2026-06-17 00:25:14 +06:30
moon
4fb6556d1b dashboard padding fix 2026-06-16 23:54:04 +06:30
6 changed files with 62 additions and 67 deletions

View File

@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.pager.rememberPagerState
@ -421,37 +422,28 @@ fun DashboardScreen2(
} }
) )
}) { paddingValues -> }) { paddingValues ->
Column( LazyColumn(
modifier = Modifier modifier = Modifier
.padding(paddingValues) .padding(paddingValues)
.fillMaxSize() .fillMaxSize()
) { ) {
//top section item {
Box( AdvertisingArea(
carouselUrls = dashboardUiState.carouselUrls,
modifier = Modifier modifier = Modifier
.weight(1f) .fillMaxWidth()
.fillMaxWidth(), .height(200.dp)
) { )
AdvertisingArea()
} }
//center section item {
Box( Spacer(Modifier.height(12.dp))
modifier = Modifier
.weight(1f)
.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
SummaryCard( SummaryCard(
onClickLastSync = onClickLastSync, onClickLastSync = onClickLastSync,
lastSyncTime = dashboardUiState.lastSyncTime lastSyncTime = dashboardUiState.lastSyncTime
) )
Spacer(Modifier.height(12.dp))
} }
//pager section item {
Box(
modifier = Modifier
.weight(1.3f)
.fillMaxWidth(),
) {
MenuPager( MenuPager(
items = buildMenuItems( items = buildMenuItems(
onNavigateAmount = onNavigateAmount, onNavigateAmount = onNavigateAmount,
@ -459,35 +451,32 @@ fun DashboardScreen2(
onNavigateSettlement = onNavigateSettlement, onNavigateSettlement = onNavigateSettlement,
onNavigateAction = onNavigateAction onNavigateAction = onNavigateAction
), ),
modifier = Modifier.fillMaxSize() modifier = Modifier
.fillMaxWidth()
// .height(250.dp)
) )
} }
//transactions section item { Spacer(Modifier.height(8.dp)) }
// RecentTransactions( recentTransactionsItems(transactions = dashboardUiState.recentTransactions)
// transactions = dashboardUiState.recentTransactions,
// modifier = Modifier
// .weight(1.2f)
// .fillMaxWidth()
// )
} }
} }
} }
} }
@Composable @Composable
private fun AdvertisingArea() { private fun AdvertisingArea(
carouselUrls: List<String> = emptyList(),
val imageArray = listOf( modifier: Modifier = Modifier
"https://i.ytimg.com/vi/eRUVxGRp1Ms/maxresdefault.jpg", ) {
"https://i.ytimg.com/vi/AwvmgTPd7qw/maxresdefault.jpg", val imageModels: List<Any> = carouselUrls.ifEmpty {
"https://mma.prnewswire.com/media/2080956/SUNMI_3rd_generation_products_T3_PRO_series_V3_MIX.jpg?p=facebook" listOf(R.drawable.sunmi1, R.drawable.sunmi2, R.drawable.sunmi3)
) }
val pageState = rememberPagerState(pageCount = { imageArray.size }) val pageState = rememberPagerState(pageCount = { imageModels.size })
LaunchedEffect(pageState) { LaunchedEffect(pageState) {
while (true) { while (true) {
delay(10000.milliseconds) delay(10000.milliseconds)
val nextPage = (pageState.currentPage + 1) % imageArray.size val nextPage = (pageState.currentPage + 1) % imageModels.size
pageState.animateScrollToPage( pageState.animateScrollToPage(
page = nextPage, animationSpec = tween(durationMillis = 700) page = nextPage, animationSpec = tween(durationMillis = 700)
@ -496,7 +485,7 @@ private fun AdvertisingArea() {
} }
Card( Card(
modifier = Modifier.fillMaxSize(), modifier = modifier,
shape = RoundedCornerShape(0.dp), shape = RoundedCornerShape(0.dp),
colors = CardDefaults.cardColors(containerColor = Color.White), colors = CardDefaults.cardColors(containerColor = Color.White),
) { ) {
@ -504,7 +493,7 @@ private fun AdvertisingArea() {
state = pageState, modifier = Modifier.fillMaxSize() state = pageState, modifier = Modifier.fillMaxSize()
) { page -> ) { page ->
AsyncImage( AsyncImage(
model = imageArray[page], model = imageModels[page],
contentDescription = "ads images", contentDescription = "ads images",
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop contentScale = ContentScale.Crop
@ -814,7 +803,9 @@ private fun MenuPager(
Column(modifier = modifier) { Column(modifier = modifier) {
HorizontalPager( HorizontalPager(
state = pagerState, state = pagerState,
modifier = Modifier.weight(1f) modifier = Modifier
.fillMaxWidth()
// .height(236.dp)
) { pageIndex -> ) { pageIndex ->
MenuPage(items = pages[pageIndex]) MenuPage(items = pages[pageIndex])
} }
@ -848,7 +839,6 @@ private fun MenuPage(items: List<DashboardMenuItem>) {
verticalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.padding(horizontal = 16.dp) modifier = Modifier.padding(horizontal = 16.dp)
) { ) {
Spacer(Modifier.height(8.dp))
items.chunked(3).forEach { rowItems -> items.chunked(3).forEach { rowItems ->
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) { Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
rowItems.forEach { item -> rowItems.forEach { item ->
@ -921,12 +911,8 @@ private fun MenuCard(
} }
} }
@Composable private fun LazyListScope.recentTransactionsItems(transactions: List<TrnxRecord>) {
private fun RecentTransactions( item {
transactions: List<TrnxRecord>,
modifier: Modifier = Modifier
) {
Column(modifier = modifier) {
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
@ -943,7 +929,7 @@ private fun RecentTransactions(
modifier = Modifier.padding(horizontal = 16.dp), modifier = Modifier.padding(horizontal = 16.dp),
color = Color.Gray.copy(alpha = 0.2f) color = Color.Gray.copy(alpha = 0.2f)
) )
LazyColumn(modifier = Modifier.fillMaxSize()) { }
if (transactions.isEmpty()) { if (transactions.isEmpty()) {
item { item {
Text( Text(
@ -962,8 +948,6 @@ private fun RecentTransactions(
} }
} }
} }
}
}
@Composable @Composable
private fun TrnxRow(record: TrnxRecord) { private fun TrnxRow(record: TrnxRecord) {

View File

@ -12,5 +12,6 @@ data class TrnxRecord(
data class DashboardUiState( data class DashboardUiState(
val recentTransactions: List<TrnxRecord> = emptyList(), val recentTransactions: List<TrnxRecord> = emptyList(),
val lastSyncTime: Long? = null val lastSyncTime: Long? = null,
val carouselUrls: List<String> = emptyList()
) )

View File

@ -6,6 +6,7 @@ import androidx.lifecycle.asFlow
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.utsmyanmar.baselib.repo.Repository import com.utsmyanmar.baselib.repo.Repository
import com.utsmyanmar.paylibs.model.PayDetail import com.utsmyanmar.paylibs.model.PayDetail
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
@ -35,6 +36,15 @@ class DashboardViewModel @Inject constructor(
} }
} }
refreshLastSyncTime() refreshLastSyncTime()
loadCarouselUrls()
}
private fun loadCarouselUrls() {
val raw = runCatching {
SystemParamsOperation.getInstance().carouselUrls
}.getOrDefault("")
val urls = raw.split(",").filter { it.isNotBlank() }
_uiState.update { it.copy(carouselUrls = urls) }
} }
fun refreshLastSyncTime() { fun refreshLastSyncTime() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB