2021-11-14 19:21:20 +01:00
// ignore_for_file: file_names
2021-02-28 02:38:52 +01:00
import ' package:flutter/services.dart ' ;
import ' package:flutter/material.dart ' ;
2021-03-08 00:32:18 +01:00
import ' package:gecko/globals.dart ' ;
2022-05-23 10:53:44 +02:00
import ' package:gecko/providers/generate_wallets.dart ' ;
2021-11-14 19:21:20 +01:00
import ' package:gecko/screens/common_elements.dart ' ;
2021-03-08 06:21:04 +01:00
import ' package:gecko/screens/onBoarding/7.dart ' ;
2022-05-25 20:40:25 +02:00
import ' package:gecko/screens/onBoarding/9.dart ' ;
2022-05-23 10:53:44 +02:00
import ' package:provider/provider.dart ' ;
2021-02-28 02:38:52 +01:00
// ignore: must_be_immutable
2022-05-23 10:53:44 +02:00
class OnboardingStepSix extends StatelessWidget {
2022-05-25 20:40:25 +02:00
OnboardingStepSix (
{ Key ? key , required this . skipIntro , required this . generatedMnemonic } )
2022-05-23 10:53:44 +02:00
: super ( key: key ) ;
2021-02-28 02:38:52 +01:00
2022-05-25 20:40:25 +02:00
final bool skipIntro ;
2022-05-23 10:53:44 +02:00
String ? generatedMnemonic ;
TextEditingController wordController = TextEditingController ( ) ;
final TextEditingController _mnemonicController = TextEditingController ( ) ;
2021-11-14 19:21:20 +01:00
2021-02-28 02:38:52 +01:00
@ override
Widget build ( BuildContext context ) {
SystemChrome . setPreferredOrientations ( [ DeviceOrientation . portraitUp ] ) ;
2022-05-23 10:53:44 +02:00
GenerateWalletsProvider _generateWalletProvider =
Provider . of < GenerateWalletsProvider > ( context , listen: true ) ;
2021-03-01 04:48:28 +01:00
CommonElements common = CommonElements ( ) ;
2022-05-23 10:53:44 +02:00
_mnemonicController . text = generatedMnemonic ! ;
2021-03-01 04:48:28 +01:00
2022-05-23 10:53:44 +02:00
return WillPopScope (
onWillPop: ( ) {
_generateWalletProvider . isAskedWordValid = false ;
_generateWalletProvider . askedWordColor = Colors . black ;
return Future < bool > . value ( true ) ;
} ,
child: Scaffold (
2022-05-29 00:00:57 +02:00
backgroundColor: backgroundColor ,
2022-05-23 10:53:44 +02:00
resizeToAvoidBottomInset: false ,
2021-02-28 02:38:52 +01:00
extendBodyBehindAppBar: true ,
2022-05-23 10:53:44 +02:00
appBar: AppBar (
toolbarHeight: 60 * ratio ,
title: const SizedBox (
height: 22 ,
child: Text (
' Votre phrase de restauration ' ,
style: TextStyle ( fontWeight: FontWeight . w600 ) ,
2021-02-28 02:38:52 +01:00
) ,
2022-05-23 10:53:44 +02:00
) ,
) ,
body: SafeArea (
child: Align (
alignment: Alignment . topCenter ,
child: Column ( children: [
SizedBox ( height: isTall ? 40 : 20 ) ,
common . buildProgressBar ( 5 ) ,
SizedBox ( height: isTall ? 40 : 20 ) ,
2022-06-17 21:50:18 +02:00
common . buildText (
" Avez-vous bien noté votre phrase de restauration ? \n \n Pour en être sûr, veuillez taper dans le champ ci-dessous le ** ${ _generateWalletProvider . nbrWord + 1 } ème mot** de votre phrase de restauration : " ,
20 ,
true ) ,
2022-05-23 10:53:44 +02:00
SizedBox ( height: isTall ? 70 : 20 ) ,
Text ( ' ${ _generateWalletProvider . nbrWord + 1 } ' ,
key: const Key ( ' askedWord ' ) ,
style: TextStyle (
fontSize: isTall ? 17 : 15 ,
color: orangeC ,
fontWeight: FontWeight . w400 ) ) ,
const SizedBox ( height: 10 ) ,
Container (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 7 ) ,
border: Border . all (
color: Colors . grey [ 600 ] ! ,
width: 3 ,
) ) ,
width: 430 ,
child: TextFormField (
key: const Key ( ' inputWord ' ) ,
autofocus: true ,
enabled: ! _generateWalletProvider . isAskedWordValid ,
controller: wordController ,
textInputAction: TextInputAction . next ,
onChanged: ( value ) {
_generateWalletProvider . checkAskedWord (
value , _mnemonicController . text ) ;
} ,
maxLines: 1 ,
textAlign: TextAlign . center ,
decoration: InputDecoration (
labelStyle: TextStyle (
fontSize: 22.0 ,
color: Colors . grey [ 500 ] ,
fontWeight: FontWeight . w500 ) ,
labelText: _generateWalletProvider . isAskedWordValid
? " C'est le bon mot ! "
: " ${ _generateWalletProvider . nbrWordAlpha } mot de votre phrase de restauration " ,
fillColor: const Color ( 0xffeeeedd ) ,
filled: true ,
contentPadding: const EdgeInsets . all ( 12 ) ,
) ,
style: TextStyle (
fontSize: 40.0 ,
color: _generateWalletProvider . askedWordColor ,
fontWeight: FontWeight . w500 ) ) ) ,
Visibility (
visible: _generateWalletProvider . isAskedWordValid ,
child: Expanded (
child: Align (
2021-02-28 02:38:52 +01:00
alignment: Alignment . bottomCenter ,
2022-05-25 20:40:25 +02:00
child: nextButton (
context ,
' Continuer ' ,
skipIntro
? const OnboardingStepNine ( )
: const OnboardingStepSeven ( ) ,
false ) ,
2022-05-23 10:53:44 +02:00
) ,
) ,
) ,
// Visibility(
// visible: !_generateWalletProvider.isAskedWordValid,
// child: const Expanded(
// child: Align(
// alignment: Alignment.bottomCenter,
// child: Text(''),
// ),
// ),
// ),
2022-05-25 20:40:25 +02:00
SizedBox ( height: 35 * ratio ) ,
2022-05-23 10:53:44 +02:00
] ) ,
) ,
) ,
) ,
) ;
2021-02-28 02:38:52 +01:00
}
}
2021-02-28 07:12:10 +01:00
Widget sentanceArray ( BuildContext context ) {
2022-05-23 10:53:44 +02:00
GenerateWalletsProvider _generateWalletProvider =
Provider . of < GenerateWalletsProvider > ( context ) ;
2021-12-23 21:44:24 +01:00
return Padding (
2022-05-23 10:53:44 +02:00
padding: const EdgeInsets . symmetric ( horizontal: 3 ) ,
child: Container (
constraints: const BoxConstraints ( maxWidth: 450 ) ,
decoration: BoxDecoration (
border: Border . all ( color: Colors . black ) ,
color: const Color ( 0xffeeeedd ) ,
borderRadius: const BorderRadius . all (
Radius . circular ( 10 ) ,
) ) ,
padding: const EdgeInsets . all ( 20 ) ,
child: FutureBuilder (
future: _generateWalletProvider . generateWordList ( context ) ,
builder: ( BuildContext context , AsyncSnapshot < List > _data ) {
if ( ! _data . hasData ) {
return const Text ( ' ' ) ;
} else {
return Column (
mainAxisAlignment: MainAxisAlignment . center ,
mainAxisSize: MainAxisSize . max ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: < Widget > [
Row ( children: < Widget > [
arrayCell ( _data . data ! [ 0 ] ) ,
arrayCell ( _data . data ! [ 1 ] ) ,
arrayCell ( _data . data ! [ 2 ] ) ,
arrayCell ( _data . data ! [ 3 ] ) ,
] ) ,
const SizedBox ( height: 15 ) ,
Row ( children: < Widget > [
arrayCell ( _data . data ! [ 4 ] ) ,
arrayCell ( _data . data ! [ 5 ] ) ,
arrayCell ( _data . data ! [ 6 ] ) ,
arrayCell ( _data . data ! [ 7 ] ) ,
] ) ,
const SizedBox ( height: 15 ) ,
Row ( children: < Widget > [
arrayCell ( _data . data ! [ 8 ] ) ,
arrayCell ( _data . data ! [ 9 ] ) ,
arrayCell ( _data . data ! [ 10 ] ) ,
arrayCell ( _data . data ! [ 11 ] ) ,
] ) ,
] ) ;
}
} ) ,
) ,
) ;
2021-02-28 07:12:10 +01:00
}
Widget arrayCell ( dataWord ) {
2021-11-14 19:21:20 +01:00
return SizedBox (
2022-05-23 10:53:44 +02:00
width: 100 ,
child: Column ( children: < Widget > [
Text (
dataWord . split ( ' : ' ) [ 0 ] ,
style: const TextStyle ( fontSize: 15 , color: Color ( 0xff6b6b52 ) ) ,
) ,
Text (
dataWord . split ( ' : ' ) [ 1 ] ,
key: Key ( ' word ${ dataWord . split ( ' : ' ) [ 0 ] } ' ) ,
style: const TextStyle ( fontSize: 20 , color: Colors . black ) ,
) ,
] ) ,
) ;
}
Widget nextButton ( BuildContext context , String text , nextScreen , bool isFast ) {
GenerateWalletsProvider _generateWalletProvider =
Provider . of < GenerateWalletsProvider > ( context , listen: false ) ;
_generateWalletProvider . isAskedWordValid = false ;
_generateWalletProvider . askedWordColor = Colors . black ;
return SizedBox (
2022-05-25 20:40:25 +02:00
width: 380 * ratio ,
height: 60 * ratio ,
2022-05-23 10:53:44 +02:00
child: ElevatedButton (
style: ElevatedButton . styleFrom (
elevation: 4 ,
primary: orangeC , // background
onPrimary: Colors . white , // foreground
) ,
onPressed: ( ) {
Navigator . push (
context , FaderTransition ( page: nextScreen , isFast: isFast ) ) ;
} ,
child: Text (
text ,
style: const TextStyle ( fontSize: 24 , fontWeight: FontWeight . w600 ) ,
) ,
) ,
) ;
2021-02-28 07:12:10 +01:00
}