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.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
|
||||||
@ -422,28 +421,37 @@ fun DashboardScreen2(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}) { paddingValues ->
|
}) { paddingValues ->
|
||||||
LazyColumn(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
item {
|
//top section
|
||||||
AdvertisingArea(
|
Box(
|
||||||
carouselUrls = dashboardUiState.carouselUrls,
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.weight(1f)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth(),
|
||||||
.height(200.dp)
|
) {
|
||||||
)
|
AdvertisingArea()
|
||||||
}
|
}
|
||||||
item {
|
//center section
|
||||||
Spacer(Modifier.height(12.dp))
|
Box(
|
||||||
|
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))
|
|
||||||
}
|
}
|
||||||
item {
|
//pager section
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1.3f)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
) {
|
||||||
MenuPager(
|
MenuPager(
|
||||||
items = buildMenuItems(
|
items = buildMenuItems(
|
||||||
onNavigateAmount = onNavigateAmount,
|
onNavigateAmount = onNavigateAmount,
|
||||||
@ -451,32 +459,35 @@ fun DashboardScreen2(
|
|||||||
onNavigateSettlement = onNavigateSettlement,
|
onNavigateSettlement = onNavigateSettlement,
|
||||||
onNavigateAction = onNavigateAction
|
onNavigateAction = onNavigateAction
|
||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxSize()
|
||||||
.fillMaxWidth()
|
|
||||||
// .height(250.dp)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
item { Spacer(Modifier.height(8.dp)) }
|
//transactions section
|
||||||
recentTransactionsItems(transactions = dashboardUiState.recentTransactions)
|
// RecentTransactions(
|
||||||
|
// transactions = dashboardUiState.recentTransactions,
|
||||||
|
// modifier = Modifier
|
||||||
|
// .weight(1.2f)
|
||||||
|
// .fillMaxWidth()
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AdvertisingArea(
|
private fun AdvertisingArea() {
|
||||||
carouselUrls: List<String> = emptyList(),
|
|
||||||
modifier: Modifier = Modifier
|
val imageArray = listOf(
|
||||||
) {
|
"https://i.ytimg.com/vi/eRUVxGRp1Ms/maxresdefault.jpg",
|
||||||
val imageModels: List<Any> = carouselUrls.ifEmpty {
|
"https://i.ytimg.com/vi/AwvmgTPd7qw/maxresdefault.jpg",
|
||||||
listOf(R.drawable.sunmi1, R.drawable.sunmi2, R.drawable.sunmi3)
|
"https://mma.prnewswire.com/media/2080956/SUNMI_3rd_generation_products_T3_PRO_series_V3_MIX.jpg?p=facebook"
|
||||||
}
|
)
|
||||||
val pageState = rememberPagerState(pageCount = { imageModels.size })
|
val pageState = rememberPagerState(pageCount = { imageArray.size })
|
||||||
|
|
||||||
LaunchedEffect(pageState) {
|
LaunchedEffect(pageState) {
|
||||||
while (true) {
|
while (true) {
|
||||||
delay(10000.milliseconds)
|
delay(10000.milliseconds)
|
||||||
val nextPage = (pageState.currentPage + 1) % imageModels.size
|
val nextPage = (pageState.currentPage + 1) % imageArray.size
|
||||||
|
|
||||||
pageState.animateScrollToPage(
|
pageState.animateScrollToPage(
|
||||||
page = nextPage, animationSpec = tween(durationMillis = 700)
|
page = nextPage, animationSpec = tween(durationMillis = 700)
|
||||||
@ -485,7 +496,7 @@ private fun AdvertisingArea(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier,
|
modifier = Modifier.fillMaxSize(),
|
||||||
shape = RoundedCornerShape(0.dp),
|
shape = RoundedCornerShape(0.dp),
|
||||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||||
) {
|
) {
|
||||||
@ -493,7 +504,7 @@ private fun AdvertisingArea(
|
|||||||
state = pageState, modifier = Modifier.fillMaxSize()
|
state = pageState, modifier = Modifier.fillMaxSize()
|
||||||
) { page ->
|
) { page ->
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = imageModels[page],
|
model = imageArray[page],
|
||||||
contentDescription = "ads images",
|
contentDescription = "ads images",
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
contentScale = ContentScale.Crop
|
contentScale = ContentScale.Crop
|
||||||
@ -803,9 +814,7 @@ private fun MenuPager(
|
|||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
HorizontalPager(
|
HorizontalPager(
|
||||||
state = pagerState,
|
state = pagerState,
|
||||||
modifier = Modifier
|
modifier = Modifier.weight(1f)
|
||||||
.fillMaxWidth()
|
|
||||||
// .height(236.dp)
|
|
||||||
) { pageIndex ->
|
) { pageIndex ->
|
||||||
MenuPage(items = pages[pageIndex])
|
MenuPage(items = pages[pageIndex])
|
||||||
}
|
}
|
||||||
@ -839,6 +848,7 @@ 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 ->
|
||||||
@ -911,8 +921,12 @@ private fun MenuCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LazyListScope.recentTransactionsItems(transactions: List<TrnxRecord>) {
|
@Composable
|
||||||
item {
|
private fun RecentTransactions(
|
||||||
|
transactions: List<TrnxRecord>,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
Column(modifier = modifier) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@ -929,22 +943,24 @@ private fun LazyListScope.recentTransactionsItems(transactions: List<TrnxRecord>
|
|||||||
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(
|
||||||
text = "No recent transactions",
|
text = "No recent transactions",
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
fontSize = 13.sp,
|
fontSize = 13.sp,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 24.dp)
|
.padding(vertical = 24.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
items(items = transactions, key = { it.pid }) { record ->
|
items(items = transactions, key = { it.pid }) { record ->
|
||||||
TrnxRow(record = record)
|
TrnxRow(record = record)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,5 @@ 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()
|
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,7 +6,6 @@ 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
|
||||||
@ -36,15 +35,6 @@ 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.
|
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