Skip to content

Commit

Permalink
Fix #117: Update screenshots prevent switch without refreshing the app
Browse files Browse the repository at this point in the history
  • Loading branch information
RoonyShekho09 committed Oct 4, 2024
1 parent 9edab4a commit b9d8843
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/src/main/java/com/mensinator/app/SettingsDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object ResourceMapper {


@Composable
fun SettingsDialog() {
fun SettingsDialog(onSwitchProtectionScreen: (Boolean) -> Unit) {
Log.d("SettingsDialog", "SettingsDialog recomposed")

val context = LocalContext.current
Expand Down Expand Up @@ -331,6 +331,9 @@ fun SettingsDialog() {
Switch(
checked = isChecked,
onCheckedChange = { newValue ->
if(setting.label == "Protect screen"){
onSwitchProtectionScreen(newValue)
}
isChecked = newValue
savedSettings = savedSettings.map {
if (it.key == setting.key) it.copy(value = if (newValue) "1" else "0") else it
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/mensinator/app/navigation/bottomBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ fun BottomBar(
}
composable(route = Screens.Settings.name) {
// here you add the page that you want to open(Settings)
SettingsDialog()
SettingsDialog(onSwitchProtectionScreen = { newValue ->
onScreenProtectionChanged(newValue)
})
}
}
}
Expand Down

0 comments on commit b9d8843

Please sign in to comment.