Skip to content

Commit

Permalink
fix: enabling app lock manually displays the dialog turn off (#2454)
Browse files Browse the repository at this point in the history
Co-authored-by: Yamil Medina <yamilmedina@users.noreply.github.com>
  • Loading branch information
MohamadJaara and yamilmedina committed Nov 24, 2023
1 parent f593408 commit 7ef3db4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ fun SettingsScreen(
viewModel: SettingsViewModel = hiltViewModel()
) {
val lazyListState: LazyListState = rememberLazyListState()
val turnAppLockOffDialogState = rememberVisibilityState<Unit>()
val onAppLockSwitchClicked: (Boolean) -> Unit = remember {
{ isChecked ->
if (isChecked) homeStateHolder.navigator.navigate(NavigationCommand(SetLockCodeScreenDestination, BackStackMode.NONE))
else turnAppLockOffDialogState.show(Unit)
}
}

val context = LocalContext.current
SettingsScreenContent(
lazyListState = lazyListState,
Expand All @@ -66,13 +74,9 @@ fun SettingsScreen(
)
}
},
onAppLockSwitchChanged = remember {
{ isChecked ->
if (isChecked) homeStateHolder.navigator.navigate(NavigationCommand(SetLockCodeScreenDestination, BackStackMode.NONE))
else viewModel.disableAppLock()
}
}
onAppLockSwitchChanged = onAppLockSwitchClicked
)
TurnAppLockOffDialog(dialogState = turnAppLockOffDialogState, turnOff = viewModel::disableAppLock)
}

@Composable
Expand All @@ -84,7 +88,6 @@ fun SettingsScreenContent(
) {
val context = LocalContext.current
val featureVisibilityFlags = LocalFeatureVisibilityFlags.current
val turnAppLockOffDialogState = rememberVisibilityState<Unit>()

with(featureVisibilityFlags) {
LazyColumn(
Expand Down Expand Up @@ -121,10 +124,9 @@ fun SettingsScreenContent(
appLogger.d("AppLockConfig isAppLockEnabled: ${settingsState.isAppLockEnabled}")
SwitchState.Enabled(
value = settingsState.isAppLockEnabled,
isOnOffVisible = true
) {
turnAppLockOffDialogState.show(Unit)
}
isOnOffVisible = true,
onCheckedChange = onAppLockSwitchChanged
)
}

false -> {
Expand Down Expand Up @@ -158,8 +160,6 @@ fun SettingsScreenContent(
)
}
}

TurnAppLockOffDialog(dialogState = turnAppLockOffDialogState) { onAppLockSwitchChanged(false) }
}

private fun LazyListScope.folderWithElements(
Expand Down

0 comments on commit 7ef3db4

Please sign in to comment.