From b924d644b75587d4aaf44f95c649ef274ab1d75c Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 4 Dec 2022 23:18:30 +0100 Subject: [PATCH] UX: improve certification popup --- assets/translations/en.json | 8 +-- assets/translations/es.json | 7 ++- assets/translations/fr.json | 8 +-- lib/providers/substrate_sdk.dart | 3 ++ lib/screens/common_elements.dart | 86 ++++++++++++++++++++++++++++++++ lib/screens/wallet_view.dart | 25 +++++++--- pubspec.yaml | 2 +- 7 files changed, 123 insertions(+), 16 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 0ffee34..a46a889 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -71,7 +71,8 @@ "areYouSureToDeleteWallet": "Are you sure you want to delete the chest \"{}\"?", "areYouSureForgetAllChests": "Are you sure you want to forget all your chests?", "areYouSureToForgetWallet": "Are you sure you wan to forget the wallet \"{}\"?", - "areYouSureYouWantToCertify": "Are you sure you want to certify the address:\n\n{}", + "areYouSureYouWantToCertify1": "Are you sure you want to certify the identity :", + "areYouSureYouWantToCertify2": "having the address :", "yes": "Yes", "no": "No", "keepYourMnemonicSecret": "Try to keep this phrase a secret, as it allows anyone who knows it to access all your wallets.", @@ -156,7 +157,7 @@ "hours": "{} hours {}", "days": "{} days", "months": "{} months", - "certify": "Certify", + "certify": "Certify this\nidentity", "from": "From:", "to": "To:", "amount": "Amount:", @@ -199,5 +200,6 @@ "thisMnemonicHasBeenCopiedToClipboard": "This mnemonic has been copied to clipboard", "smithCantMigrateIdentity":"You can't migrate this identity while you're member of smith web", "received": "Received", - "sent": "Sent" + "sent": "Sent", + "createIdentity": "Create a new \nidentity" } \ No newline at end of file diff --git a/assets/translations/es.json b/assets/translations/es.json index dc66365..b8a6a03 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -72,6 +72,8 @@ "areYouSureForgetAllChests": "¿Seguro de que quieres olvidar todos tus cofres?", "areYouSureToForgetWallet": "¿Seguro de que quieres olvidar el monedero \"{}\"?", "areYouSureYouWantToCertify": "¿Seguro de que quiere certificar a la dirección\n\n{}?", + "areYouSureYouWantToCertify1": "¿Seguro de que quiere certificar a la identidad :", + "areYouSureYouWantToCertify2": " a la dirección :", "yes": "Sí", "no": "No", "keepYourMnemonicSecret": "Intenta mantener esta frase de restauración en secreto, ya que permite a cualquiera que la conozca acceder a todas tus monederos.", @@ -156,7 +158,7 @@ "hours": "{} horas {}", "days": "{} dias", "months": "{} meses", - "certify": "Certificar", + "certify": "Certificar esta\nidentidad", "from": "De:", "to": "A:", "amount": "Importe:", @@ -199,5 +201,6 @@ "thisMnemonicHasBeenCopiedToClipboard": "This mnemonic has been copied to clipboard", "smithCantMigrateIdentity":"You can't migrate this identity while you're member of smith web", "received": "Received", - "sent": "Sent" + "sent": "Sent", + "createIdentity": "Create a new \nidentity" } diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 9b75ea3..d3510bf 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -71,7 +71,8 @@ "areYouSureToDeleteWallet": "Êtes-vous sûr de vouloir supprimer le coffre \"{}\" ?", "areYouSureForgetAllChests": "Êtes-vous sûr de vouloir oublier tous vos coffres ?", "areYouSureToForgetWallet": "Êtes-vous sûr de vouloir oublier le portefeuille \"{}\" ?", - "areYouSureYouWantToCertify": "Êtes-vous certain de vouloir certifier l'adresse:\n\n{}", + "areYouSureYouWantToCertify1": "Êtes-vous certain de vouloir certifier l'identité :", + "areYouSureYouWantToCertify2": "ayant pour adresse :", "yes": "Oui", "no": "Non", "keepYourMnemonicSecret": "Tâchez de garder cette phrase bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.", @@ -157,7 +158,7 @@ "hours": "{} heures {}", "days": "{} jours", "months": "{} mois", - "certify": "Certifier", + "certify": "Certifier cette\nidentité", "from": "Depuis:", "to": "Vers:", "amount": "Montant:", @@ -200,5 +201,6 @@ "thisMnemonicHasBeenCopiedToClipboard": "Cette phrase secrète viens d'être copié dans votre presse-papier.", "smithCantMigrateIdentity":"Vous ne pouvez pas migrer cette identité\ntant que vous êtes dans la toile forgerons", "received": "Reçus", - "sent": "Envoyés" + "sent": "Envoyés", + "createIdentity": "Créer sa nouvelle\nidentité" } diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 9fadbb7..8b9de12 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -288,6 +288,9 @@ class SubstrateSdk with ChangeNotifier { result.putIfAbsent('certDelay', () => certDelayDuration); } else if (toStatus == 'Created') { result.putIfAbsent('toStatus', () => 1); + } else if (toStatus == 'noid') { + result.putIfAbsent('toStatus', () => 2); + result.putIfAbsent('canCert', () => 0); } else { result.putIfAbsent('canCert', () => 0); } diff --git a/lib/screens/common_elements.dart b/lib/screens/common_elements.dart index 89d8014..117d465 100644 --- a/lib/screens/common_elements.dart +++ b/lib/screens/common_elements.dart @@ -279,6 +279,92 @@ Future confirmPopup(BuildContext context, String title) async { ); } +Future confirmPopupCertification(BuildContext context, String question1, + String username, String question2, String address) async { + return showDialog( + context: context, + barrierDismissible: true, + builder: (BuildContext context) { + return AlertDialog( + // actionsPadding: const EdgeInsets.all(0.0), + backgroundColor: backgroundColor, + content: SizedBox( + height: 240, + child: Column( + children: [ + const SizedBox(height: 15), + Text( + question1, + textAlign: TextAlign.center, + style: + const TextStyle(fontSize: 20, fontWeight: FontWeight.w400), + ), + const SizedBox(height: 20), + Text( + username, + textAlign: TextAlign.center, + style: + const TextStyle(fontSize: 24, fontWeight: FontWeight.w500), + ), + const SizedBox(height: 20), + Text( + question2, + textAlign: TextAlign.center, + style: + const TextStyle(fontSize: 20, fontWeight: FontWeight.w400), + ), + const SizedBox(height: 20), + Text( + address, + textAlign: TextAlign.center, + style: + const TextStyle(fontSize: 20, fontWeight: FontWeight.w500), + ), + const SizedBox(height: 20), + const Text( + '?', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400), + ), + ], + ), + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + key: keyConfirm, + child: Text( + "yes".tr(), + style: const TextStyle( + fontSize: 25, + color: Color(0xffD80000), + ), + ), + onPressed: () { + Navigator.pop(context, true); + }, + ), + const SizedBox(width: 35), + TextButton( + child: Text( + "no".tr(), + style: const TextStyle(fontSize: 25), + ), + onPressed: () { + Navigator.pop(context, false); + }, + ), + const SizedBox(height: 120) + ], + ) + ], + ); + }, + ); +} + Future infoPopup(BuildContext context, String title) async { return showDialog( context: context, diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index c76a633..02bb43a 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:gecko/models/g1_wallets_list.dart'; import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/providers/cesium_plus.dart'; +import 'package:gecko/providers/duniter_indexer.dart'; import 'package:gecko/providers/home.dart'; import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/wallet_options.dart'; @@ -148,6 +149,8 @@ class WalletViewScreen extends StatelessWidget { ]), Consumer(builder: (context, sub, _) { WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); + final duniterIndexer = + Provider.of(context, listen: false); return FutureBuilder( future: sub.certState(defaultWallet.address!, address), builder: (context, AsyncSnapshot> snapshot) { @@ -211,12 +214,18 @@ class WalletViewScreen extends StatelessWidget { 'assets/gecko_certify.png')), ), onTap: () async { - final bool? result = await confirmPopup( - context, - "areYouSureYouWantToCertify".tr( - args: [ - getShortPubkey(address) - ])); + final bool? result = + await confirmPopupCertification( + context, + 'areYouSureYouWantToCertify1' + .tr(), + duniterIndexer + .walletNameIndexer[ + address] ?? + "noIdentity".tr(), + 'areYouSureYouWantToCertify2' + .tr(), + getShortPubkey(address)); if (result ?? false) { String? pin; @@ -260,7 +269,9 @@ class WalletViewScreen extends StatelessWidget { ), const SizedBox(height: 9), Text( - "certify".tr(), + toStatus == 0 + ? "certify".tr() + : "createIdentity".tr(), textAlign: TextAlign.center, style: TextStyle( fontSize: buttonFontSize, diff --git a/pubspec.yaml b/pubspec.yaml index e59a0ca..99d6f98 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: Pay with G1. # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.13+41 +version: 0.0.13+42 environment: sdk: '>=2.12.0 <3.0.0'