Skip to content

Commit

Permalink
Block navigation from create pin code on registration and recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Oct 2, 2024
1 parent de2be2c commit c826c37
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
20 changes: 13 additions & 7 deletions app/lib/screens/change_pin_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import 'package:threebotlogin/services/shared_preference_service.dart';
import 'package:threebotlogin/widgets/pin_code.dart';

class ChangePinScreen extends StatefulWidget {
const ChangePinScreen({super.key, this.currentPin, this.hideBackButton});
const ChangePinScreen(
{super.key, this.currentPin, this.hideBackButton = false});

final String? currentPin;
final bool? hideBackButton;
final bool hideBackButton;

@override
State<ChangePinScreen> createState() => _ChangePinScreenState();
Expand Down Expand Up @@ -38,11 +39,16 @@ class _ChangePinScreenState extends State<ChangePinScreen> {

@override
Widget build(BuildContext context) {
return PincodeWidget(
title:
widget.currentPin == null ? 'Choose your pincode' : 'Change pincode',
userMessage: getText(),
handler: changePin,
return PopScope(
canPop: widget.hideBackButton == false,
child: PincodeWidget(
title: widget.currentPin == null
? 'Choose your pincode'
: 'Change pincode',
userMessage: getText(),
hideBackButton: widget.hideBackButton,
handler: changePin,
),
);
}

Expand Down
19 changes: 11 additions & 8 deletions app/lib/widgets/pin_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import 'package:pinput/pinput.dart';
import 'package:threebotlogin/helpers/globals.dart';

class PincodeWidget extends StatefulWidget {
const PincodeWidget(
{super.key,
required this.userMessage,
required this.title,
required this.handler});
const PincodeWidget({
super.key,
required this.userMessage,
required this.title,
required this.handler,
this.hideBackButton = false,
});
final String title;
final String userMessage;
final bool hideBackButton;
final Function(String) handler;

@override
Expand Down Expand Up @@ -50,9 +53,9 @@ class _PincodeWidgetState extends State<PincodeWidget> {
/// Optionally you can use form to validate the Pinput
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(widget.title),
),
elevation: 0,
title: Text(widget.title),
automaticallyImplyLeading: widget.hideBackButton == false),
body: Center(
child: Form(
key: formKey,
Expand Down

0 comments on commit c826c37

Please sign in to comment.