Compare commits
No commits in common. "13aed803ae55a964ae598ce5c581428d741e5d71" and "b9be038d68abc73944890ee1f1a4c1c4513e16ba" have entirely different histories.
13aed803ae
...
b9be038d68
@ -22,7 +22,6 @@ 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
|
||||
@ -422,28 +421,37 @@ fun DashboardScreen2(
|
||||
}
|
||||
)
|
||||
}) { paddingValues ->
|
||||
LazyColumn(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(paddingValues)
|
||||
.fillMaxSize()
|
||||
) {
|
||||
item {
|
||||
AdvertisingArea(
|
||||
carouselUrls = dashboardUiState.carouselUrls,
|
||||
//top section
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(200.dp)
|
||||
)
|
||||
.weight(1f)
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
AdvertisingArea()
|
||||
}
|
||||
item {
|
||||
Spacer(Modifier.height(12.dp))
|
||||
//center section
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
SummaryCard(
|
||||
onClickLastSync = onClickLastSync,
|
||||
lastSyncTime = dashboardUiState.lastSyncTime
|
||||
)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
}
|
||||
item {
|
||||
//pager section
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1.3f)
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
MenuPager(
|
||||
items = buildMenuItems(
|
||||
onNavigateAmount = onNavigateAmount,
|
||||
@ -451,32 +459,35 @@ fun DashboardScreen2(
|
||||
onNavigateSettlement = onNavigateSettlement,
|
||||
onNavigateAction = onNavigateAction
|
||||
),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
// .height(250.dp)
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
}
|
||||
item { Spacer(Modifier.height(8.dp)) }
|
||||
recentTransactionsItems(transactions = dashboardUiState.recentTransactions)
|
||||
//transactions section
|
||||
// RecentTransactions(
|
||||
// transactions = dashboardUiState.recentTransactions,
|
||||
// modifier = Modifier
|
||||
// .weight(1.2f)
|
||||
// .fillMaxWidth()
|
||||
// )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
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 })
|
||||
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 })
|
||||
|
||||
LaunchedEffect(pageState) {
|
||||
while (true) {
|
||||
delay(10000.milliseconds)
|
||||
val nextPage = (pageState.currentPage + 1) % imageModels.size
|
||||
val nextPage = (pageState.currentPage + 1) % imageArray.size
|
||||
|
||||
pageState.animateScrollToPage(
|
||||
page = nextPage, animationSpec = tween(durationMillis = 700)
|
||||
@ -485,7 +496,7 @@ private fun AdvertisingArea(
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = modifier,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
shape = RoundedCornerShape(0.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
) {
|
||||
@ -493,7 +504,7 @@ private fun AdvertisingArea(
|
||||
state = pageState, modifier = Modifier.fillMaxSize()
|
||||
) { page ->
|
||||
AsyncImage(
|
||||
model = imageModels[page],
|
||||
model = imageArray[page],
|
||||
contentDescription = "ads images",
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop
|
||||
@ -803,9 +814,7 @@ private fun MenuPager(
|
||||
Column(modifier = modifier) {
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
// .height(236.dp)
|
||||
modifier = Modifier.weight(1f)
|
||||
) { pageIndex ->
|
||||
MenuPage(items = pages[pageIndex])
|
||||
}
|
||||
@ -839,6 +848,7 @@ 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 ->
|
||||
@ -911,8 +921,12 @@ private fun MenuCard(
|
||||
}
|
||||
}
|
||||
|
||||
private fun LazyListScope.recentTransactionsItems(transactions: List<TrnxRecord>) {
|
||||
item {
|
||||
@Composable
|
||||
private fun RecentTransactions(
|
||||
transactions: List<TrnxRecord>,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(modifier = modifier) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -929,7 +943,7 @@ private fun LazyListScope.recentTransactionsItems(transactions: List<TrnxRecord>
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
color = Color.Gray.copy(alpha = 0.2f)
|
||||
)
|
||||
}
|
||||
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
if (transactions.isEmpty()) {
|
||||
item {
|
||||
Text(
|
||||
@ -947,6 +961,8 @@ private fun LazyListScope.recentTransactionsItems(transactions: List<TrnxRecord>
|
||||
TrnxRow(record = record)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@ -12,6 +12,5 @@ data class TrnxRecord(
|
||||
|
||||
data class DashboardUiState(
|
||||
val recentTransactions: List<TrnxRecord> = emptyList(),
|
||||
val lastSyncTime: Long? = null,
|
||||
val carouselUrls: List<String> = emptyList()
|
||||
val lastSyncTime: Long? = null
|
||||
)
|
||||
|
||||
@ -6,7 +6,6 @@ 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
|
||||
@ -36,15 +35,6 @@ 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.
|
Before Width: | Height: | Size: 82 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
Loading…
Reference in New Issue
Block a user