Skip to content

Commit

Permalink
fix: enabling app lock manually displays the dialog turn off
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Nov 22, 2023
1 parent 3afc4af commit b9cc0ff
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ fun SettingsScreen(
viewModel: SettingsViewModel = hiltViewModel()
) {
val lazyListState: LazyListState = rememberLazyListState()
val turnAppLockOffDialogState = rememberVisibilityState<Unit>()

val context = LocalContext.current
SettingsScreenContent(
lazyListState = lazyListState,
Expand All @@ -69,10 +71,11 @@ fun SettingsScreen(
onAppLockSwitchChanged = remember {
{ isChecked ->
if (isChecked) homeStateHolder.navigator.navigate(NavigationCommand(SetLockCodeScreenDestination, BackStackMode.NONE))
else viewModel.disableAppLock()
else turnAppLockOffDialogState.show(Unit)
}
}
)
TurnAppLockOffDialog(dialogState = turnAppLockOffDialogState, turnOff = viewModel::disableAppLock)
}

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

with(featureVisibilityFlags) {
LazyColumn(
Expand Down Expand Up @@ -121,10 +123,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 @@ -159,7 +160,6 @@ fun SettingsScreenContent(
}
}

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

private fun LazyListScope.folderWithElements(
Expand Down

0 comments on commit b9cc0ff

Please sign in to comment.