Display mnemonic in array of 12 worlds

This commit is contained in:
poka 2021-02-28 06:04:22 +01:00
parent 2f7313ec1c
commit fb11550ecc
2 changed files with 114 additions and 25 deletions

View File

@ -279,6 +279,22 @@ class GenerateWalletsProvider with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future<List<String>> generateWordList() async {
final String _sentance = await generateMnemonic();
List<String> _wordsList = [];
String word;
int _nbr = 1;
for (word in _sentance.split(' ')) {
// print(word);
_wordsList.add("$_nbr:$word");
_nbr++;
}
// notifyListeners();
return _wordsList;
}
// void makeError() { // void makeError() {
// var tata = File(appPath.path + '/ddfhjftjfg'); // var tata = File(appPath.path + '/ddfhjftjfg');
// tata.readAsLinesSync(); // tata.readAsLinesSync();

View File

@ -15,7 +15,7 @@ class OnboardingStepNine extends StatelessWidget {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider = GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context); Provider.of<GenerateWalletsProvider>(context);
_generateWalletProvider.generateMnemonic(); // _generateWalletProvider.generateMnemonic();
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
@ -71,23 +71,19 @@ class OnboardingStepNine extends StatelessWidget {
), ),
), ),
SizedBox(height: 64), SizedBox(height: 64),
// Row(children: <Widget>[ // TextField(
// Align( // enabled: false,
// alignment: Alignment.centerRight, // controller: _generateWalletProvider.mnemonicController,
// child: // maxLines: 3,
TextField( // textAlign: TextAlign.center,
enabled: false, // decoration: InputDecoration(
controller: _generateWalletProvider.mnemonicController, // contentPadding: EdgeInsets.all(15.0),
maxLines: 3, // ),
textAlign: TextAlign.center, // style: TextStyle(
decoration: InputDecoration( // fontSize: 22.0,
contentPadding: EdgeInsets.all(15.0), // color: Colors.black,
), // fontWeight: FontWeight.w400)),
style: TextStyle( sentanceArray(context),
fontSize: 22.0,
color: Colors.black,
fontWeight: FontWeight.w400)),
// ]),
Expanded( Expanded(
child: Align( child: Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
@ -97,18 +93,34 @@ class OnboardingStepNine extends StatelessWidget {
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
elevation: 5, elevation: 5,
primary: Color(0xffD28928), primary: Color(0xffFFD58D),
onPrimary: Colors.white, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () { onPressed: () {
// Navigator.push( _generateWalletProvider.reloadBuild();
// context,
// SmoothTransition(page: OnboardingStepNince()),
// );
}, },
child: Text("J'ai noté ma phrase", child: Text("Choisir une autre phrase",
style: TextStyle(fontSize: 20))), 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), SizedBox(height: 80),
]), ]),
)); ));
@ -144,3 +156,64 @@ class GeckoSpeechAppBar extends StatelessWidget with PreferredSizeWidget {
)); ));
} }
} }
// _generateWalletProvider
Widget sentanceArray(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(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: <Widget>[
Row(children: <Widget>[
arrayCell(formatedArray.data[0]),
arrayCell(formatedArray.data[1]),
arrayCell(formatedArray.data[2]),
arrayCell(formatedArray.data[3]),
]),
SizedBox(height: 15),
Row(children: <Widget>[
arrayCell(formatedArray.data[4]),
arrayCell(formatedArray.data[5]),
arrayCell(formatedArray.data[6]),
arrayCell(formatedArray.data[7]),
]),
SizedBox(height: 15),
Row(children: <Widget>[
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: <Widget>[
Text(dataWord.split(':')[0], style: TextStyle(fontSize: 12)),
SizedBox(height: 2),
Text(dataWord.split(':')[1],
style: TextStyle(fontSize: 16, color: Colors.black)),
]));
}