diff --git a/lib/dashboard/user_pin/view/user_pin_page.dart b/lib/dashboard/user_pin/view/user_pin_page.dart index e081e9306..ffdb82a3c 100644 --- a/lib/dashboard/user_pin/view/user_pin_page.dart +++ b/lib/dashboard/user_pin/view/user_pin_page.dart @@ -4,9 +4,9 @@ import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; import 'package:altme/l10n/l10n.dart'; import 'package:altme/pin_code/pin_code.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:secure_storage/secure_storage.dart'; class UserPinPage extends StatelessWidget { const UserPinPage({ @@ -68,44 +68,58 @@ class _UserPinViewState extends State { super.dispose(); } - String? pinCodeValue; - @override Widget build(BuildContext context) { final l10n = context.l10n; return WillPopScope( onWillPop: () async => false, - child: BasePage( - backgroundColor: Theme.of(context).colorScheme.background, - scrollView: false, - body: PinCodeWidget( - title: l10n.pleaseInsertTheSecredCodeReceived, - passwordEnteredCallback: _onPasscodeEntered, - passwordDigits: 6, - 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!); - }, - shouldTriggerVerification: _verificationNotifier.stream, - ), + child: BlocBuilder( + builder: (context, state) { + return BasePage( + backgroundColor: Theme.of(context).colorScheme.background, + scrollView: false, + body: PinCodeWidget( + title: l10n.pleaseInsertTheSecredCodeReceived, + passwordEnteredCallback: (String enterPasscode) { + _verificationNotifier.add(true); + }, + passwordDigits: 6, + 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(state.enteredPasscode); + }, + doneButton: state.enteredPasscode.length < 4 + ? null + : CupertinoButton( + onPressed: () { + Navigator.pop(context); + widget.onProceed.call(state.enteredPasscode); + }, + child: Container( + margin: const EdgeInsets.all(24), + child: Text( + l10n.proceed, + style: Theme.of(context).textTheme.labelLarge, + ), + ), + ), + shouldTriggerVerification: _verificationNotifier.stream, + ), + ); + }, ), ); } - 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 7c0867f08..7670922ac 100644 --- a/lib/pin_code/widgets/pin_code_widget.dart +++ b/lib/pin_code/widgets/pin_code_widget.dart @@ -21,6 +21,7 @@ class PinCodeWidget extends StatefulWidget { KeyboardUIConfig? keyboardUIConfig, this.bottomWidget, this.backgroundColor, + this.doneButton, this.cancelCallback, this.subTitle, this.header, @@ -29,6 +30,7 @@ class PinCodeWidget extends StatefulWidget { keyboardUIConfig = keyboardUIConfig ?? const KeyboardUIConfig(); final Widget? header; + final Widget? doneButton; final String title; final String? subTitle; final int passwordDigits; @@ -154,16 +156,19 @@ class _PinCodeWidgetState extends State Positioned( bottom: 0, right: 0, - child: Align( - alignment: Alignment.bottomRight, - child: DeleteButton( - cancelButton: widget.cancelButton, - deleteButton: widget.deleteButton, - cancelCallback: widget.cancelCallback, - keyboardUIConfig: widget.keyboardUIConfig, - ), + child: DeleteButton( + cancelButton: widget.cancelButton, + deleteButton: widget.deleteButton, + cancelCallback: widget.cancelCallback, + keyboardUIConfig: widget.keyboardUIConfig, ), ), + if (widget.doneButton != null) + Positioned( + bottom: 0, + left: 0, + child: widget.doneButton!, + ), ], ), ],