|
@@ -4,31 +4,24 @@ import androidx.compose.foundation.layout.PaddingValues
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.runtime.Composable
|
|
|
-import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.ui.Modifier
|
|
|
-import androidx.compose.ui.platform.LocalContext
|
|
|
import eu.kanade.domain.manga.model.Manga
|
|
|
import eu.kanade.presentation.components.AppBar
|
|
|
import eu.kanade.presentation.components.EmptyScreen
|
|
|
import eu.kanade.presentation.components.FastScrollLazyColumn
|
|
|
-import eu.kanade.presentation.components.LoadingScreen
|
|
|
import eu.kanade.presentation.components.Scaffold
|
|
|
import eu.kanade.presentation.manga.components.BaseMangaListItem
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
-import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaPresenter
|
|
|
-import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaPresenter.Event
|
|
|
-import eu.kanade.tachiyomi.util.system.toast
|
|
|
-import kotlinx.coroutines.flow.collectLatest
|
|
|
+import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaState
|
|
|
|
|
|
@Composable
|
|
|
fun MigrateMangaScreen(
|
|
|
navigateUp: () -> Unit,
|
|
|
title: String?,
|
|
|
- presenter: MigrateMangaPresenter,
|
|
|
+ state: MigrateMangaState,
|
|
|
onClickItem: (Manga) -> Unit,
|
|
|
onClickCover: (Manga) -> Unit,
|
|
|
) {
|
|
|
- val context = LocalContext.current
|
|
|
Scaffold(
|
|
|
topBar = { scrollBehavior ->
|
|
|
AppBar(
|
|
@@ -38,30 +31,20 @@ fun MigrateMangaScreen(
|
|
|
)
|
|
|
},
|
|
|
) { contentPadding ->
|
|
|
- when {
|
|
|
- presenter.isLoading -> LoadingScreen()
|
|
|
- presenter.isEmpty -> EmptyScreen(
|
|
|
+ if (state.isEmpty) {
|
|
|
+ EmptyScreen(
|
|
|
textResource = R.string.empty_screen,
|
|
|
modifier = Modifier.padding(contentPadding),
|
|
|
)
|
|
|
- else -> {
|
|
|
- MigrateMangaContent(
|
|
|
- contentPadding = contentPadding,
|
|
|
- state = presenter,
|
|
|
- onClickItem = onClickItem,
|
|
|
- onClickCover = onClickCover,
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- LaunchedEffect(Unit) {
|
|
|
- presenter.events.collectLatest { event ->
|
|
|
- when (event) {
|
|
|
- Event.FailedFetchingFavorites -> {
|
|
|
- context.toast(R.string.internal_error)
|
|
|
- }
|
|
|
- }
|
|
|
+ return@Scaffold
|
|
|
}
|
|
|
+
|
|
|
+ MigrateMangaContent(
|
|
|
+ contentPadding = contentPadding,
|
|
|
+ state = state,
|
|
|
+ onClickItem = onClickItem,
|
|
|
+ onClickCover = onClickCover,
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -75,7 +58,7 @@ private fun MigrateMangaContent(
|
|
|
FastScrollLazyColumn(
|
|
|
contentPadding = contentPadding,
|
|
|
) {
|
|
|
- items(state.items) { manga ->
|
|
|
+ items(state.titles) { manga ->
|
|
|
MigrateMangaItem(
|
|
|
manga = manga,
|
|
|
onClickItem = onClickItem,
|