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
+6 -14
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))
}
}
@@ -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,
@@ -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() {
@@ -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) {