2022-05-07 23:34:55 -04:00
|
|
|
package eu.kanade.presentation.browse
|
2022-04-30 09:37:10 -04:00
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.WindowInsets
|
|
|
|
import androidx.compose.foundation.layout.asPaddingValues
|
|
|
|
import androidx.compose.foundation.layout.navigationBars
|
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.collectAsState
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|
|
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
|
|
import eu.kanade.domain.manga.model.Manga
|
|
|
|
import eu.kanade.presentation.components.EmptyScreen
|
|
|
|
import eu.kanade.presentation.components.LoadingScreen
|
|
|
|
import eu.kanade.presentation.manga.components.BaseMangaListItem
|
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
|
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaState
|
|
|
|
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrationMangaPresenter
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun MigrateMangaScreen(
|
|
|
|
nestedScrollInterop: NestedScrollConnection,
|
|
|
|
presenter: MigrationMangaPresenter,
|
|
|
|
onClickItem: (Manga) -> Unit,
|
2022-05-10 17:54:52 -04:00
|
|
|
onClickCover: (Manga) -> Unit,
|
2022-04-30 09:37:10 -04:00
|
|
|
) {
|
|
|
|
val state by presenter.state.collectAsState()
|
|
|
|
|
|
|
|
when (state) {
|
|
|
|
MigrateMangaState.Loading -> LoadingScreen()
|
|
|
|
is MigrateMangaState.Error -> Text(text = (state as MigrateMangaState.Error).error.message!!)
|
|
|
|
is MigrateMangaState.Success -> {
|
|
|
|
MigrateMangaContent(
|
|
|
|
nestedScrollInterop = nestedScrollInterop,
|
|
|
|
list = (state as MigrateMangaState.Success).list,
|
|
|
|
onClickItem = onClickItem,
|
|
|
|
onClickCover = onClickCover,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun MigrateMangaContent(
|
|
|
|
nestedScrollInterop: NestedScrollConnection,
|
|
|
|
list: List<Manga>,
|
|
|
|
onClickItem: (Manga) -> Unit,
|
2022-05-10 17:54:52 -04:00
|
|
|
onClickCover: (Manga) -> Unit,
|
2022-04-30 09:37:10 -04:00
|
|
|
) {
|
|
|
|
if (list.isEmpty()) {
|
2022-05-07 23:34:55 -04:00
|
|
|
EmptyScreen(textResource = R.string.empty_screen)
|
2022-04-30 09:37:10 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
LazyColumn(
|
|
|
|
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
|
|
|
contentPadding = WindowInsets.navigationBars.asPaddingValues(),
|
|
|
|
) {
|
|
|
|
items(list) { manga ->
|
|
|
|
MigrateMangaItem(
|
|
|
|
manga = manga,
|
|
|
|
onClickItem = onClickItem,
|
2022-05-10 17:54:52 -04:00
|
|
|
onClickCover = onClickCover,
|
2022-04-30 09:37:10 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun MigrateMangaItem(
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
manga: Manga,
|
|
|
|
onClickItem: (Manga) -> Unit,
|
2022-05-10 17:54:52 -04:00
|
|
|
onClickCover: (Manga) -> Unit,
|
2022-04-30 09:37:10 -04:00
|
|
|
) {
|
|
|
|
BaseMangaListItem(
|
|
|
|
modifier = modifier,
|
|
|
|
manga = manga,
|
|
|
|
onClickItem = { onClickItem(manga) },
|
2022-05-10 17:54:52 -04:00
|
|
|
onClickCover = { onClickCover(manga) },
|
2022-04-30 09:37:10 -04:00
|
|
|
)
|
|
|
|
}
|