diff --git a/lib/dashboard/user_pin/view/user_pin_page.dart b/lib/dashboard/user_pin/view/user_pin_page.dart index f0014052c..5fc5a038d 100644 --- a/lib/dashboard/user_pin/view/user_pin_page.dart +++ b/lib/dashboard/user_pin/view/user_pin_page.dart @@ -37,8 +37,7 @@ class UserPinPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - PinCodeViewCubit(), + create: (context) => PinCodeViewCubit(), child: UserPinView( onCancel: onCancel, onProceed: onProceed, @@ -79,42 +78,35 @@ class _UserPinViewState extends State { @override Widget build(BuildContext context) { final l10n = context.l10n; - return BlocBuilder( - builder: (context, state) { - return WillPopScope( - onWillPop: () async => false, - child: BasePage( - backgroundColor: Theme.of(context).colorScheme.background, - scrollView: false, - body: PinCodeWidget( - title: widget.txCode?.description ?? - l10n.pleaseInsertTheSecredCodeReceived, - passwordDigits: widget.txCode?.length ?? 4, - deleteButton: Text( - l10n.delete, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelButton: Text( - l10n.cancel, - style: Theme.of(context).textTheme.labelLarge, - ), - cancelCallback: _onPasscodeCancelled, - isValidCallback: () { - Navigator.pop(context); - widget.onProceed.call(pinCodeValue!); - }, - ), + return WillPopScope( + onWillPop: () async => false, + child: BasePage( + backgroundColor: Theme.of(context).colorScheme.surface, + scrollView: false, + body: PinCodeWidget( + title: widget.txCode?.description ?? + l10n.pleaseInsertTheSecredCodeReceived, + passwordDigits: widget.txCode?.length ?? 4, + deleteButton: Text( + l10n.delete, + style: Theme.of(context).textTheme.labelLarge, ), - ); - }, + cancelButton: Text( + l10n.cancel, + style: Theme.of(context).textTheme.labelLarge, + ), + cancelCallback: _onPasscodeCancelled, + isValidCallback: () { + Navigator.pop(context); + widget.onProceed + .call(context.read().state.enteredPasscode); + }, + isUserPin: true, + ), + ), ); } - Future _onPasscodeEntered(String enteredPasscode) async { - pinCodeValue = enteredPasscode; - _verificationNotifier.add(true); - } - void _onPasscodeCancelled() { Navigator.of(context).pop(); widget.onCancel.call(); diff --git a/lib/pin_code/widgets/pin_code_widget.dart b/lib/pin_code/widgets/pin_code_widget.dart index 920efa667..e338e265d 100644 --- a/lib/pin_code/widgets/pin_code_widget.dart +++ b/lib/pin_code/widgets/pin_code_widget.dart @@ -24,6 +24,7 @@ class PinCodeWidget extends StatefulWidget { this.header, this.onLoginAttempt, this.isNewCode = false, + this.isUserPin = false, }) : circleUIConfig = circleUIConfig ?? const CircleUIConfig(), keyboardUIConfig = keyboardUIConfig ?? const KeyboardUIConfig(); @@ -33,6 +34,8 @@ class PinCodeWidget extends StatefulWidget { final String? subTitle; final int passwordDigits; final bool isNewCode; + // When a specific pin is requested to get a credential + final bool isUserPin; // Cancel button and delete button will be switched based on the screen state final Widget cancelButton; @@ -74,7 +77,7 @@ class _PinCodeWidgetState extends State }); } if (current.enteredPasscode.length == widget.passwordDigits) { - if (current.isPinCodeValid) { + if (current.isPinCodeValid || widget.isUserPin) { _validationCallback(); } else { if (widget.title == l10n.confirmYourPinCode) { @@ -89,6 +92,10 @@ class _PinCodeWidgetState extends State listener: (context, state) { widget.onLoginAttempt ?.call(state.loginAttemptCount, state.loginAttemptsRemaining); + // if (state.enteredPasscode.length == widget.passwordDigits && + // widget.isUserPin) { + // _validationCallback(); + // } }, builder: (context, state) { final enteredPasscode = state.enteredPasscode;