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

View File

@ -12,5 +12,6 @@ data class TrnxRecord(
data class DashboardUiState(
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 com.utsmyanmar.baselib.repo.Repository
import com.utsmyanmar.paylibs.model.PayDetail
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.MutableStateFlow
@ -35,6 +36,15 @@ class DashboardViewModel @Inject constructor(
}
}
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() {

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