From fb11550ecc0217bcdefecb4ed36c1113c625a108 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 28 Feb 2021 06:04:22 +0100 Subject: [PATCH] Display mnemonic in array of 12 worlds --- lib/models/generateWallets.dart | 16 ++++ lib/screens/onBoarding/9_stepNine.dart | 123 ++++++++++++++++++++----- 2 files changed, 114 insertions(+), 25 deletions(-) diff --git a/lib/models/generateWallets.dart b/lib/models/generateWallets.dart index c7b7281..a95dde0 100644 --- a/lib/models/generateWallets.dart +++ b/lib/models/generateWallets.dart @@ -279,6 +279,22 @@ class GenerateWalletsProvider with ChangeNotifier { notifyListeners(); } + Future> generateWordList() async { + final String _sentance = await generateMnemonic(); + List _wordsList = []; + String word; + int _nbr = 1; + + for (word in _sentance.split(' ')) { + // print(word); + _wordsList.add("$_nbr:$word"); + _nbr++; + } + // notifyListeners(); + + return _wordsList; + } + // void makeError() { // var tata = File(appPath.path + '/ddfhjftjfg'); // tata.readAsLinesSync(); diff --git a/lib/screens/onBoarding/9_stepNine.dart b/lib/screens/onBoarding/9_stepNine.dart index 973f967..390ba6e 100644 --- a/lib/screens/onBoarding/9_stepNine.dart +++ b/lib/screens/onBoarding/9_stepNine.dart @@ -15,7 +15,7 @@ class OnboardingStepNine extends StatelessWidget { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); GenerateWalletsProvider _generateWalletProvider = Provider.of(context); - _generateWalletProvider.generateMnemonic(); + // _generateWalletProvider.generateMnemonic(); return Scaffold( extendBodyBehindAppBar: true, @@ -71,23 +71,19 @@ class OnboardingStepNine extends StatelessWidget { ), ), SizedBox(height: 64), - // Row(children: [ - // Align( - // alignment: Alignment.centerRight, - // child: - TextField( - enabled: false, - controller: _generateWalletProvider.mnemonicController, - maxLines: 3, - textAlign: TextAlign.center, - decoration: InputDecoration( - contentPadding: EdgeInsets.all(15.0), - ), - style: TextStyle( - fontSize: 22.0, - color: Colors.black, - fontWeight: FontWeight.w400)), - // ]), + // TextField( + // enabled: false, + // controller: _generateWalletProvider.mnemonicController, + // maxLines: 3, + // textAlign: TextAlign.center, + // decoration: InputDecoration( + // contentPadding: EdgeInsets.all(15.0), + // ), + // style: TextStyle( + // fontSize: 22.0, + // color: Colors.black, + // fontWeight: FontWeight.w400)), + sentanceArray(context), Expanded( child: Align( alignment: Alignment.bottomCenter, @@ -97,18 +93,34 @@ class OnboardingStepNine extends StatelessWidget { child: ElevatedButton( style: ElevatedButton.styleFrom( elevation: 5, - primary: Color(0xffD28928), - onPrimary: Colors.white, // foreground + primary: Color(0xffFFD58D), + onPrimary: Colors.black, // foreground ), onPressed: () { - // Navigator.push( - // context, - // SmoothTransition(page: OnboardingStepNince()), - // ); + _generateWalletProvider.reloadBuild(); }, - child: Text("J'ai noté ma phrase", + child: Text("Choisir une autre phrase", style: TextStyle(fontSize: 20))), ))), + SizedBox(height: 20), + SizedBox( + width: 350, + height: 55, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 5, + primary: Color(0xffD28928), + onPrimary: Colors.white, // foreground + ), + onPressed: () { + // Navigator.push( + // context, + // SmoothTransition(page: OnboardingStepNince()), + // ); + }, + child: Text("J'ai noté ma phrase", + style: TextStyle(fontSize: 20))), + ), SizedBox(height: 80), ]), )); @@ -144,3 +156,64 @@ class GeckoSpeechAppBar extends StatelessWidget with PreferredSizeWidget { )); } } + +// _generateWalletProvider + +Widget sentanceArray(BuildContext context) { + GenerateWalletsProvider _generateWalletProvider = + Provider.of(context); + + return FutureBuilder( + future: _generateWalletProvider.generateWordList(), + initialData: '::::::::::::', + builder: (context, formatedArray) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Container( + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.all( + const Radius.circular(10), + )), + // color: Colors.grey[300], + padding: EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row(children: [ + arrayCell(formatedArray.data[0]), + arrayCell(formatedArray.data[1]), + arrayCell(formatedArray.data[2]), + arrayCell(formatedArray.data[3]), + ]), + SizedBox(height: 15), + Row(children: [ + arrayCell(formatedArray.data[4]), + arrayCell(formatedArray.data[5]), + arrayCell(formatedArray.data[6]), + arrayCell(formatedArray.data[7]), + ]), + SizedBox(height: 15), + Row(children: [ + arrayCell(formatedArray.data[8]), + arrayCell(formatedArray.data[9]), + arrayCell(formatedArray.data[10]), + arrayCell(formatedArray.data[11]), + ]), + ]))); + }); +} + +Widget arrayCell(dataWord) { + print(dataWord); + return Container( + width: 80, + child: Column(children: [ + Text(dataWord.split(':')[0], style: TextStyle(fontSize: 12)), + SizedBox(height: 2), + Text(dataWord.split(':')[1], + style: TextStyle(fontSize: 16, color: Colors.black)), + ])); +}