Security settings improvements

This commit is contained in:
shital
2025-11-11 14:18:37 +05:30
parent 36702b198f
commit ef481ec879
10 changed files with 294 additions and 101 deletions

View File

@@ -15,12 +15,18 @@ class MPinScreen extends StatefulWidget {
final MPinMode mode;
final String? initialPin;
final void Function(String pin)? onCompleted;
final bool disableBiometric;
final String? customTitle;
final String? customConfirmTitle;
const MPinScreen({
super.key,
required this.mode,
this.initialPin,
this.onCompleted,
this.disableBiometric = false,
this.customTitle,
this.customConfirmTitle,
});
@override
@@ -77,7 +83,7 @@ class _MPinScreenState extends State<MPinScreen> with TickerProviderStateMixin {
CurvedAnimation(parent: _waveController, curve: Curves.easeInOut),
);
if (widget.mode == MPinMode.enter) {
if (widget.mode == MPinMode.enter && !widget.disableBiometric) {
_tryBiometricBeforePin();
}
}
@@ -172,17 +178,27 @@ class _MPinScreenState extends State<MPinScreen> with TickerProviderStateMixin {
}
break;
case MPinMode.set:
// propagate parent onCompleted into confirm step
Navigator.push(
// Navigate to confirm and wait for result
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => MPinScreen(
mode: MPinMode.confirm,
initialPin: pin,
onCompleted: widget.onCompleted, // <-- use parent callback
onCompleted: (confirmedPin) {
// Just pop with the pin, don't call parent callback yet
Navigator.of(context).pop(confirmedPin);
},
disableBiometric: widget.disableBiometric,
customTitle: widget.customConfirmTitle,
),
),
);
// If confirm succeeded, call parent callback
if (result != null && mounted) {
widget.onCompleted?.call(result);
}
break;
case MPinMode.confirm:
if (widget.initialPin == pin) {
@@ -335,6 +351,9 @@ class _MPinScreenState extends State<MPinScreen> with TickerProviderStateMixin {
}
String getTitle() {
if (widget.customTitle != null) {
return widget.customTitle!;
}
switch (widget.mode) {
case MPinMode.enter:
return AppLocalizations.of(context).enterMPIN;