mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 11:09:19 +01:00
Migrate more screens to full Compose
This commit is contained in:
parent
459b369feb
commit
cbfe9c30bb
@ -1,20 +1,24 @@
|
|||||||
package eu.kanade.presentation.browse
|
package eu.kanade.presentation.browse
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.asPaddingValues
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
import androidx.compose.foundation.layout.navigationBars
|
import androidx.compose.foundation.layout.navigationBars
|
||||||
|
import androidx.compose.foundation.layout.statusBarsPadding
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.EmptyScreen
|
import eu.kanade.presentation.components.EmptyScreen
|
||||||
import eu.kanade.presentation.components.LazyColumn
|
import eu.kanade.presentation.components.LazyColumn
|
||||||
import eu.kanade.presentation.components.LoadingScreen
|
import eu.kanade.presentation.components.LoadingScreen
|
||||||
import eu.kanade.presentation.components.PreferenceRow
|
import eu.kanade.presentation.components.PreferenceRow
|
||||||
|
import eu.kanade.presentation.components.Scaffold
|
||||||
|
import eu.kanade.presentation.util.plus
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionFilterPresenter
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionFilterPresenter
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
@ -23,21 +27,31 @@ import kotlinx.coroutines.flow.collectLatest
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ExtensionFilterScreen(
|
fun ExtensionFilterScreen(
|
||||||
nestedScrollInterop: NestedScrollConnection,
|
navigateUp: () -> Unit,
|
||||||
presenter: ExtensionFilterPresenter,
|
presenter: ExtensionFilterPresenter,
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
when {
|
Scaffold(
|
||||||
presenter.isLoading -> LoadingScreen()
|
modifier = Modifier.statusBarsPadding(),
|
||||||
presenter.isEmpty -> EmptyScreen(textResource = R.string.empty_screen)
|
topBar = {
|
||||||
else -> {
|
AppBar(
|
||||||
SourceFilterContent(
|
title = stringResource(R.string.label_extensions),
|
||||||
nestedScrollInterop = nestedScrollInterop,
|
navigateUp = navigateUp,
|
||||||
state = presenter,
|
|
||||||
onClickLang = {
|
|
||||||
presenter.toggleLanguage(it)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
) { paddingValues ->
|
||||||
|
when {
|
||||||
|
presenter.isLoading -> LoadingScreen()
|
||||||
|
presenter.isEmpty -> EmptyScreen(textResource = R.string.empty_screen)
|
||||||
|
else -> {
|
||||||
|
SourceFilterContent(
|
||||||
|
paddingValues = paddingValues,
|
||||||
|
state = presenter,
|
||||||
|
onClickLang = {
|
||||||
|
presenter.toggleLanguage(it)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
@ -53,13 +67,12 @@ fun ExtensionFilterScreen(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SourceFilterContent(
|
fun SourceFilterContent(
|
||||||
nestedScrollInterop: NestedScrollConnection,
|
paddingValues: PaddingValues,
|
||||||
state: ExtensionFilterState,
|
state: ExtensionFilterState,
|
||||||
onClickLang: (String) -> Unit,
|
onClickLang: (String) -> Unit,
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
contentPadding = paddingValues + WindowInsets.navigationBars.asPaddingValues(),
|
||||||
contentPadding = WindowInsets.navigationBars.asPaddingValues(),
|
|
||||||
) {
|
) {
|
||||||
items(
|
items(
|
||||||
items = state.items,
|
items = state.items,
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
package eu.kanade.presentation.browse
|
package eu.kanade.presentation.browse
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.asPaddingValues
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
import androidx.compose.foundation.layout.navigationBars
|
import androidx.compose.foundation.layout.navigationBars
|
||||||
|
import androidx.compose.foundation.layout.statusBarsPadding
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.EmptyScreen
|
import eu.kanade.presentation.components.EmptyScreen
|
||||||
import eu.kanade.presentation.components.LoadingScreen
|
import eu.kanade.presentation.components.LoadingScreen
|
||||||
|
import eu.kanade.presentation.components.Scaffold
|
||||||
import eu.kanade.presentation.components.ScrollbarLazyColumn
|
import eu.kanade.presentation.components.ScrollbarLazyColumn
|
||||||
import eu.kanade.presentation.manga.components.BaseMangaListItem
|
import eu.kanade.presentation.manga.components.BaseMangaListItem
|
||||||
|
import eu.kanade.presentation.util.plus
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaPresenter
|
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaPresenter
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaPresenter.Event
|
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaPresenter.Event
|
||||||
@ -23,22 +26,33 @@ import kotlinx.coroutines.flow.collectLatest
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MigrateMangaScreen(
|
fun MigrateMangaScreen(
|
||||||
nestedScrollInterop: NestedScrollConnection,
|
navigateUp: () -> Unit,
|
||||||
|
title: String?,
|
||||||
presenter: MigrateMangaPresenter,
|
presenter: MigrateMangaPresenter,
|
||||||
onClickItem: (Manga) -> Unit,
|
onClickItem: (Manga) -> Unit,
|
||||||
onClickCover: (Manga) -> Unit,
|
onClickCover: (Manga) -> Unit,
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
when {
|
Scaffold(
|
||||||
presenter.isLoading -> LoadingScreen()
|
modifier = Modifier.statusBarsPadding(),
|
||||||
presenter.isEmpty -> EmptyScreen(textResource = R.string.empty_screen)
|
topBar = {
|
||||||
else -> {
|
AppBar(
|
||||||
MigrateMangaContent(
|
title = title,
|
||||||
nestedScrollInterop = nestedScrollInterop,
|
navigateUp = navigateUp,
|
||||||
state = presenter,
|
|
||||||
onClickItem = onClickItem,
|
|
||||||
onClickCover = onClickCover,
|
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
) { paddingValues ->
|
||||||
|
when {
|
||||||
|
presenter.isLoading -> LoadingScreen()
|
||||||
|
presenter.isEmpty -> EmptyScreen(textResource = R.string.empty_screen)
|
||||||
|
else -> {
|
||||||
|
MigrateMangaContent(
|
||||||
|
paddingValues = paddingValues,
|
||||||
|
state = presenter,
|
||||||
|
onClickItem = onClickItem,
|
||||||
|
onClickCover = onClickCover,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
@ -54,14 +68,13 @@ fun MigrateMangaScreen(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MigrateMangaContent(
|
fun MigrateMangaContent(
|
||||||
nestedScrollInterop: NestedScrollConnection,
|
paddingValues: PaddingValues,
|
||||||
state: MigrateMangaState,
|
state: MigrateMangaState,
|
||||||
onClickItem: (Manga) -> Unit,
|
onClickItem: (Manga) -> Unit,
|
||||||
onClickCover: (Manga) -> Unit,
|
onClickCover: (Manga) -> Unit,
|
||||||
) {
|
) {
|
||||||
ScrollbarLazyColumn(
|
ScrollbarLazyColumn(
|
||||||
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
contentPadding = paddingValues + WindowInsets.navigationBars.asPaddingValues(),
|
||||||
contentPadding = WindowInsets.navigationBars.asPaddingValues(),
|
|
||||||
) {
|
) {
|
||||||
items(state.items) { manga ->
|
items(state.items) { manga ->
|
||||||
MigrateMangaItem(
|
MigrateMangaItem(
|
||||||
|
@ -1,21 +1,17 @@
|
|||||||
package eu.kanade.tachiyomi.ui.browse.extension
|
package eu.kanade.tachiyomi.ui.browse.extension
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|
||||||
import eu.kanade.presentation.browse.ExtensionFilterScreen
|
import eu.kanade.presentation.browse.ExtensionFilterScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.ui.base.controller.FullComposeController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
|
|
||||||
|
|
||||||
class ExtensionFilterController : ComposeController<ExtensionFilterPresenter>() {
|
class ExtensionFilterController : FullComposeController<ExtensionFilterPresenter>() {
|
||||||
|
|
||||||
override fun getTitle() = resources?.getString(R.string.label_extensions)
|
override fun createPresenter() = ExtensionFilterPresenter()
|
||||||
|
|
||||||
override fun createPresenter(): ExtensionFilterPresenter = ExtensionFilterPresenter()
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
override fun ComposeContent() {
|
||||||
ExtensionFilterScreen(
|
ExtensionFilterScreen(
|
||||||
nestedScrollInterop = nestedScrollInterop,
|
navigateUp = router::popCurrentController,
|
||||||
presenter = presenter,
|
presenter = presenter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,14 @@ package eu.kanade.tachiyomi.ui.browse.migration.manga
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import eu.kanade.presentation.browse.MigrateMangaScreen
|
import eu.kanade.presentation.browse.MigrateMangaScreen
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
|
import eu.kanade.tachiyomi.ui.base.controller.FullComposeController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.search.SearchController
|
import eu.kanade.tachiyomi.ui.browse.migration.search.SearchController
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
|
|
||||||
class MigrationMangaController : ComposeController<MigrateMangaPresenter> {
|
class MigrationMangaController : FullComposeController<MigrateMangaPresenter> {
|
||||||
|
|
||||||
constructor(sourceId: Long, sourceName: String?) : super(
|
constructor(sourceId: Long, sourceName: String?) : super(
|
||||||
bundleOf(
|
bundleOf(
|
||||||
@ -28,14 +27,13 @@ class MigrationMangaController : ComposeController<MigrateMangaPresenter> {
|
|||||||
private val sourceId: Long = args.getLong(SOURCE_ID_EXTRA)
|
private val sourceId: Long = args.getLong(SOURCE_ID_EXTRA)
|
||||||
private val sourceName: String? = args.getString(SOURCE_NAME_EXTRA)
|
private val sourceName: String? = args.getString(SOURCE_NAME_EXTRA)
|
||||||
|
|
||||||
override fun getTitle(): String? = sourceName
|
override fun createPresenter() = MigrateMangaPresenter(sourceId)
|
||||||
|
|
||||||
override fun createPresenter(): MigrateMangaPresenter = MigrateMangaPresenter(sourceId)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
override fun ComposeContent() {
|
||||||
MigrateMangaScreen(
|
MigrateMangaScreen(
|
||||||
nestedScrollInterop = nestedScrollInterop,
|
navigateUp = router::popCurrentController,
|
||||||
|
title = sourceName,
|
||||||
presenter = presenter,
|
presenter = presenter,
|
||||||
onClickItem = {
|
onClickItem = {
|
||||||
router.pushController(SearchController(it.id))
|
router.pushController(SearchController(it.id))
|
||||||
|
Loading…
Reference in New Issue
Block a user