Use Voyager between more screens

(cherry picked from commit 5c9e9bd2c4647da189d7313f2ee206541e65f409)

# Conflicts:
#	app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt
This commit is contained in:
arkon 2022-11-26 09:34:06 -05:00 committed by Jobobby04
parent da1bf0f3f7
commit 44c324f145
2 changed files with 12 additions and 14 deletions

View File

@ -32,8 +32,9 @@ import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastMap import androidx.compose.ui.util.fastMap
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.currentOrThrow import cafe.adriel.voyager.navigator.currentOrThrow
import com.bluelinelabs.conductor.Router
import com.commandiron.wheel_picker_compose.WheelPicker import com.commandiron.wheel_picker_compose.WheelPicker
import eu.kanade.domain.UnsortedPreferences import eu.kanade.domain.UnsortedPreferences
import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.GetCategories
@ -44,7 +45,6 @@ import eu.kanade.domain.library.service.LibraryPreferences
import eu.kanade.presentation.category.visualName import eu.kanade.presentation.category.visualName
import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.widget.TriStateListDialog import eu.kanade.presentation.more.settings.widget.TriStateListDialog
import eu.kanade.presentation.util.LocalRouter
import eu.kanade.presentation.util.collectAsState import eu.kanade.presentation.util.collectAsState
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
@ -56,9 +56,8 @@ import eu.kanade.tachiyomi.data.preference.MANGA_HAS_UNREAD
import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED import eu.kanade.tachiyomi.data.preference.MANGA_NON_COMPLETED
import eu.kanade.tachiyomi.data.preference.MANGA_NON_READ import eu.kanade.tachiyomi.data.preference.MANGA_NON_READ
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.ui.base.controller.pushController import eu.kanade.tachiyomi.ui.category.CategoryScreen
import eu.kanade.tachiyomi.ui.category.CategoryController import eu.kanade.tachiyomi.ui.category.genre.SortTagScreen
import eu.kanade.tachiyomi.ui.category.genre.SortTagController
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
@ -82,10 +81,10 @@ object SettingsLibraryScreen : SearchableSettings {
return mutableListOf( return mutableListOf(
getDisplayGroup(libraryPreferences), getDisplayGroup(libraryPreferences),
getCategoriesGroup(LocalRouter.currentOrThrow, allCategories, libraryPreferences), getCategoriesGroup(LocalNavigator.currentOrThrow, allCategories, libraryPreferences),
getGlobalUpdateGroup(allCategories, libraryPreferences), getGlobalUpdateGroup(allCategories, libraryPreferences),
// SY --> // SY -->
getSortingCategory(libraryPreferences), getSortingCategory(LocalNavigator.currentOrThrow, libraryPreferences),
getMigrationCategory(unsortedPreferences), getMigrationCategory(unsortedPreferences),
// SY <-- // SY <--
) )
@ -126,7 +125,7 @@ object SettingsLibraryScreen : SearchableSettings {
@Composable @Composable
private fun getCategoriesGroup( private fun getCategoriesGroup(
router: Router?, navigator: Navigator,
allCategories: List<Category>, allCategories: List<Category>,
libraryPreferences: LibraryPreferences, libraryPreferences: LibraryPreferences,
): Preference.PreferenceGroup { ): Preference.PreferenceGroup {
@ -153,7 +152,7 @@ object SettingsLibraryScreen : SearchableSettings {
count = userCategoriesCount, count = userCategoriesCount,
userCategoriesCount, userCategoriesCount,
), ),
onClick = { router?.pushController(CategoryController()) }, onClick = { navigator.push(CategoryScreen()) },
), ),
Preference.PreferenceItem.ListPreference( Preference.PreferenceItem.ListPreference(
pref = libraryPreferences.defaultCategory(), pref = libraryPreferences.defaultCategory(),
@ -423,8 +422,7 @@ object SettingsLibraryScreen : SearchableSettings {
// SY --> // SY -->
@Composable @Composable
fun getSortingCategory(libraryPreferences: LibraryPreferences): Preference.PreferenceGroup { fun getSortingCategory(navigator: Navigator, libraryPreferences: LibraryPreferences): Preference.PreferenceGroup {
val router = LocalRouter.current
val tagCount by libraryPreferences.sortTagsForLibrary().collectAsState() val tagCount by libraryPreferences.sortTagsForLibrary().collectAsState()
return Preference.PreferenceGroup( return Preference.PreferenceGroup(
stringResource(R.string.pref_sorting_settings), stringResource(R.string.pref_sorting_settings),
@ -433,7 +431,7 @@ object SettingsLibraryScreen : SearchableSettings {
title = stringResource(R.string.pref_tag_sorting), title = stringResource(R.string.pref_tag_sorting),
subtitle = pluralStringResource(R.plurals.pref_tag_sorting_desc, tagCount.size, tagCount.size), subtitle = pluralStringResource(R.plurals.pref_tag_sorting_desc, tagCount.size, tagCount.size),
onClick = { onClick = {
router?.pushController(SortTagController()) navigator.push(SortTagScreen())
}, },
), ),
), ),

View File

@ -65,7 +65,7 @@ import eu.kanade.tachiyomi.ui.browse.source.SourcesController.Companion.SMART_SE
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.browse.source.feed.SourceFeedController import eu.kanade.tachiyomi.ui.browse.source.feed.SourceFeedController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.category.CategoryController import eu.kanade.tachiyomi.ui.category.CategoryScreen
import eu.kanade.tachiyomi.ui.history.HistoryController import eu.kanade.tachiyomi.ui.history.HistoryController
import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
@ -195,7 +195,7 @@ class MangaScreen(
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
onEditCategories = { router.pushController(CategoryController()) }, onEditCategories = { navigator.push(CategoryScreen()) },
onConfirm = { include, _ -> onConfirm = { include, _ ->
screenModel.moveMangaToCategoriesAndAddToLibrary(dialog.manga, include) screenModel.moveMangaToCategoriesAndAddToLibrary(dialog.manga, include)
}, },