Settings: confirm dialog before enabling biometric; cancel reverts switch to OFF
This commit is contained in:
@@ -80,6 +80,33 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
});
|
||||
return;
|
||||
}
|
||||
// When turning ON, ask for confirmation first. If cancelled, keep OFF.
|
||||
if (value) {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Aktifkan Sidik Jari?'),
|
||||
content: const Text(
|
||||
'Saat login, Anda akan diminta verifikasi sidik jari '
|
||||
'untuk masuk tanpa mengisi email & password.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(false),
|
||||
child: const Text('Batal'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(true),
|
||||
child: const Text('Aktifkan'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed != true) {
|
||||
// cancelled -> revert switch to OFF
|
||||
if (mounted) setState(() => _biometricOn = false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Settings only sets the flag; actual biometric prompt happens at login.
|
||||
await widget.auth.setBiometricEnabled(value);
|
||||
if (mounted) {
|
||||
|
||||
Reference in New Issue
Block a user