Skip to content

Commit

Permalink
🚩 Disable nearby search with flag (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheubuch authored Jan 11, 2025
1 parent f9c8bc1 commit 35e3e83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class FeatureFlags private constructor() {
private var _trwlDown = MutableLiveData(false)
val trwlDown: LiveData<Boolean> get() = _trwlDown

private var _nearbyActive = MutableLiveData(false)
val nearbyActive: LiveData<Boolean> get() = _nearbyActive

fun init(client: UnleashClient) {
unleashClient = client
unleashClient?.startPolling()
Expand All @@ -29,6 +32,7 @@ class FeatureFlags private constructor() {
unleashClient?.let {
_wrappedActive.postValue(it.isEnabled("WrappedActive", false))
_trwlDown.postValue(it.isEnabled("TrwlDown", false))
_nearbyActive.postValue(it.isEnabled("NearbyActive", false))
}
}
}
16 changes: 11 additions & 5 deletions app/src/main/kotlin/de/hbch/traewelling/ui/search/Search.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -49,6 +50,7 @@ import com.google.accompanist.permissions.rememberMultiplePermissionsState
import de.hbch.traewelling.R
import de.hbch.traewelling.api.models.station.Station
import de.hbch.traewelling.api.models.user.User
import de.hbch.traewelling.shared.FeatureFlags
import de.hbch.traewelling.theme.LocalFont
import de.hbch.traewelling.ui.composables.ProfilePicture
import de.hbch.traewelling.util.getStationNameWithRL100
Expand Down Expand Up @@ -98,6 +100,8 @@ fun Search(

val userResults = remember { mutableStateListOf<User>() }
val stationResults = remember { mutableStateListOf<Station>() }
val featureFlags = remember { FeatureFlags.getInstance() }
val nearbyActive by featureFlags.nearbyActive.observeAsState(false)

val stationSelected: (Station) -> Unit = {
active = false
Expand Down Expand Up @@ -177,11 +181,13 @@ fun Search(
modifier = Modifier.size(24.dp)
)
} else {
IconButton(onClick = { isLocating = true }) {
Icon(
painter = painterResource(id = R.drawable.ic_locate),
contentDescription = stringResource(id = R.string.locate)
)
if (nearbyActive) {
IconButton(onClick = { isLocating = true }) {
Icon(
painter = painterResource(id = R.drawable.ic_locate),
contentDescription = stringResource(id = R.string.locate)
)
}
}
}
}
Expand Down

0 comments on commit 35e3e83

Please sign in to comment.