Skip to content

Commit

Permalink
Loading screen for Upcomping/Updating screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Oct 28, 2024
1 parent 13d6ba2 commit a378124
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 ->
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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 <--
)
}

0 comments on commit a378124

Please sign in to comment.