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