fix(location): force UI update on setting change
Use mutable state for locationSearchProvider and googleMapsApiKey display values in BetterLocationRoot. Update these state variables immediately when dialogs are dismissed/saved to ensure the UI reflects changes without reopening the screen. - Introduce currentProvider/currentApiKey state variables. - Refresh state in onDismissRequest/callbacks.
This commit is contained in:
@@ -275,22 +275,31 @@ class BetterLocationRoot : Routes.Route() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showProviderDialog) {
|
var currentProvider by remember { mutableStateOf(context.config.root.global.betterLocation.locationSearchProvider.get()) }
|
||||||
me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = {
|
var currentApiKey by remember { mutableStateOf(context.config.root.global.betterLocation.googleMapsApiKey.get()) }
|
||||||
showProviderDialog = false
|
|
||||||
context.config.writeConfig()
|
if (showProviderDialog) {
|
||||||
}) {
|
me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = {
|
||||||
alertDialogs.UniqueSelectionDialog(providerProperty)
|
showProviderDialog = false
|
||||||
}
|
context.config.writeConfig()
|
||||||
}
|
currentProvider = context.config.root.global.betterLocation.locationSearchProvider.get()
|
||||||
if (showApiKeyDialog) {
|
}) {
|
||||||
me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { showApiKeyDialog = false }) {
|
alertDialogs.UniqueSelectionDialog(providerProperty)
|
||||||
alertDialogs.KeyboardInputDialog(apiKeyProperty) {
|
}
|
||||||
showApiKeyDialog = false
|
}
|
||||||
context.config.writeConfig()
|
if (showApiKeyDialog) {
|
||||||
}
|
me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = {
|
||||||
}
|
showApiKeyDialog = false
|
||||||
}
|
context.config.writeConfig()
|
||||||
|
currentApiKey = context.config.root.global.betterLocation.googleMapsApiKey.get()
|
||||||
|
}) {
|
||||||
|
alertDialogs.KeyboardInputDialog(apiKeyProperty) {
|
||||||
|
showApiKeyDialog = false
|
||||||
|
context.config.writeConfig()
|
||||||
|
currentApiKey = context.config.root.global.betterLocation.googleMapsApiKey.get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -448,7 +457,6 @@ class BetterLocationRoot : Routes.Route() {
|
|||||||
ConfigSelector(text, if (value.isNotEmpty()) "********" else translation["options.empty"], onClick)
|
ConfigSelector(text, if (value.isNotEmpty()) "********" else translation["options.empty"], onClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentProvider = context.config.root.global.betterLocation.locationSearchProvider.get()
|
|
||||||
ConfigSelector(
|
ConfigSelector(
|
||||||
text = translation["location_search_provider_title"],
|
text = translation["location_search_provider_title"],
|
||||||
value = translation["option_$currentProvider"]
|
value = translation["option_$currentProvider"]
|
||||||
@@ -457,7 +465,7 @@ class BetterLocationRoot : Routes.Route() {
|
|||||||
if (currentProvider == "google_maps") {
|
if (currentProvider == "google_maps") {
|
||||||
ConfigInput(
|
ConfigInput(
|
||||||
text = translation["google_maps_api_key_title"],
|
text = translation["google_maps_api_key_title"],
|
||||||
value = context.config.root.global.betterLocation.googleMapsApiKey.get()
|
value = currentApiKey
|
||||||
) { showApiKeyDialog = true }
|
) { showApiKeyDialog = true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user