From 1bd4dd47b2b59d7b20d81f05ea233edb58ed9c14 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 28 Jan 2021 15:26:26 +0100 Subject: [PATCH] Fix some return lock wallets; Rename floders --- lib/main.dart | 2 +- .../history.dart} | 0 lib/{ui => screens}/home.dart | 6 +- lib/{ui => screens}/myWallets/changePin.dart | 0 .../myWallets/confirmWalletStorage.dart | 176 +++++++++++++ .../myWallets/generateWallets.dart} | 2 +- lib/screens/myWallets/walletOptions.dart | 237 ++++++++++++++++++ .../myWallets/walletsHome.dart | 4 +- .../settings.dart} | 0 lib/ui/myWallets/confirmWalletStorage.dart | 166 ------------ lib/ui/myWallets/walletOptions.dart | 231 ----------------- 11 files changed, 420 insertions(+), 404 deletions(-) rename lib/{ui/historyScreen.dart => screens/history.dart} (100%) rename lib/{ui => screens}/home.dart (95%) rename lib/{ui => screens}/myWallets/changePin.dart (100%) create mode 100644 lib/screens/myWallets/confirmWalletStorage.dart rename lib/{ui/myWallets/generateWalletsScreen.dart => screens/myWallets/generateWallets.dart} (98%) create mode 100644 lib/screens/myWallets/walletOptions.dart rename lib/{ui => screens}/myWallets/walletsHome.dart (97%) rename lib/{ui/settingsScreen.dart => screens/settings.dart} (100%) delete mode 100644 lib/ui/myWallets/confirmWalletStorage.dart delete mode 100644 lib/ui/myWallets/walletOptions.dart diff --git a/lib/main.dart b/lib/main.dart index 211f6e1..b44de91 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,7 +5,7 @@ import 'package:gecko/models/history.dart'; import 'package:gecko/models/home.dart'; import 'package:gecko/models/myWallets.dart'; import 'package:gecko/models/walletOptions.dart'; -import 'package:gecko/ui/home.dart'; +import 'package:gecko/screens/home.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; diff --git a/lib/ui/historyScreen.dart b/lib/screens/history.dart similarity index 100% rename from lib/ui/historyScreen.dart rename to lib/screens/history.dart diff --git a/lib/ui/home.dart b/lib/screens/home.dart similarity index 95% rename from lib/ui/home.dart rename to lib/screens/home.dart index d09538f..cea9ba9 100644 --- a/lib/ui/home.dart +++ b/lib/screens/home.dart @@ -1,10 +1,10 @@ import 'package:gecko/globals.dart'; import 'package:gecko/models/home.dart'; -import 'package:gecko/ui/historyScreen.dart'; +import 'package:gecko/screens/history.dart'; import 'package:flutter/material.dart'; import 'dart:ui'; -import 'package:gecko/ui/myWallets/walletsHome.dart'; -import 'package:gecko/ui/settingsScreen.dart'; +import 'package:gecko/screens/myWallets/walletsHome.dart'; +import 'package:gecko/screens/settings.dart'; import 'package:provider/provider.dart'; // ignore: must_be_immutable diff --git a/lib/ui/myWallets/changePin.dart b/lib/screens/myWallets/changePin.dart similarity index 100% rename from lib/ui/myWallets/changePin.dart rename to lib/screens/myWallets/changePin.dart diff --git a/lib/screens/myWallets/confirmWalletStorage.dart b/lib/screens/myWallets/confirmWalletStorage.dart new file mode 100644 index 0000000..f516513 --- /dev/null +++ b/lib/screens/myWallets/confirmWalletStorage.dart @@ -0,0 +1,176 @@ +import 'package:dubp/dubp.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:gecko/models/generateWallets.dart'; +import 'package:gecko/models/myWallets.dart'; +import 'package:provider/provider.dart'; + +// ignore: must_be_immutable +class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { + ConfirmStoreWallet({ + Key validationKey, + @required this.generatedMnemonic, + @required this.generatedWallet, + }) : super(key: validationKey); + + String generatedMnemonic; + NewWallet generatedWallet; + + TextEditingController _mnemonicController = TextEditingController(); + TextEditingController _pubkey = TextEditingController(); + TextEditingController _inputRestoreWord = TextEditingController(); + TextEditingController walletName = TextEditingController(); + FocusNode _wordFocus = FocusNode(); + + @override + Widget build(BuildContext context) { + GenerateWalletsProvider _generateWalletProvider = + Provider.of(context); + MyWalletsProvider _myWalletProvider = + Provider.of(context); + print("JE BUILD !!!"); + + this._mnemonicController.text = generatedMnemonic; + this._pubkey.text = generatedWallet.publicKey; + return WillPopScope( + onWillPop: () { + _generateWalletProvider.isAskedWordValid = false; + _generateWalletProvider.askedWordColor = Colors.black; + return Future.value(true); + }, + child: Scaffold( + resizeToAvoidBottomInset: false, + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back, color: Colors.black), + onPressed: () { + Navigator.of(context).pop(); + _generateWalletProvider.isAskedWordValid = false; + _generateWalletProvider.askedWordColor = Colors.black; + }), + title: SizedBox( + height: 22, + child: Text('Confirmez ce portefeuille'), + )), + body: Center( + child: Column(children: [ + SizedBox(height: 15), + Text( + 'Votre clé publique est :', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 17.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), + TextField( + enabled: false, + controller: this._pubkey, + maxLines: 1, + textAlign: TextAlign.center, + decoration: InputDecoration(), + style: TextStyle( + fontSize: 14.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + SizedBox(height: 12), + Text( + 'Quel est le ${_generateWalletProvider.nbrWord + 1}ème mot de votre phrase de restauration ?', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 17.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), + TextFormField( + focusNode: _wordFocus, + autofocus: true, + enabled: !_generateWalletProvider.isAskedWordValid, + controller: this._inputRestoreWord, + textInputAction: TextInputAction.next, + onChanged: (value) { + _generateWalletProvider.checkAskedWord( + value, _mnemonicController.text); + }, + maxLines: 1, + textAlign: TextAlign.center, + decoration: InputDecoration(), + style: TextStyle( + fontSize: 30.0, + color: _generateWalletProvider.askedWordColor, + fontWeight: FontWeight.w500)), + SizedBox(height: 12), + Text( + 'Choisissez un nom pour votre portefeuille :', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 17.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), + TextFormField( + focusNode: _generateWalletProvider.walletNameFocus, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp('[A-Za-z|0-9|\\-|_| ]')), + ], + controller: this.walletName, + textInputAction: TextInputAction.next, + onChanged: (v) { + _generateWalletProvider.nameChanged(); + }, + maxLines: 1, + textAlign: TextAlign.center, + decoration: InputDecoration(), + style: TextStyle( + fontSize: 30.0, + color: Colors.black, + fontWeight: FontWeight.w500)), + Expanded( + child: Align( + alignment: Alignment.bottomCenter, + child: SizedBox( + width: 200, + height: 50, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 12, + primary: Colors.green[ + 400], //Color(0xffFFD68E), // background + onPrimary: Colors.black, // foreground + ), + onPressed: (_generateWalletProvider + .isAskedWordValid && + this.walletName.text != '') + ? () { + _generateWalletProvider.storeWallet( + generatedWallet, + walletName.text, + context); + _generateWalletProvider.isAskedWordValid = + false; + _generateWalletProvider.askedWordColor = + Colors.black; + WidgetsBinding.instance + .addPostFrameCallback((_) { + _myWalletProvider.listWallets = + _myWalletProvider + .getAllWalletsNames(); + _myWalletProvider.rebuildWidget(); + }); + } + : null, + child: Text('Confirmer', + style: TextStyle(fontSize: 28))), + ))), + SizedBox(height: 70), + Text('TRICHE PENDANT ALPHA: ' + this._mnemonicController.text, + style: TextStyle( + fontSize: 10.0, + color: Colors.black, + fontWeight: FontWeight.normal)), + ]), + ), + )); + } +} diff --git a/lib/ui/myWallets/generateWalletsScreen.dart b/lib/screens/myWallets/generateWallets.dart similarity index 98% rename from lib/ui/myWallets/generateWalletsScreen.dart rename to lib/screens/myWallets/generateWallets.dart index d33734f..1721084 100644 --- a/lib/ui/myWallets/generateWalletsScreen.dart +++ b/lib/screens/myWallets/generateWallets.dart @@ -1,5 +1,5 @@ import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/ui/myWallets/confirmWalletStorage.dart'; +import 'package:gecko/screens/myWallets/confirmWalletStorage.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:super_tooltip/super_tooltip.dart'; diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/walletOptions.dart new file mode 100644 index 0000000..0362709 --- /dev/null +++ b/lib/screens/myWallets/walletOptions.dart @@ -0,0 +1,237 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:dubp/dubp.dart'; +import 'package:gecko/models/walletOptions.dart'; +import 'package:gecko/screens/myWallets/changePin.dart'; +import 'dart:io'; +import 'dart:async'; +import 'package:pin_code_fields/pin_code_fields.dart'; +import 'package:provider/provider.dart'; + +// ignore: must_be_immutable +class WalletOptions extends StatelessWidget with ChangeNotifier { + WalletOptions({Key keyMyWallets, @required this.walletName}) + : super(key: keyMyWallets); + String walletName; + + StreamController errorController; + Directory appPath; + TextEditingController _enterPin = new TextEditingController(); + final formKey = GlobalKey(); + bool hasError = false; + String validPin = 'NO PIN'; + var pinColor = Color(0xffF9F9F1); + var walletPin = ''; + + Future get badWallet => null; + + @override + Widget build(BuildContext context) { + WalletOptionsProvider _walletOptions = + Provider.of(context); + errorController = StreamController(); + // _walletOptions.isWalletUnlock = false; + return WillPopScope( + onWillPop: () { + _walletOptions.isWalletUnlock = false; + return Future.value(true); + }, + child: Scaffold( + resizeToAvoidBottomInset: false, + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back, color: Colors.black), + onPressed: () { + Navigator.of(context).pop(); + _walletOptions.isWalletUnlock = false; + }), + title: SizedBox( + height: 22, + child: Text(walletName), + )), + body: Center( + child: SafeArea( + child: Column(children: [ + Visibility( + visible: _walletOptions.isWalletUnlock, + child: Expanded( + child: Column(children: [ + SizedBox(height: 15), + Text( + 'Clé publique:', + style: TextStyle( + fontSize: 15.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), + SizedBox(height: 15), + Text( + _walletOptions.pubkey.text, + style: TextStyle( + fontSize: 14.0, + color: Colors.black, + fontWeight: FontWeight.bold), + ), + Expanded( + child: Align( + alignment: Alignment.bottomCenter, + child: SizedBox( + height: 50, + width: 300, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 5, + primary: Color( + 0xffFFD68E), //Color(0xffFFD68E), // background + onPrimary: Colors.black, // foreground + ), + onPressed: () => _walletOptions + .renameWalletAlerte( + context, walletName) + .then((_) { + notifyListeners(); + }), + child: Text('Renommer ce portefeuille', + style: TextStyle(fontSize: 20)))))), + SizedBox(height: 30), + SizedBox( + height: 50, + width: 300, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 5, + primary: Color( + 0xffFFD68E), //Color(0xffFFD68E), // background + onPrimary: Colors.black, // foreground + ), + onPressed: () { + // changePin(widget.walletName, this.walletPin); + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return ChangePinScreen( + walletName: walletName, + oldPin: this.walletPin); + }), + ); + }, + child: Text('Changer mon code secret', + style: TextStyle(fontSize: 20)))), + SizedBox(height: 30), + SizedBox( + height: 50, + width: 300, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 6, + primary: Colors + .redAccent, //Color(0xffFFD68E), // background + onPrimary: Colors.black, // foreground + ), + onPressed: () { + _walletOptions.deleteWallet(context, walletName); + }, + child: Text('Supprimer ce portefeuille', + style: TextStyle(fontSize: 20)))), + SizedBox(height: 50), + Text( + 'Portefeuille déverrouillé', + style: TextStyle( + color: Colors.green, + fontWeight: FontWeight.w700, + fontSize: 15), + ), + SizedBox(height: 10) + ]))), + Visibility( + visible: !_walletOptions.isWalletUnlock, + child: Expanded( + child: Column(children: [ + SizedBox(height: 80), + Text( + 'Veuillez tapper votre code secret pour dévérouiller votre portefeuille.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 15.0, + color: Colors.black, + fontWeight: FontWeight.w400), + ), + SizedBox(height: 50), + Form( + key: formKey, + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 8.0, horizontal: 30), + child: PinCodeTextField( + autoFocus: true, + appContext: context, + pastedTextStyle: TextStyle( + color: Colors.green.shade600, + fontWeight: FontWeight.bold, + ), + length: 6, + obscureText: false, + obscuringCharacter: '*', + animationType: AnimationType.fade, + validator: (v) { + if (v.length < 6) { + return "Votre code PIN fait 6 caractères"; + } else { + return null; + } + }, + pinTheme: PinTheme( + shape: PinCodeFieldShape.box, + borderRadius: BorderRadius.circular(5), + fieldHeight: 60, + fieldWidth: 50, + activeFillColor: + hasError ? Colors.orange : Colors.white, + ), + cursorColor: Colors.black, + animationDuration: Duration(milliseconds: 300), + textStyle: TextStyle(fontSize: 20, height: 1.6), + backgroundColor: pinColor, + enableActiveFill: false, + errorAnimationController: errorController, + controller: _enterPin, + keyboardType: TextInputType.text, + boxShadows: [ + BoxShadow( + offset: Offset(0, 1), + color: Colors.black12, + blurRadius: 10, + ) + ], + onCompleted: (_pin) async { + print("Completed"); + final resultWallet = + await _walletOptions.readLocalWallet( + this.walletName, _pin.toUpperCase()); + if (resultWallet == 'bad') { + errorController.add(ErrorAnimationType + .shake); // Triggering error shake animation + hasError = true; + pinColor = Colors.red[200]; + notifyListeners(); + } else { + pinColor = Colors.green[200]; + // setState(() {}); + // await Future.delayed(Duration(milliseconds: 50)); + this.walletPin = _pin.toUpperCase(); + // isWalletUnlock = true; + notifyListeners(); + } + }, + onChanged: (value) { + if (pinColor != Color(0xffF9F9F1)) { + pinColor = Color(0xffF9F9F1); + } + print(value); + }, + )), + ) + ]))), + ]))))); + } +} diff --git a/lib/ui/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart similarity index 97% rename from lib/ui/myWallets/walletsHome.dart rename to lib/screens/myWallets/walletsHome.dart index 7f44b31..3d1e5db 100644 --- a/lib/ui/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -1,7 +1,7 @@ import 'package:gecko/models/myWallets.dart'; -import 'package:gecko/ui/myWallets/generateWalletsScreen.dart'; +import 'package:gecko/screens/myWallets/generateWallets.dart'; import 'package:flutter/material.dart'; -import 'package:gecko/ui/myWallets/walletOptions.dart'; +import 'package:gecko/screens/myWallets/walletOptions.dart'; import 'package:provider/provider.dart'; // ignore: must_be_immutable diff --git a/lib/ui/settingsScreen.dart b/lib/screens/settings.dart similarity index 100% rename from lib/ui/settingsScreen.dart rename to lib/screens/settings.dart diff --git a/lib/ui/myWallets/confirmWalletStorage.dart b/lib/ui/myWallets/confirmWalletStorage.dart deleted file mode 100644 index 09d448f..0000000 --- a/lib/ui/myWallets/confirmWalletStorage.dart +++ /dev/null @@ -1,166 +0,0 @@ -import 'package:dubp/dubp.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:gecko/models/generateWallets.dart'; -import 'package:gecko/models/myWallets.dart'; -import 'package:provider/provider.dart'; - -// ignore: must_be_immutable -class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { - ConfirmStoreWallet({ - Key validationKey, - @required this.generatedMnemonic, - @required this.generatedWallet, - }) : super(key: validationKey); - - String generatedMnemonic; - NewWallet generatedWallet; - - TextEditingController _mnemonicController = TextEditingController(); - TextEditingController _pubkey = TextEditingController(); - TextEditingController _inputRestoreWord = TextEditingController(); - TextEditingController walletName = TextEditingController(); - FocusNode _wordFocus = FocusNode(); - - @override - Widget build(BuildContext context) { - GenerateWalletsProvider _generateWalletProvider = - Provider.of(context); - MyWalletsProvider _myWalletProvider = - Provider.of(context); - print("JE BUILD !!!"); - - this._mnemonicController.text = generatedMnemonic; - this._pubkey.text = generatedWallet.publicKey; - return Scaffold( - resizeToAvoidBottomInset: false, - appBar: AppBar( - leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), - onPressed: () { - Navigator.of(context).pop(); - _generateWalletProvider.isAskedWordValid = false; - _generateWalletProvider.askedWordColor = Colors.black; - }), - title: SizedBox( - height: 22, - child: Text('Confirmez ce portefeuille'), - )), - body: Center( - child: Column(children: [ - SizedBox(height: 15), - Text( - 'Votre clé publique est :', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 17.0, - color: Colors.grey[600], - fontWeight: FontWeight.w400), - ), - TextField( - enabled: false, - controller: this._pubkey, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 14.0, - color: Colors.black, - fontWeight: FontWeight.bold)), - SizedBox(height: 12), - Text( - 'Quel est le ${_generateWalletProvider.nbrWord + 1}ème mot de votre phrase de restauration ?', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 17.0, - color: Colors.grey[600], - fontWeight: FontWeight.w400), - ), - TextFormField( - focusNode: _wordFocus, - autofocus: true, - enabled: !_generateWalletProvider.isAskedWordValid, - controller: this._inputRestoreWord, - textInputAction: TextInputAction.next, - onChanged: (value) { - _generateWalletProvider.checkAskedWord( - value, _mnemonicController.text); - }, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 30.0, - color: _generateWalletProvider.askedWordColor, - fontWeight: FontWeight.w500)), - SizedBox(height: 12), - Text( - 'Choisissez un nom pour votre portefeuille :', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 17.0, - color: Colors.grey[600], - fontWeight: FontWeight.w400), - ), - TextFormField( - focusNode: _generateWalletProvider.walletNameFocus, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp('[A-Za-z|0-9|\\-|_| ]')), - ], - controller: this.walletName, - textInputAction: TextInputAction.next, - onChanged: (v) { - _generateWalletProvider.nameChanged(); - }, - maxLines: 1, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 30.0, - color: Colors.black, - fontWeight: FontWeight.w500)), - Expanded( - child: Align( - alignment: Alignment.bottomCenter, - child: SizedBox( - width: 200, - height: 50, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - elevation: 12, - primary: Colors - .green[400], //Color(0xffFFD68E), // background - onPrimary: Colors.black, // foreground - ), - onPressed: (_generateWalletProvider.isAskedWordValid && - this.walletName.text != '') - ? () { - _generateWalletProvider.storeWallet( - generatedWallet, walletName.text, context); - _generateWalletProvider.isAskedWordValid = - false; - _generateWalletProvider.askedWordColor = - Colors.black; - WidgetsBinding.instance - .addPostFrameCallback((_) { - _myWalletProvider.listWallets = - _myWalletProvider.getAllWalletsNames(); - _myWalletProvider.rebuildWidget(); - }); - } - : null, - child: - Text('Confirmer', style: TextStyle(fontSize: 28))), - ))), - SizedBox(height: 70), - Text('TRICHE PENDANT ALPHA: ' + this._mnemonicController.text, - style: TextStyle( - fontSize: 10.0, - color: Colors.black, - fontWeight: FontWeight.normal)), - ]), - ), - ); - } -} diff --git a/lib/ui/myWallets/walletOptions.dart b/lib/ui/myWallets/walletOptions.dart deleted file mode 100644 index 2ad5a5b..0000000 --- a/lib/ui/myWallets/walletOptions.dart +++ /dev/null @@ -1,231 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:dubp/dubp.dart'; -import 'package:gecko/models/walletOptions.dart'; -import 'package:gecko/ui/myWallets/changePin.dart'; -import 'dart:io'; -import 'dart:async'; -import 'package:pin_code_fields/pin_code_fields.dart'; -import 'package:provider/provider.dart'; - -// ignore: must_be_immutable -class WalletOptions extends StatelessWidget with ChangeNotifier { - WalletOptions({Key keyMyWallets, @required this.walletName}) - : super(key: keyMyWallets); - String walletName; - - StreamController errorController; - Directory appPath; - TextEditingController _enterPin = new TextEditingController(); - final formKey = GlobalKey(); - bool hasError = false; - String validPin = 'NO PIN'; - var pinColor = Color(0xffF9F9F1); - var walletPin = ''; - - Future get badWallet => null; - - @override - Widget build(BuildContext context) { - WalletOptionsProvider _walletOptions = - Provider.of(context); - errorController = StreamController(); - // _walletOptions.isWalletUnlock = false; - return Scaffold( - resizeToAvoidBottomInset: false, - appBar: AppBar( - leading: IconButton( - icon: Icon(Icons.arrow_back, color: Colors.black), - onPressed: () { - Navigator.of(context).pop(); - _walletOptions.isWalletUnlock = false; - }), - title: SizedBox( - height: 22, - child: Text(walletName), - )), - body: Center( - child: SafeArea( - child: Column(children: [ - Visibility( - visible: _walletOptions.isWalletUnlock, - child: Expanded( - child: Column(children: [ - SizedBox(height: 15), - Text( - 'Clé publique:', - style: TextStyle( - fontSize: 15.0, - color: Colors.grey[600], - fontWeight: FontWeight.w400), - ), - SizedBox(height: 15), - Text( - _walletOptions.pubkey.text, - style: TextStyle( - fontSize: 14.0, - color: Colors.black, - fontWeight: FontWeight.bold), - ), - Expanded( - child: Align( - alignment: Alignment.bottomCenter, - child: SizedBox( - height: 50, - width: 300, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - elevation: 5, - primary: Color( - 0xffFFD68E), //Color(0xffFFD68E), // background - onPrimary: Colors.black, // foreground - ), - onPressed: () => _walletOptions - .renameWalletAlerte(context, walletName) - .then((_) { - notifyListeners(); - }), - child: Text('Renommer ce portefeuille', - style: TextStyle(fontSize: 20)))))), - SizedBox(height: 30), - SizedBox( - height: 50, - width: 300, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - elevation: 5, - primary: Color( - 0xffFFD68E), //Color(0xffFFD68E), // background - onPrimary: Colors.black, // foreground - ), - onPressed: () { - // changePin(widget.walletName, this.walletPin); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return ChangePinScreen( - walletName: walletName, - oldPin: this.walletPin); - }), - ); - }, - child: Text('Changer mon code secret', - style: TextStyle(fontSize: 20)))), - SizedBox(height: 30), - SizedBox( - height: 50, - width: 300, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - elevation: 6, - primary: Colors - .redAccent, //Color(0xffFFD68E), // background - onPrimary: Colors.black, // foreground - ), - onPressed: () { - _walletOptions.deleteWallet(context, walletName); - }, - child: Text('Supprimer ce portefeuille', - style: TextStyle(fontSize: 20)))), - SizedBox(height: 50), - Text( - 'Portefeuille déverrouillé', - style: TextStyle( - color: Colors.green, - fontWeight: FontWeight.w700, - fontSize: 15), - ), - SizedBox(height: 10) - ]))), - Visibility( - visible: !_walletOptions.isWalletUnlock, - child: Expanded( - child: Column(children: [ - SizedBox(height: 80), - Text( - 'Veuillez tapper votre code secret pour dévérouiller votre portefeuille.', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 15.0, - color: Colors.black, - fontWeight: FontWeight.w400), - ), - SizedBox(height: 50), - Form( - key: formKey, - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 8.0, horizontal: 30), - child: PinCodeTextField( - autoFocus: true, - appContext: context, - pastedTextStyle: TextStyle( - color: Colors.green.shade600, - fontWeight: FontWeight.bold, - ), - length: 6, - obscureText: false, - obscuringCharacter: '*', - animationType: AnimationType.fade, - validator: (v) { - if (v.length < 6) { - return "Votre code PIN fait 6 caractères"; - } else { - return null; - } - }, - pinTheme: PinTheme( - shape: PinCodeFieldShape.box, - borderRadius: BorderRadius.circular(5), - fieldHeight: 60, - fieldWidth: 50, - activeFillColor: - hasError ? Colors.orange : Colors.white, - ), - cursorColor: Colors.black, - animationDuration: Duration(milliseconds: 300), - textStyle: TextStyle(fontSize: 20, height: 1.6), - backgroundColor: pinColor, - enableActiveFill: false, - errorAnimationController: errorController, - controller: _enterPin, - keyboardType: TextInputType.text, - boxShadows: [ - BoxShadow( - offset: Offset(0, 1), - color: Colors.black12, - blurRadius: 10, - ) - ], - onCompleted: (_pin) async { - print("Completed"); - final resultWallet = - await _walletOptions.readLocalWallet( - this.walletName, _pin.toUpperCase()); - if (resultWallet == 'bad') { - errorController.add(ErrorAnimationType - .shake); // Triggering error shake animation - hasError = true; - pinColor = Colors.red[200]; - notifyListeners(); - } else { - pinColor = Colors.green[200]; - // setState(() {}); - // await Future.delayed(Duration(milliseconds: 50)); - this.walletPin = _pin.toUpperCase(); - // isWalletUnlock = true; - notifyListeners(); - } - }, - onChanged: (value) { - if (pinColor != Color(0xffF9F9F1)) { - pinColor = Color(0xffF9F9F1); - } - print(value); - }, - )), - ) - ]))), - ])))); - } -}