Make MigrateSourceState similar to MigrateState (#7054)

(cherry picked from commit aef1dc6eaf)
This commit is contained in:
FourTOne5
2022-05-02 08:35:34 +06:00
committed by Jobobby04
parent 222f8a7d7a
commit bb5732055e
2 changed files with 21 additions and 24 deletions
@@ -28,6 +28,7 @@ import eu.kanade.presentation.source.components.BaseSourceItem
import eu.kanade.presentation.theme.header
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrateSourceState
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesPresenter
@Composable
@@ -39,18 +40,17 @@ fun MigrateSourceScreen(
onClickAll: (Source) -> Unit,
) {
val state by presenter.state.collectAsState()
when {
state.isLoading -> LoadingScreen()
state.isEmpty -> EmptyScreen(textResource = R.string.information_empty_library)
else -> {
when (state) {
is MigrateSourceState.Loading -> LoadingScreen()
is MigrateSourceState.Error -> Text(text = (state as MigrateSourceState.Error).error.message!!)
is MigrateSourceState.Success ->
MigrateSourceList(
nestedScrollInterop = nestedScrollInterop,
list = state.sources!!,
list = (state as MigrateSourceState.Success).sources,
onClickItem = onClickItem,
onLongClickItem = onLongClickItem,
onClickAll = onClickAll
)
}
}
}
@@ -62,6 +62,11 @@ fun MigrateSourceList(
onLongClickItem: (Source) -> Unit,
onClickAll: (Source) -> Unit,
) {
if (list.isEmpty()) {
EmptyScreen(textResource = R.string.information_empty_library)
return
}
LazyColumn(
modifier = Modifier.nestedScroll(nestedScrollInterop),
contentPadding = WindowInsets.navigationBars.asPaddingValues(),