Add 'Gunakan Sidik Jari' retry button on login (shown when biometric enabled+available). Loads biometric flags at init.
This commit is contained in:
@@ -21,6 +21,8 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
bool _busy = false;
|
bool _busy = false;
|
||||||
String? _error;
|
String? _error;
|
||||||
String? _bioMsg;
|
String? _bioMsg;
|
||||||
|
bool _biometricAvailable = false;
|
||||||
|
bool _biometricEnabled = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -32,10 +34,16 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
Future<void> _initMode() async {
|
Future<void> _initMode() async {
|
||||||
final registered = await widget.auth.isRegistered();
|
final registered = await widget.auth.isRegistered();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() => _isLogin = registered);
|
final avail = await widget.auth.canUseBiometrics();
|
||||||
|
final enabled = await widget.auth.isBiometricEnabled();
|
||||||
|
setState(() {
|
||||||
|
_isLogin = registered;
|
||||||
|
_biometricAvailable = avail;
|
||||||
|
_biometricEnabled = enabled;
|
||||||
|
});
|
||||||
// If already registered and biometric is enabled, prompt fingerprint
|
// If already registered and biometric is enabled, prompt fingerprint
|
||||||
// automatically (unless a valid session already skips to dashboard).
|
// automatically (unless a valid session already skips to dashboard).
|
||||||
if (registered && await widget.auth.isBiometricEnabled()) {
|
if (registered && enabled) {
|
||||||
final timeout = await widget.auth.getTimeoutMinutes();
|
final timeout = await widget.auth.getTimeoutMinutes();
|
||||||
final valid = await widget.auth.hasValidSession(timeout);
|
final valid = await widget.auth.hasValidSession(timeout);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
@@ -154,9 +162,25 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_busy
|
_busy
|
||||||
? const CircularProgressIndicator()
|
? const CircularProgressIndicator()
|
||||||
: ElevatedButton(
|
: Column(
|
||||||
onPressed: _submit,
|
children: [
|
||||||
child: Text(_isLogin ? 'Masuk' : 'Daftar'),
|
ElevatedButton(
|
||||||
|
onPressed: _submit,
|
||||||
|
child: Text(_isLogin ? 'Masuk' : 'Daftar'),
|
||||||
|
),
|
||||||
|
// Biometric retry button (only when enabled + registered)
|
||||||
|
if (_isLogin &&
|
||||||
|
_biometricAvailable &&
|
||||||
|
_biometricEnabled)
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() => _bioMsg = null);
|
||||||
|
_promptBiometricOnOpen();
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.fingerprint),
|
||||||
|
label: const Text('Gunakan Sidik Jari'),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user