Move SmartSearchConfig around

This commit is contained in:
Jobobby04 2022-12-03 00:19:24 -05:00
parent 8e2f5aa495
commit 07c7ec972d
11 changed files with 28 additions and 57 deletions

View File

@ -1,23 +0,0 @@
package eu.kanade.tachiyomi.ui.browse.source
import android.os.Bundle
import androidx.compose.runtime.Composable
import cafe.adriel.voyager.navigator.Navigator
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
import eu.kanade.tachiyomi.util.system.getSerializableCompat
import java.io.Serializable
class SourcesController(bundle: Bundle? = null) : BasicFullComposeController(bundle) {
private val smartSearchConfig = args.getSerializableCompat<SmartSearchConfig>(SMART_SEARCH_CONFIG)
@Composable
override fun ComposeContent() {
Navigator(screen = SourcesScreen(smartSearchConfig))
}
data class SmartSearchConfig(val origTitle: String, val origMangaId: Long? = null) : Serializable
companion object {
const val SMART_SEARCH_CONFIG = "SMART_SEARCH_CONFIG"
}
}

View File

@ -3,11 +3,14 @@ package eu.kanade.tachiyomi.ui.browse.source
import androidx.compose.runtime.Composable
import cafe.adriel.voyager.core.screen.Screen
import eu.kanade.presentation.browse.BrowseTabWrapper
import java.io.Serializable
class SourcesScreen(private val smartSearchConfig: SourcesController.SmartSearchConfig?) : Screen {
class SourcesScreen(private val smartSearchConfig: SmartSearchConfig?) : Screen {
@Composable
override fun Content() {
BrowseTabWrapper(sourcesTab(smartSearchConfig))
}
data class SmartSearchConfig(val origTitle: String, val origMangaId: Long? = null) : Serializable
}

View File

@ -43,7 +43,7 @@ class SourcesScreenModel(
private val getShowLatest: GetShowLatest = Injekt.get(),
private val toggleExcludeFromDataSaver: ToggleExcludeFromDataSaver = Injekt.get(),
private val setSourceCategories: SetSourceCategories = Injekt.get(),
val smartSearchConfig: SourcesController.SmartSearchConfig?,
val smartSearchConfig: SourcesScreen.SmartSearchConfig?,
// SY <--
) : StateScreenModel<SourcesState>(SourcesState()) {

View File

@ -20,7 +20,7 @@ import eu.kanade.presentation.components.TabContent
import eu.kanade.presentation.util.LocalRouter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.pushController
import eu.kanade.tachiyomi.ui.browse.source.SourcesController.SmartSearchConfig
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen.SmartSearchConfig
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.globalsearch.GlobalSearchController

View File

@ -8,7 +8,7 @@ import cafe.adriel.voyager.navigator.Navigator
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.consumeAsFlow
@ -20,7 +20,7 @@ class BrowseSourceController(bundle: Bundle) : BasicFullComposeController(bundle
sourceId: Long,
query: String? = null,
// SY -->
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
smartSearchConfig: SourcesScreen.SmartSearchConfig? = null,
savedSearch: Long? = null,
filterList: String? = null,
// SY <--
@ -51,7 +51,7 @@ class BrowseSourceController(bundle: Bundle) : BasicFullComposeController(bundle
source: CatalogueSource,
query: String? = null,
// SY -->
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
smartSearchConfig: SourcesScreen.SmartSearchConfig? = null,
savedSearch: Long? = null,
filterList: String? = null,
// SY <--
@ -67,7 +67,7 @@ class BrowseSourceController(bundle: Bundle) : BasicFullComposeController(bundle
source: Source,
query: String? = null,
// SY -->
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
smartSearchConfig: SourcesScreen.SmartSearchConfig? = null,
savedSearch: Long? = null,
filterList: String? = null,
// SY <--

View File

@ -5,7 +5,7 @@ import androidx.compose.runtime.Composable
import androidx.core.os.bundleOf
import cafe.adriel.voyager.navigator.Navigator
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
import eu.kanade.tachiyomi.util.system.getSerializableCompat
class MangaController : BasicFullComposeController {
@ -16,7 +16,7 @@ class MangaController : BasicFullComposeController {
constructor(
mangaId: Long,
fromSource: Boolean = false,
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
smartSearchConfig: SourcesScreen.SmartSearchConfig? = null,
) : super(bundleOf(MANGA_EXTRA to mangaId, FROM_SOURCE_EXTRA to fromSource, SMART_SEARCH_CONFIG_EXTRA to smartSearchConfig))
// SY -->
@ -32,7 +32,7 @@ class MangaController : BasicFullComposeController {
get() = args.getBoolean(FROM_SOURCE_EXTRA)
// SY -->
val smartSearchConfig: SourcesController.SmartSearchConfig?
val smartSearchConfig: SourcesScreen.SmartSearchConfig?
get() = args.getSerializableCompat(SMART_SEARCH_CONFIG_EXTRA)
// SY <--

View File

@ -58,7 +58,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.controller.pushController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.migration.advanced.design.PreMigrationScreen
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.browse.source.feed.SourceFeedController
@ -96,7 +95,7 @@ import uy.kohesive.injekt.api.get
class MangaScreen(
private val mangaId: Long,
private val fromSource: Boolean = false,
private val smartSearchConfig: SourcesController.SmartSearchConfig? = null,
private val smartSearchConfig: SourcesScreen.SmartSearchConfig? = null,
) : Screen {
override val key = uniqueScreenKey
@ -497,7 +496,7 @@ class MangaScreen(
// EXH -->
private fun openSmartSearch(navigator: Navigator, manga: Manga) {
val smartSearchConfig = SourcesController.SmartSearchConfig(manga.title, manga.id)
val smartSearchConfig = SourcesScreen.SmartSearchConfig(manga.title, manga.id)
navigator.push(SourcesScreen(smartSearchConfig))
}

View File

@ -7,20 +7,18 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalConfiguration
import androidx.core.os.bundleOf
import androidx.paging.compose.collectAsLazyPagingItems
import cafe.adriel.voyager.core.model.rememberScreenModel
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.currentOrThrow
import com.bluelinelabs.conductor.Router
import eu.kanade.domain.manga.model.Manga
import eu.kanade.presentation.browse.BrowseSourceContent
import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar
import eu.kanade.presentation.components.Scaffold
import eu.kanade.presentation.util.LocalRouter
import eu.kanade.tachiyomi.ui.base.controller.pushController
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen {
@ -32,7 +30,7 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen {
val navigator = LocalNavigator.currentOrThrow
val onMangaClick: (Manga) -> Unit = { manga ->
openSmartSearch(router, manga.ogTitle)
openSmartSearch(navigator, manga.ogTitle)
}
val snackbarHostState = remember { SnackbarHostState() }
@ -79,14 +77,8 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen {
}
}
private fun openSmartSearch(router: Router, title: String) {
val smartSearchConfig = SourcesController.SmartSearchConfig(title)
router.pushController(
SourcesController(
bundleOf(
SourcesController.SMART_SEARCH_CONFIG to smartSearchConfig,
),
),
)
private fun openSmartSearch(navigator: Navigator, title: String) {
val smartSearchConfig = SourcesScreen.SmartSearchConfig(title)
navigator.push(SourcesScreen(smartSearchConfig))
}
}

View File

@ -5,14 +5,14 @@ import androidx.compose.runtime.Composable
import androidx.core.os.bundleOf
import cafe.adriel.voyager.navigator.Navigator
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
import eu.kanade.tachiyomi.util.system.getSerializableCompat
class SmartSearchController(bundle: Bundle) : BasicFullComposeController() {
private val sourceId = bundle.getLong(ARG_SOURCE_ID, -1)
private val smartSearchConfig = bundle.getSerializableCompat<SourcesController.SmartSearchConfig>(ARG_SMART_SEARCH_CONFIG)!!
private val smartSearchConfig = bundle.getSerializableCompat<SourcesScreen.SmartSearchConfig>(ARG_SMART_SEARCH_CONFIG)!!
constructor(sourceId: Long, smartSearchConfig: SourcesController.SmartSearchConfig) : this(
constructor(sourceId: Long, smartSearchConfig: SourcesScreen.SmartSearchConfig) : this(
bundleOf(
ARG_SOURCE_ID to sourceId,
ARG_SMART_SEARCH_CONFIG to smartSearchConfig,

View File

@ -25,12 +25,12 @@ import eu.kanade.presentation.components.Scaffold
import eu.kanade.presentation.util.LocalRouter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.system.toast
class SmartSearchScreen(private val sourceId: Long, private val smartSearchConfig: SourcesController.SmartSearchConfig) : Screen {
class SmartSearchScreen(private val sourceId: Long, private val smartSearchConfig: SourcesScreen.SmartSearchConfig) : Screen {
@Composable
override fun Content() {

View File

@ -6,7 +6,7 @@ import eu.kanade.domain.manga.interactor.NetworkToLocalManga
import eu.kanade.domain.manga.model.Manga
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
import eu.kanade.tachiyomi.util.lang.launchIO
import exh.smartsearch.SmartSearchEngine
import kotlinx.coroutines.CancellationException
@ -15,7 +15,7 @@ import uy.kohesive.injekt.api.get
class SmartSearchScreenModel(
private val sourceId: Long,
private val config: SourcesController.SmartSearchConfig,
private val config: SourcesScreen.SmartSearchConfig,
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
private val sourceManager: SourceManager = Injekt.get(),
) : StateScreenModel<SmartSearchScreenModel.SearchResults?>(null) {