Skip to content

Commit adf411b

Browse files
Duy PhạmDuy Phạm
authored andcommitted
Handle INACTIVE state in MyLocationButton and hide accuracy indicators
1 parent 7ad90a1 commit adf411b

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib-compose/src/main/java/com/what3words/components/compose/maps/buttons/MyLocationButton.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,22 @@ internal fun MyLocationButton(
119119
}
120120

121121
LaunchedEffect(locationStatus) {
122-
if (locationStatus == LocationStatus.SEARCHING) {
123-
while (true) {
124-
// Switch searching icon
125-
searchingIconState = SearchIconState.ICON_ONE
126-
delay(400L)
127-
searchingIconState = SearchIconState.ICON_TWO
128-
delay(800L)
122+
when (locationStatus) {
123+
LocationStatus.SEARCHING -> {
124+
while (true) {
125+
// Switch searching icon
126+
searchingIconState = SearchIconState.ICON_ONE
127+
delay(400L)
128+
searchingIconState = SearchIconState.ICON_TWO
129+
delay(800L)
130+
}
131+
}
132+
133+
LocationStatus.INACTIVE -> {
134+
isShowingAccuracy = false
129135
}
136+
137+
else -> {}
130138
}
131139
}
132140

@@ -209,7 +217,7 @@ internal fun MyLocationButton(
209217
modifier = Modifier.size(layoutConfig.locationIconSize)
210218
)
211219
}
212-
if (accuracyDistanceInMeter >= SAFE_ACCURACY_DISTANCE) {
220+
if (accuracyDistanceInMeter >= SAFE_ACCURACY_DISTANCE && locationStatus != LocationStatus.INACTIVE) {
213221
WarningIndicator(
214222
modifier = Modifier.align(Alignment.TopEnd),
215223
accuracyDistance = accuracyDistanceInMeter,

0 commit comments

Comments
 (0)