gecko/lib/screens/onBoarding/9_stepNine.dart

183 lines
6.7 KiB
Dart
Raw Normal View History

2021-02-28 02:38:52 +01:00
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
2021-02-28 02:38:52 +01:00
import 'package:gecko/models/generateWallets.dart';
import 'package:gecko/screens/commonElements.dart';
import 'package:gecko/screens/onBoarding/10_stepTen.dart';
2021-02-28 06:22:44 +01:00
import 'package:printing/printing.dart';
2021-02-28 02:38:52 +01:00
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class OnboardingStepNine extends StatelessWidget {
TextEditingController tplController = TextEditingController();
2021-03-08 01:08:26 +01:00
final int progress = 6;
2021-02-28 02:38:52 +01:00
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
CommonElements common = CommonElements();
2021-02-28 06:04:22 +01:00
// _generateWalletProvider.generateMnemonic();
2021-02-28 02:38:52 +01:00
return Scaffold(
extendBodyBehindAppBar: true,
body: SafeArea(
child: Column(children: <Widget>[
common.onboardingProgressBar('Ma phrase de restauration', progress),
common.bubbleSpeak(
"Cest le moment de noter votre phrase !",
long: 60,
2021-02-28 02:38:52 +01:00
),
SizedBox(height: isTall ? 100 : 70),
2021-02-28 06:04:22 +01:00
sentanceArray(context),
SizedBox(height: isTall ? 20 : 15),
2021-02-28 06:22:44 +01:00
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return PrintWallet(
_generateWalletProvider.generatedMnemonic);
}),
);
},
child: Image.asset(
'assets/printer.png',
),
),
2021-02-28 02:38:52 +01:00
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 400,
height: 62,
2021-02-28 02:38:52 +01:00
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 5,
2021-02-28 06:04:22 +01:00
primary: Color(0xffFFD58D),
onPrimary: Colors.black, // foreground
2021-02-28 02:38:52 +01:00
),
onPressed: () {
2021-02-28 06:04:22 +01:00
_generateWalletProvider.reloadBuild();
2021-02-28 02:38:52 +01:00
},
2021-02-28 06:04:22 +01:00
child: Text("Choisir une autre phrase",
2021-02-28 02:38:52 +01:00
style: TextStyle(fontSize: 20))),
))),
2021-02-28 06:22:44 +01:00
SizedBox(height: 25),
2021-02-28 06:04:22 +01:00
SizedBox(
width: 400,
height: 62,
2021-02-28 06:04:22 +01:00
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Color(0xffD28928),
onPrimary: Colors.white, // foreground
),
onPressed: () {
_generateWalletProvider.nbrWord =
_generateWalletProvider.getRandomInt();
_generateWalletProvider.nbrWordAlpha =
_generateWalletProvider
.intToString(_generateWalletProvider.nbrWord + 1);
Navigator.push(
context,
SmoothTransition(
page: OnboardingStepTen(
generatedMnemonic:
_generateWalletProvider.generatedMnemonic,
generatedWallet:
_generateWalletProvider.actualWallet)),
);
2021-02-28 06:04:22 +01:00
},
child: Text("J'ai noté ma phrase",
style: TextStyle(fontSize: 20))),
),
2021-02-28 02:38:52 +01:00
SizedBox(height: 80),
]),
));
}
}
2021-02-28 06:04:22 +01:00
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(
2021-02-28 06:22:44 +01:00
border: Border.all(color: Colors.black),
2021-02-28 06:04:22 +01:00
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) {
return Container(
width: 102,
2021-02-28 06:04:22 +01:00
child: Column(children: <Widget>[
Text(dataWord.split(':')[0], style: TextStyle(fontSize: 14)),
2021-02-28 06:04:22 +01:00
SizedBox(height: 2),
Text(dataWord.split(':')[1],
style: TextStyle(fontSize: 19, color: Colors.black)),
2021-02-28 06:04:22 +01:00
]));
}
2021-02-28 06:22:44 +01:00
// ignore: must_be_immutable
class PrintWallet extends StatelessWidget {
PrintWallet(this.sentence);
final String sentence;
@override
Widget build(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Imprimer ce trousseau')),
body: PdfPreview(
build: (format) => _generateWalletProvider.printWallet(sentence),
),
),
);
}
}