image array get from tms
This commit is contained in:
parent
4fb6556d1b
commit
13aed803ae
@ -429,6 +429,7 @@ fun DashboardScreen2(
|
|||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
AdvertisingArea(
|
AdvertisingArea(
|
||||||
|
carouselUrls = dashboardUiState.carouselUrls,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(200.dp)
|
.height(200.dp)
|
||||||
@ -463,19 +464,19 @@ fun DashboardScreen2(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AdvertisingArea(modifier: Modifier = Modifier) {
|
private fun AdvertisingArea(
|
||||||
|
carouselUrls: List<String> = emptyList(),
|
||||||
val imageArray = listOf(
|
modifier: Modifier = Modifier
|
||||||
R.drawable.sunmi1,
|
) {
|
||||||
R.drawable.sunmi2,
|
val imageModels: List<Any> = carouselUrls.ifEmpty {
|
||||||
R.drawable.sunmi3
|
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)
|
||||||
@ -492,7 +493,7 @@ private fun AdvertisingArea(modifier: Modifier = Modifier) {
|
|||||||
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
|
||||||
|
|||||||
@ -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()
|
||||||
)
|
)
|
||||||
|
|||||||
@ -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() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user