Fix search focus when switching between tabs

This commit is contained in:
Rafał Kobyłko 2023-10-27 21:23:11 +02:00
parent 072b5f1d5e
commit 4fafd68950
2 changed files with 20 additions and 3 deletions

View File

@ -33,6 +33,7 @@ interface BottomBarListener {
internal fun BottomBar( internal fun BottomBar(
selectedIndex: Int, selectedIndex: Int,
listener: BottomBarListener, listener: BottomBarListener,
onItemClick: () -> Unit = {},
) { ) {
TwNavigationBar { TwNavigationBar {
bottomNavItems.forEachIndexed { index, item -> bottomNavItems.forEachIndexed { index, item ->
@ -43,8 +44,14 @@ internal fun BottomBar(
showBadge = false, showBadge = false,
onClick = { onClick = {
when { when {
index == 0 && selectedIndex != 0 -> listener.openHome() index == 0 && selectedIndex != 0 -> {
index == 1 && selectedIndex != 1 -> listener.openSettings() onItemClick()
listener.openHome()
}
index == 1 && selectedIndex != 1 -> {
onItemClick()
listener.openSettings()
}
} }
} }
) )

View File

@ -262,7 +262,17 @@ private fun ServicesScreen(
} }
Scaffold( Scaffold(
bottomBar = { BottomBar(0, bottomBarListener) }, bottomBar = {
BottomBar(
selectedIndex = 0,
listener = bottomBarListener,
onItemClick = {
if (uiState.searchFocused) {
onSearchFocusChange(false)
}
}
)
},
topBar = { topBar = {
ServicesAppBar( ServicesAppBar(
query = uiState.searchQuery, query = uiState.searchQuery,