Skip to content

Commit

Permalink
feat: Cusomise PIN code title based on situation #2977
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Nov 5, 2024
1 parent 3128658 commit 81ec55c
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class FailureWidget extends StatelessWidget {
onPressed: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.pushReplacement(
Expand All @@ -226,6 +227,7 @@ class FailureWidget extends StatelessWidget {
onPressed: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class _VerifyAgeViewState extends State<VerifyAgeView> {
onPressed: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class ManageAccountsItem extends StatelessWidget {
if (confirm) {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.of(context).push<void>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ResetWalletView extends StatelessWidget {
? () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () async {
await resetWallet(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class DidPrivateKey extends StatelessWidget {
if (confirm) {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.push<void>(context, route);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';

Future<void> securityCheck({
required BuildContext context,
required String title,
required VoidCallback onSuccess,
required LocalAuthApi localAuthApi,
}) async {
Expand All @@ -19,6 +20,7 @@ Future<void> securityCheck({
case WalletProtectionType.FA2:
await Navigator.of(context).push<void>(
PinCodePage.route(
title: title,
isValidCallback: onSuccess.call,
restrictToBack: false,
walletProtectionType: walletProtectionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class WalletSecurityView extends StatelessWidget {
onTap: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.of(context)
Expand Down Expand Up @@ -78,6 +79,7 @@ class WalletSecurityView extends StatelessWidget {
if (confirm) {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.of(context)
Expand All @@ -102,6 +104,7 @@ class WalletSecurityView extends StatelessWidget {
onTap: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.of(context).push<void>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class PolygonIdCredentialOfferPage extends StatelessWidget {
onPressed: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
context.read<PolygonIdCubit>().addPolygonIdCredentials(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class _PolygonIdVerificationViewState extends State<PolygonIdVerificationView> {
? () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class CredentialManifestOfferPickView extends StatelessWidget {
bool authenticated = false;
await securityCheck(
context: context,
title: context.l10n.typeYourPINCodeToShareTheData,
localAuthApi: LocalAuthApi(),
onSuccess: () {
authenticated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class QueryByExampleCredentialPickView extends StatelessWidget {
bool authenticated = false;
await securityCheck(
context: context,
title: context.l10n
.typeYourPINCodeToShareTheData,
localAuthApi: LocalAuthApi(),
onSuccess: () {
authenticated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class _SelectiveDisclosurePickViewState
bool authenticated = false;
await securityCheck(
context: context,
title: context.l10n.typeYourPINCodeToShareTheData,
localAuthApi: LocalAuthApi(),
onSuccess: () {
authenticated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class _ConfirmWithdrawalViewState extends State<ConfirmWithdrawalView> {
? () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
context
Expand Down
1 change: 1 addition & 0 deletions lib/dashboard/src/view/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class _DashboardViewState extends State<DashboardView> {
onButtonClick: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () => Navigator.of(context)
.push<void>(RecoveryKeyPage.route()),
Expand Down
5 changes: 4 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1155,5 +1155,8 @@
"credentialPickTitle": "Choose the credential(s) to wish to obtain",
"credentialShareTitle": "Choose the credential(s) to share",
"enterYourSecretCode": "Enter your secret code.",
"jwk": "JWK"
"jwk": "JWK",
"typeYourPINCodeToOpenTheWallet": "Type your PIN code to open the wallet",
"typeYourPINCodeToShareTheData": "Type your PIN code to share the data",
"typeYourPINCodeToAuthenticate": "Type your PIN code to authenticate"
}
15 changes: 12 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
"credentialPickTitle",
"credentialShareTitle",
"enterYourSecretCode",
"jwk"
"jwk",
"typeYourPINCodeToOpenTheWallet",
"typeYourPINCodeToShareTheData",
"typeYourPINCodeToAuthenticate"
],

"es": [
Expand Down Expand Up @@ -148,7 +151,10 @@
"credentialPickTitle",
"credentialShareTitle",
"enterYourSecretCode",
"jwk"
"jwk",
"typeYourPINCodeToOpenTheWallet",
"typeYourPINCodeToShareTheData",
"typeYourPINCodeToAuthenticate"
],

"fr": [
Expand Down Expand Up @@ -229,6 +235,9 @@
"credentialPickTitle",
"credentialShareTitle",
"enterYourSecretCode",
"jwk"
"jwk",
"typeYourPINCodeToOpenTheWallet",
"typeYourPINCodeToShareTheData",
"typeYourPINCodeToAuthenticate"
]
}
10 changes: 8 additions & 2 deletions lib/pin_code/view/pin_code_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@ import 'package:secure_storage/secure_storage.dart';
class PinCodePage extends StatelessWidget {
const PinCodePage({
super.key,
required this.title,
required this.isValidCallback,
this.restrictToBack = true,
required this.localAuthApi,
required this.walletProtectionType,
});

final String title;
final VoidCallback isValidCallback;
final bool restrictToBack;
final LocalAuthApi localAuthApi;
final WalletProtectionType walletProtectionType;

static Route<dynamic> route({
required String title,
required VoidCallback isValidCallback,
required WalletProtectionType walletProtectionType,
bool restrictToBack = true,
}) =>
MaterialPageRoute<void>(
builder: (_) => PinCodePage(
title: title,
isValidCallback: isValidCallback,
restrictToBack: restrictToBack,
localAuthApi: LocalAuthApi(),
Expand All @@ -42,6 +46,7 @@ class PinCodePage extends StatelessWidget {
secureStorageProvider: getSecureStorage,
),
child: PinCodeView(
title: title,
isValidCallback: isValidCallback,
restrictToBack: restrictToBack,
localAuthApi: localAuthApi,
Expand All @@ -54,12 +59,14 @@ class PinCodePage extends StatelessWidget {
class PinCodeView extends StatefulWidget {
const PinCodeView({
super.key,
required this.title,
required this.isValidCallback,
this.restrictToBack = true,
required this.localAuthApi,
required this.walletProtectionType,
});

final String title;
final VoidCallback isValidCallback;
final bool restrictToBack;
final LocalAuthApi localAuthApi;
Expand All @@ -85,8 +92,7 @@ class _PinCodeViewState extends State<PinCodeView> {
titleLeading: widget.restrictToBack ? null : const BackLeadingButton(),
scrollView: false,
body: PinCodeWidget(
title: l10n.enterYourPinCode,
subTitle: l10n.pinCodeMessage,
title: widget.title,
deleteButton: Text(
l10n.delete,
style: Theme.of(context).textTheme.labelLarge,
Expand Down
3 changes: 3 additions & 0 deletions lib/splash/bloclisteners/blocklisteners.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ final splashBlocListener = BlocListener<SplashCubit, SplashState>(
if (state.status == SplashStatus.routeToPassCode) {
securityCheck(
context: context,
title: context.l10n.typeYourPINCodeToOpenTheWallet,
localAuthApi: LocalAuthApi(),
onSuccess: () {
Navigator.of(context).push<void>(DashboardPage.route());
Expand Down Expand Up @@ -530,6 +531,7 @@ final qrCodeBlocListener = BlocListener<QRCodeScanCubit, QRCodeScanState>(
bool authenticated = false;
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
authenticated = true;
Expand Down Expand Up @@ -844,6 +846,7 @@ final polygonIdBlocListener = BlocListener<PolygonIdCubit, PolygonIdState>(

await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
context.read<PolygonIdCubit>().authenticateOrGenerateProof(
Expand Down
2 changes: 2 additions & 0 deletions test/pin_code/view/pin_code_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void main() {
Navigator.of(context).push<void>(
PinCodePage.route(
isValidCallback: () {},
title: '',
walletProtectionType: WalletProtectionType.FA2,
),
);
Expand Down Expand Up @@ -102,6 +103,7 @@ void main() {
BlocProvider<FlavorCubit>.value(value: flavorCubit),
],
child: PinCodePage(
title: '',
isValidCallback: () {},
walletProtectionType: WalletProtectionType.FA2,
localAuthApi: localAuthApi,
Expand Down

0 comments on commit 81ec55c

Please sign in to comment.