feat(ui): Improve navigation flow when click on manga's source
This commit is contained in:
parent
5d9a7a1189
commit
43852b8b79
7 changed files with 44 additions and 1 deletions
|
|
@ -37,6 +37,9 @@ import tachiyomi.presentation.core.components.material.Scaffold
|
|||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
import tachiyomi.source.local.LocalSource
|
||||
|
||||
/**
|
||||
* Opened when click on a source in [MigrateSearchScreen]
|
||||
*/
|
||||
data class SourceSearchScreen(
|
||||
private val oldManga: Manga,
|
||||
private val sourceId: Long,
|
||||
|
|
|
|||
|
|
@ -3,13 +3,24 @@ package eu.kanade.tachiyomi.ui.browse.source
|
|||
import androidx.compose.runtime.Composable
|
||||
import eu.kanade.presentation.browse.BrowseTabWrapper
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||
import exh.recs.RecommendsScreen
|
||||
import java.io.Serializable
|
||||
|
||||
/**
|
||||
* Navigated to when invoking [MangaScreen.openSmartSearch] for entries to merge or
|
||||
* from [RecommendsScreen.openSmartSearch] for click a recommendation entry.
|
||||
* This will show a [sourcesTab] to select a source to search for entries to merge or
|
||||
* search for recommending entry.
|
||||
*/
|
||||
class SourcesScreen(private val smartSearchConfig: SmartSearchConfig?) : Screen() {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
BrowseTabWrapper(sourcesTab(smartSearchConfig))
|
||||
}
|
||||
|
||||
/**
|
||||
* initialized when invoking [MangaScreen.openSmartSearch] or [RecommendsScreen.openSmartSearch]
|
||||
*/
|
||||
data class SmartSearchConfig(val origTitle: String, val origMangaId: Long? = null) : Serializable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ fun Screen.sourcesTab(
|
|||
onClickItem = { source, listing ->
|
||||
// SY -->
|
||||
val screen = when {
|
||||
// Search selected source for entries to merge or for the recommending entry
|
||||
smartSearchConfig != null -> SmartSearchScreen(source.id, smartSearchConfig)
|
||||
listing == Listing.Popular && screenModel.useNewSourceNavigation -> SourceFeedScreen(source.id)
|
||||
else -> BrowseSourceScreen(source.id, listing.query)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ import eu.kanade.tachiyomi.ui.webview.WebViewScreen
|
|||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.md.follows.MangaDexFollowsScreen
|
||||
import exh.ui.ifSourcesLoaded
|
||||
import exh.ui.smartsearch.SmartSearchScreen
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
|
|
@ -85,6 +86,8 @@ data class BrowseSourceScreen(
|
|||
// SY -->
|
||||
private val filtersJson: String? = null,
|
||||
private val savedSearch: Long? = null,
|
||||
/** being set when called from [SmartSearchScreen] or when click on a manga from this screen
|
||||
* which was previously opened from `SmartSearchScreen` */
|
||||
private val smartSearchConfig: SourcesScreen.SmartSearchConfig? = null,
|
||||
// SY <--
|
||||
) : Screen(), AssistContentScreen {
|
||||
|
|
|
|||
|
|
@ -362,11 +362,27 @@ class MangaScreen(
|
|||
onSourceClick = {
|
||||
if (successState.source !is StubSource) {
|
||||
val screen = when {
|
||||
// Clicked on source of an entry being merged with previous entry or
|
||||
// source of an recommending entry (to search again)
|
||||
smartSearchConfig != null -> SmartSearchScreen(successState.source.id, smartSearchConfig)
|
||||
screenModel.useNewSourceNavigation -> SourceFeedScreen(successState.source.id)
|
||||
else -> BrowseSourceScreen(successState.source.id, GetRemoteManga.QUERY_POPULAR)
|
||||
}
|
||||
navigator.push(screen)
|
||||
when (screen) {
|
||||
// When doing a migrate/recommend => replace previous screen to perform search again.
|
||||
is SmartSearchScreen -> {
|
||||
navigator.popUntil { it is SmartSearchScreen }
|
||||
if (navigator.size > 1) navigator.replace(screen) else navigator.push(screen)
|
||||
}
|
||||
is SourceFeedScreen -> {
|
||||
navigator.popUntil { it is SourceFeedScreen }
|
||||
if (navigator.size > 1) navigator.replace(screen) else navigator.push(screen)
|
||||
}
|
||||
else -> {
|
||||
navigator.popUntil { it is BrowseSourceScreen }
|
||||
if (navigator.size > 1) navigator.replace(screen) else navigator.push(screen)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
navigator.push(ExtensionsScreen(searchSource = successState.source.name))
|
||||
}
|
||||
|
|
@ -708,6 +724,9 @@ class MangaScreen(
|
|||
// SY <--
|
||||
|
||||
// EXH -->
|
||||
/**
|
||||
* Called when click Merge on an entry to search for entries to merge.
|
||||
*/
|
||||
private fun openSmartSearch(navigator: Navigator, manga: Manga) {
|
||||
val smartSearchConfig = SourcesScreen.SmartSearchConfig(manga.title, manga.id)
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,9 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen() {
|
|||
// KMK <--
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when click on an recommending entry to search sources for it.
|
||||
*/
|
||||
private fun openSmartSearch(navigator: Navigator, title: String) {
|
||||
val smartSearchConfig = SourcesScreen.SmartSearchConfig(title)
|
||||
navigator.push(SourcesScreen(smartSearchConfig))
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ import tachiyomi.i18n.sy.SYMR
|
|||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
/**
|
||||
* Search source for entries, either search for entries to merge or search for recommending entry.
|
||||
*/
|
||||
class SmartSearchScreen(
|
||||
private val sourceId: Long,
|
||||
private val smartSearchConfig: SourcesScreen.SmartSearchConfig,
|
||||
|
|
|
|||
Loading…
Reference in a new issue