diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7bf1ee6..101936c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ - + { DubpRust.setup(); } - TextEditingController _mnemonic = new TextEditingController(); + TextEditingController _mnemonicController = new TextEditingController(); TextEditingController _pubkey = new TextEditingController(); TextEditingController _pin = new TextEditingController(); + String generatedMnemonic; + NewWallet actualWallet; final formKey = GlobalKey(); @override Widget build(BuildContext context) { return SafeArea( child: Column(children: [ - TextField( - enabled: false, - controller: this._mnemonic, - maxLines: 2, - textAlign: TextAlign.center, - decoration: InputDecoration(), - style: TextStyle( - fontSize: 15.0, - color: Colors.black, - fontWeight: FontWeight.bold)), + SizedBox(height: 8), + Text( + 'Clé publique:', + style: TextStyle( + fontSize: 15.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), TextField( enabled: false, controller: this._pubkey, @@ -46,6 +46,34 @@ class _GenerateWalletState extends State { fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.bold)), + SizedBox(height: 8), + Text( + 'Phrase secrète:', + style: TextStyle( + fontSize: 15.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), + TextField( + enabled: false, + controller: this._mnemonicController, + maxLines: 3, + textAlign: TextAlign.center, + decoration: InputDecoration( + contentPadding: EdgeInsets.all(15.0), + ), + style: TextStyle( + fontSize: 22.0, + color: Colors.black, + fontWeight: FontWeight.w400)), + SizedBox(height: 8), + Text( + 'Code PIN:', + style: TextStyle( + fontSize: 15.0, + color: Colors.grey[600], + fontWeight: FontWeight.w400), + ), TextField( enabled: false, controller: this._pin, @@ -53,21 +81,47 @@ class _GenerateWalletState extends State { textAlign: TextAlign.center, decoration: InputDecoration(), style: TextStyle( - fontSize: 20.0, + fontSize: 30.0, color: Colors.black, fontWeight: FontWeight.bold)), SizedBox(height: 12), new RaisedButton( + color: Color(0xffFFD68E), onPressed: () => generateMnemonic(), child: Text('Générer un wallet', style: TextStyle(fontSize: 20))), - SizedBox(height: 20) + SizedBox(height: 30), + Expanded( + child: Align( + alignment: Alignment.bottomCenter, + child: new RaisedButton( + color: Color(0xffFFD68E), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) { + return ValidStoreWalletScreen( + generatedMnemonic: this.generatedMnemonic, + generatedWallet: + this.actualWallet); //, this.actualWallet); + }), + ).then((value) => setState(() { + if (value) { + _pin.clear(); + _mnemonicController.clear(); + _pubkey.clear(); + } + })); + }, + child: Text('Enregistrer ce wallet', + style: TextStyle(fontSize: 20))))), + SizedBox(height: 15) ])); } Future generateMnemonic() async { - String generatedMnemonic; try { - generatedMnemonic = await DubpRust.genMnemonic(language: Language.french); + this.generatedMnemonic = + await DubpRust.genMnemonic(language: Language.french); } catch (e, stack) { print(e); if (kReleaseMode) { @@ -77,15 +131,13 @@ class _GenerateWalletState extends State { ); } } - - generateWallet(generatedMnemonic); + this.actualWallet = await generateWallet(this.generatedMnemonic); + return this.generatedMnemonic; } Future generateWallet(generatedMnemonic) async { - final walletFile = await _localWallet; - NewWallet newWallet; try { - newWallet = await DubpRust.genWalletFromMnemonic( + this.actualWallet = await DubpRust.genWalletFromMnemonic( language: Language.french, mnemonic: generatedMnemonic); } catch (e, stack) { print(e); @@ -98,12 +150,82 @@ class _GenerateWalletState extends State { } setState(() { - this._mnemonic.text = generatedMnemonic; - this._pubkey.text = newWallet.publicKey; - this._pin.text = newWallet.pin; + this._mnemonicController.text = generatedMnemonic; + this._pubkey.text = actualWallet.publicKey; + this._pin.text = actualWallet.pin; }); - return walletFile.writeAsString('${newWallet.dewif}'); + return actualWallet; + } +} + +class ValidStoreWalletScreen extends StatefulWidget { + final String generatedMnemonic; + final NewWallet generatedWallet; + + ValidStoreWalletScreen( + {Key validationKey, + @required this.generatedMnemonic, + @required this.generatedWallet}) + : super(key: validationKey); + + @override + _ValidStoreWalletScreen createState() => _ValidStoreWalletScreen(); +} + +class _ValidStoreWalletScreen extends State { + void initState() { + super.initState(); + // DubpRust.setup(); + this._mnemonicController.text = widget.generatedMnemonic; + this._pubkey.text = widget.generatedWallet.publicKey; + } + + TextEditingController _mnemonicController = new TextEditingController(); + TextEditingController _pubkey = new TextEditingController(); + TextEditingController _pin = new TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(), + body: Center( + child: Column(children: [ + TextField( + enabled: false, + controller: this._mnemonicController, + maxLines: 2, + textAlign: TextAlign.center, + decoration: InputDecoration(), + style: TextStyle( + fontSize: 15.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + TextField( + enabled: false, + controller: this._pubkey, + maxLines: 1, + textAlign: TextAlign.center, + decoration: InputDecoration(), + style: TextStyle( + fontSize: 14.0, + color: Colors.black, + fontWeight: FontWeight.bold)), + new RaisedButton( + color: Color(0xffFFD68E), + onPressed: () => storeWallet(widget.generatedWallet), + child: Text('Confirmer', style: TextStyle(fontSize: 20))), + ]), + ), + ); + } + + Future storeWallet(actualWallet) async { + final walletFile = await _localWallet; + walletFile.writeAsString('${widget.generatedWallet.dewif}'); + _pin.clear(); + Navigator.pop(context, true); + FocusScope.of(context).unfocus(); } Future get _localPath async { diff --git a/lib/ui/historyScreen.dart b/lib/ui/historyScreen.dart index 69506f4..7569a6f 100644 --- a/lib/ui/historyScreen.dart +++ b/lib/ui/historyScreen.dart @@ -64,6 +64,7 @@ class HistoryScreenState extends State { print('Build this.pubkey : ' + this.pubkey); print('isBuilding: ' + isBuilding.toString()); return Column(children: [ + SizedBox(height: 8), TextField( // Entrée de la pubkey onChanged: (text) { @@ -84,10 +85,7 @@ class HistoryScreenState extends State { errorBorder: InputBorder.none, disabledBorder: InputBorder.none, ), - style: TextStyle( - fontSize: 15.0, - color: Colors.black, - fontWeight: FontWeight.bold)), + style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold)), historyQuery(), ]); } @@ -186,7 +184,7 @@ class HistoryScreenState extends State { if (this.pubkey != '') Text(balance.toString() + ' Ğ1', textAlign: TextAlign.center, - style: TextStyle(fontSize: 30.0, color: Colors.black)), + style: TextStyle(fontSize: 30.0)), for (var repository in _transBC) ListTile( contentPadding: const EdgeInsets.all(5.0), diff --git a/lib/ui/home.dart b/lib/ui/home.dart index 6589777..171397a 100644 --- a/lib/ui/home.dart +++ b/lib/ui/home.dart @@ -31,9 +31,8 @@ class HomeScreenState extends State { @override Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - backgroundColor: Colors.grey[300], + return Scaffold( + backgroundColor: Color(0xffF9F9F1), body: SafeArea( child: IndexedStack( index: currentIndex, @@ -62,12 +61,15 @@ class HomeScreenState extends State { height: 40.0, width: 40.0, child: Image.asset('images/scanner.png')), - backgroundColor: Color.fromARGB(500, 204, 255, 255), + backgroundColor: Color( + 0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255), ), ), ), bottomNavigationBar: BottomNavigationBar( - fixedColor: Colors.black, + backgroundColor: Color(0xffFFD68E), + fixedColor: Color(0xff855F2D), + unselectedItemColor: Color(0xffBD935C), type: BottomNavigationBarType.fixed, onTap: onTabTapped, currentIndex: currentIndex, @@ -86,6 +88,6 @@ class HomeScreenState extends State { ) ], ), - )); + ); } } diff --git a/lib/ui/myWallets.dart b/lib/ui/myWallets.dart index 73b325a..e84bf08 100644 --- a/lib/ui/myWallets.dart +++ b/lib/ui/myWallets.dart @@ -30,12 +30,13 @@ class _MyWalletState extends State { bool hasError = false; String validPin = 'NO PIN'; String currentText = ""; - var pinColor = Colors.grey[300]; + var pinColor = Color(0xffF9F9F1); @override Widget build(BuildContext context) { return SafeArea( child: Column(children: [ + SizedBox(height: 8), InkWell( child: TextField( enabled: false, @@ -113,9 +114,9 @@ class _MyWalletState extends State { } }, onChanged: (value) { - if (pinColor != Colors.grey[300]) { + if (pinColor != Color(0xffF9F9F1)) { setState(() { - pinColor = Colors.grey[300]; + pinColor = Color(0xffF9F9F1); }); } print(value); diff --git a/pubspec.yaml b/pubspec.yaml index 29917e6..785cb38 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: A new Flutter project. # 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.0+7 +version: 0.0.0+8 environment: sdk: ">=2.7.0 <3.0.0" @@ -29,10 +29,10 @@ dependencies: flutter_icons: - android: "launcher_icon" + android: "ic_launcher" ios: true - image_path: "assets/icon/gecko5b96.png" - cupertino_icons: ^1.0.0 + image_path: "assets/icon/gecko5bduniter2.png" + # cupertino_icons: ^1.0.0 dev_dependencies: flutter_test: