mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 15:51:49 +01:00
BrowseSourceScreen: fix navigate up and filter sheet (#8761)
This commit is contained in:
parent
9d2d78ae5b
commit
817e144ff6
@ -84,6 +84,13 @@ data class BrowseSourceScreen(
|
||||
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
|
||||
val navigateUp: () -> Unit = {
|
||||
when {
|
||||
!state.isUserQuery && state.toolbarQuery != null -> screenModel.setToolbarQuery(null)
|
||||
else -> navigator.pop()
|
||||
}
|
||||
}
|
||||
|
||||
val onHelpClick = { uriHandler.openUri(LocalSource.HELP_URL) }
|
||||
|
||||
val onWebViewClick = f@{
|
||||
@ -105,7 +112,7 @@ data class BrowseSourceScreen(
|
||||
source = screenModel.source,
|
||||
displayMode = screenModel.displayMode,
|
||||
onDisplayModeChange = { screenModel.displayMode = it },
|
||||
navigateUp = navigator::pop,
|
||||
navigateUp = navigateUp,
|
||||
onWebViewClick = onWebViewClick,
|
||||
onHelpClick = onHelpClick,
|
||||
onSearch = { screenModel.search(it) },
|
||||
|
@ -359,21 +359,20 @@ class BrowseSourceScreenModel(
|
||||
}
|
||||
|
||||
fun initFilterSheet(context: Context) {
|
||||
val state = state.value
|
||||
if (state.filters.isEmpty()) {
|
||||
if (state.value.filters.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
filterSheet = SourceFilterSheet(
|
||||
context = context,
|
||||
onFilterClicked = { search(filters = state.filters) },
|
||||
onFilterClicked = { search(filters = state.value.filters) },
|
||||
onResetClicked = {
|
||||
reset()
|
||||
filterSheet?.setFilters(state.filterItems)
|
||||
filterSheet?.setFilters(state.value.filterItems)
|
||||
},
|
||||
)
|
||||
|
||||
filterSheet?.setFilters(state.filterItems)
|
||||
filterSheet?.setFilters(state.value.filterItems)
|
||||
}
|
||||
|
||||
sealed class Filter(open val query: String?, open val filters: FilterList) {
|
||||
@ -409,12 +408,8 @@ class BrowseSourceScreenModel(
|
||||
val toolbarQuery: String? = null,
|
||||
val dialog: Dialog? = null,
|
||||
) {
|
||||
val filterItems = filters.toItems()
|
||||
val isUserQuery = currentFilter is Filter.UserInput && !currentFilter.query.isNullOrEmpty()
|
||||
val searchQuery = when (currentFilter) {
|
||||
is Filter.UserInput -> currentFilter.query
|
||||
Filter.Latest, Filter.Popular -> null
|
||||
}
|
||||
val filterItems get() = filters.toItems()
|
||||
val isUserQuery get() = currentFilter is Filter.UserInput && !currentFilter.query.isNullOrEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user