feat: add global search shortcut to SmartSearch (#1377)
* feat: add global search shortcut to SmartSearch * feat: add global search shortcut to SmartSearch * feat: add back button to BrowseTabWrapper
This commit is contained in:
parent
d80ad3f145
commit
46dea6d598
@ -11,7 +11,7 @@ import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
@Composable
|
||||
fun BrowseTabWrapper(tab: TabContent) {
|
||||
fun BrowseTabWrapper(tab: TabContent, onBackPressed: (() -> Unit)? = null) {
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
Scaffold(
|
||||
topBar = { scrollBehavior ->
|
||||
@ -20,6 +20,7 @@ fun BrowseTabWrapper(tab: TabContent) {
|
||||
actions = {
|
||||
AppBarActions(tab.actions)
|
||||
},
|
||||
navigateUp = onBackPressed,
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
},
|
||||
|
@ -1,12 +1,15 @@
|
||||
package eu.kanade.tachiyomi.ui.browse.migration.sources
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.browse.BrowseTabWrapper
|
||||
import eu.kanade.presentation.util.Screen
|
||||
|
||||
class MigrationSourcesScreen : Screen() {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
BrowseTabWrapper(migrateSourceTab())
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
BrowseTabWrapper(migrateSourceTab(), onBackPressed = navigator::pop)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package eu.kanade.tachiyomi.ui.browse.source
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.browse.BrowseTabWrapper
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import java.io.Serializable
|
||||
@ -8,7 +10,8 @@ import java.io.Serializable
|
||||
class SourcesScreen(private val smartSearchConfig: SmartSearchConfig?) : Screen() {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
BrowseTabWrapper(sourcesTab(smartSearchConfig))
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
BrowseTabWrapper(sourcesTab(smartSearchConfig), onBackPressed = navigator::pop)
|
||||
}
|
||||
|
||||
data class SmartSearchConfig(val origTitle: String, val origMangaId: Long? = null) : Serializable
|
||||
|
@ -43,21 +43,25 @@ fun Screen.sourcesTab(
|
||||
true -> MR.strings.label_sources
|
||||
false -> SYMR.strings.find_in_another_source
|
||||
},
|
||||
actions = if (smartSearchConfig == null) {
|
||||
persistentListOf(
|
||||
actions = persistentListOf(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_global_search),
|
||||
icon = Icons.Outlined.TravelExplore,
|
||||
onClick = { navigator.push(GlobalSearchScreen()) },
|
||||
onClick = { navigator.push(GlobalSearchScreen(smartSearchConfig?.origTitle ?: "")) },
|
||||
),
|
||||
).let {
|
||||
when (smartSearchConfig) {
|
||||
null -> {
|
||||
it.add(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_filter),
|
||||
icon = Icons.Outlined.FilterList,
|
||||
onClick = { navigator.push(SourcesFilterScreen()) },
|
||||
),
|
||||
)
|
||||
} else {
|
||||
persistentListOf()
|
||||
}
|
||||
else -> it
|
||||
}
|
||||
},
|
||||
// SY <--
|
||||
content = { contentPadding, snackbarHostState ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user