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

View File

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