From aa69f47a1bb5a7d92c5ae1918af374bf264d1666 Mon Sep 17 00:00:00 2001 From: jmir1 Date: Tue, 15 Nov 2022 11:45:31 +0100 Subject: [PATCH] fix extension tabs search --- .../presentation/components/TabbedScreen.kt | 16 ++++++++++++++-- .../tachiyomi/ui/browse/BrowseController.kt | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt index 7402f88af..9a721dee6 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedScreen.kt @@ -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) }, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt index 3a53b8fad..e17cede84 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt @@ -36,6 +36,7 @@ class BrowseController : FullComposeController, 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, 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) {