From be6086c7d5d0c217912841b6690f736e7e5546a1 Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 27 Sep 2024 12:05:11 +0200 Subject: [PATCH] fix behaviour Signed-off-by: Pablo --- .../ui/designsystem/component/LocationSearchBar.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LocationSearchBar.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LocationSearchBar.kt index de3c4f7a2..89343b458 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LocationSearchBar.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/LocationSearchBar.kt @@ -21,7 +21,6 @@ import androidx.compose.material.icons.outlined.Cancel import androidx.compose.material.icons.outlined.Map import androidx.compose.material.icons.outlined.Place import androidx.compose.material.icons.outlined.Search -import androidx.compose.material.icons.outlined.TouchApp import androidx.compose.material.icons.outlined.WatchLater import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -69,12 +68,12 @@ fun LocationBar( onClearLocation: () -> Unit, onSearchLocation: (query: String) -> Unit, onLocationSelected: (LocationItemModel) -> Unit, - onModeChanged:(currentMode: SearchBarMode) -> Unit = {}, + onModeChanged: (currentMode: SearchBarMode) -> Unit = {}, ) { var currentMode by remember { mutableStateOf(SearchBarMode.BUTTON) } var currentSearch: String by remember { mutableStateOf("") } - LaunchedEffect(currentMode){ + LaunchedEffect(currentMode) { onModeChanged(currentMode) } @@ -99,18 +98,15 @@ fun LocationBar( onSearchLocation(currentSearch) }, onBackClicked = { - currentSearch = "" currentMode = SearchBarMode.BUTTON - onSearchLocation(currentSearch) }, onSearch = { searchQuery -> currentMode = SearchBarMode.BUTTON - onSearchLocation(searchQuery) }, onLocationSelected = { currentSearch = it.title - onLocationSelected(it) currentMode = SearchBarMode.BUTTON + onLocationSelected(it) }, ) } @@ -303,7 +299,7 @@ fun LocationItem( style = MaterialTheme.typography.bodySmall, color = TextColor.OnSurface, maxLines = 1, - overflow = TextOverflow.Ellipsis + overflow = TextOverflow.Ellipsis, ) } }