fix extension tabs search

This commit is contained in:
jmir1 2022-11-15 11:45:31 +01:00
parent 4b751f4821
commit aa69f47a1b
2 changed files with 18 additions and 3 deletions

View file

@ -34,6 +34,8 @@ fun TabbedScreen(
downloadedOnlyMode: Boolean,
state: PagerState = rememberPagerState(),
scrollable: Boolean = false,
searchQueryAnime: String? = null,
onChangeSearchQueryAnime: (String?) -> Unit = {},
) {
val scope = rememberCoroutineScope()
@ -49,11 +51,21 @@ fun TabbedScreen(
val tab = tabs[state.currentPage]
val searchEnabled = tab.searchEnabled
val actualQuery = when (state.currentPage) {
3 -> searchQuery
else -> searchQueryAnime
}
val actualOnChange = when (state.currentPage) {
3 -> onChangeSearchQuery
else -> onChangeSearchQueryAnime
}
SearchToolbar(
titleContent = { AppBarTitle(stringResource(titleRes)) },
searchEnabled = searchEnabled,
searchQuery = if (searchEnabled) searchQuery else null,
onChangeSearchQuery = onChangeSearchQuery,
searchQuery = if (searchEnabled) actualQuery else null,
onChangeSearchQuery = actualOnChange,
actions = { AppBarActions(tab.actions) },
)
}

View file

@ -36,6 +36,7 @@ class BrowseController : FullComposeController<BrowsePresenter>, RootController
@Composable
override fun ComposeContent() {
val animeQuery by presenter.animeExtensionsPresenter.query.collectAsState()
val query by presenter.extensionsPresenter.query.collectAsState()
TabbedScreen(
@ -50,10 +51,12 @@ class BrowseController : FullComposeController<BrowsePresenter>, RootController
),
startIndex = 1.takeIf { toExtensions },
searchQuery = query,
onChangeSearchQuery = { presenter.animeExtensionsPresenter.search(it) },
onChangeSearchQuery = { presenter.extensionsPresenter.search(it) },
incognitoMode = presenter.isIncognitoMode,
downloadedOnlyMode = presenter.isDownloadOnly,
scrollable = true,
searchQueryAnime = animeQuery,
onChangeSearchQueryAnime = { presenter.animeExtensionsPresenter.search(it) },
)
LaunchedEffect(Unit) {