Loading screen for Upcomping/Updating screen

This commit is contained in:
Cuong-Tran 2024-10-27 23:54:02 +07:00
parent 0f4d3a7994
commit d8f6e7840b
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
2 changed files with 14 additions and 0 deletions

View file

@ -41,6 +41,7 @@ import tachiyomi.presentation.core.components.TwoPanelBox
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.components.material.padding
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.screens.LoadingScreen
import java.time.LocalDate
import java.time.YearMonth
@ -63,6 +64,7 @@ fun UpcomingScreenContent(
val headerIndexes = if (state.isShowingUpdatingMangas) state.updatingHeaderIndexes else state.headerIndexes
val items = if (state.isShowingUpdatingMangas) state.updatingItems else state.items
val events = if (state.isShowingUpdatingMangas) state.updatingEvents else state.events
val isLoading = if (state.isShowingUpdatingMangas) state.isLoadingUpdating else state.isLoadingUpcoming
// KMK <--
val onClickDay: (LocalDate, Int) -> Unit = { date, offset ->
@ -85,6 +87,12 @@ fun UpcomingScreenContent(
},
modifier = modifier,
) { paddingValues ->
// KMK -->
if (isLoading) {
LoadingScreen(modifier = Modifier.padding(paddingValues))
return@Scaffold
}
// KMK <--
if (isTabletUi()) {
UpcomingScreenLargeImpl(
listState = listState,

View file

@ -36,6 +36,9 @@ class UpcomingScreenModel(
mutableState.update { state ->
val upcomingItems = it.toUpcomingUIModels()
state.copy(
// KMK -->
isLoadingUpcoming = false,
// KMK <--
items = upcomingItems,
events = upcomingItems.toEvents(),
headerIndexes = upcomingItems.getHeaderIndexes(),
@ -48,6 +51,7 @@ class UpcomingScreenModel(
mutableState.update { state ->
val updatingItems = getUpcomingManga.updatingMangas().toUpcomingUIModels()
state.copy(
isLoadingUpdating = false,
updatingItems = updatingItems,
updatingEvents = updatingItems.toEvents(),
updatingHeaderIndexes = updatingItems.getHeaderIndexes(),
@ -123,10 +127,12 @@ class UpcomingScreenModel(
val events: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val headerIndexes: ImmutableMap<LocalDate, Int> = persistentMapOf(),
// KMK -->
val isLoadingUpcoming: Boolean = true,
val isShowingUpdatingMangas: Boolean = false,
val updatingItems: ImmutableList<UpcomingUIModel> = persistentListOf(),
val updatingEvents: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val updatingHeaderIndexes: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val isLoadingUpdating: Boolean = true,
// KMK <--
)
}