Refactoring onboarding

This commit is contained in:
poka 2022-05-23 10:53:44 +02:00
parent 847619bef0
commit ed734e271e
25 changed files with 1093 additions and 1322 deletions

View File

@ -10,7 +10,6 @@ import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/substrate_sdk.dart';
import 'package:pdf/pdf.dart'; import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw; import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import "package:unorm_dart/unorm_dart.dart" as unorm; import "package:unorm_dart/unorm_dart.dart" as unorm;
@ -163,37 +162,70 @@ class GenerateWalletsProvider with ChangeNotifier {
return pin.text; return pin.text;
} }
Future<Uint8List> printWallet(String? _title) async { Future<Uint8List> printWallet(AsyncSnapshot<List>? mnemoList) async {
final ByteData fontData = final ByteData fontData =
await rootBundle.load("assets/OpenSans-Regular.ttf"); await rootBundle.load("assets/OpenSans-Regular.ttf");
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData()); final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
final pdf = pw.Document(); final pdf = pw.Document();
const imageProvider = AssetImage('assets/icon/gecko_final.png'); // const imageProvider = AssetImage('assets/icon/gecko_final.png');
final geckoLogo = await flutterImageProvider(imageProvider); // final geckoLogo = await flutterImageProvider(imageProvider);
pw.Widget arrayCell(dataWord) {
return pw.SizedBox(
width: 120,
child: pw.Column(children: <pw.Widget>[
pw.Text(
dataWord.split(':')[0],
style: pw.TextStyle(
fontSize: 15, color: const PdfColor(0.5, 0, 0), font: ttf),
),
pw.Text(
dataWord.split(':')[1],
style: pw.TextStyle(
fontSize: 20, color: const PdfColor(0, 0, 0), font: ttf),
),
pw.SizedBox(height: 10)
]),
);
}
pdf.addPage( pdf.addPage(
pw.Page( pw.Page(
pageFormat: PdfPageFormat.a4, pageFormat: PdfPageFormat.a4,
build: (context) { build: (context) {
return pw.Column(children: <pw.Widget>[ return pw.Column(
pw.SizedBox(height: 20), // mainAxisAlignment: pw.MainAxisAlignment.center,
pw.Text("Phrase de restauration:", // mainAxisSize: pw.MainAxisSize.max,
style: pw.TextStyle(fontSize: 20, font: ttf)), // crossAxisAlignment: pw.CrossAxisAlignment.center,
pw.SizedBox(height: 10), children: <pw.Widget>[
pw.Text(_title!, pw.Row(children: <pw.Widget>[
style: pw.TextStyle(fontSize: 15, font: ttf), arrayCell(mnemoList!.data![0]),
textAlign: pw.TextAlign.center), arrayCell(mnemoList.data![1]),
pw.Expanded( arrayCell(mnemoList.data![2]),
child: pw.Align( arrayCell(mnemoList.data![3]),
alignment: pw.Alignment.bottomCenter, ]),
child: pw.Text( pw.Row(children: <pw.Widget>[
"Gardez cette feuille en lieu sûr, à l'abris des regards indiscrets.", arrayCell(mnemoList.data![4]),
style: pw.TextStyle(fontSize: 10, font: ttf), arrayCell(mnemoList.data![5]),
))), arrayCell(mnemoList.data![6]),
pw.SizedBox(height: 15), arrayCell(mnemoList.data![7]),
pw.Image(geckoLogo, height: 50) ]),
]); pw.Row(children: <pw.Widget>[
arrayCell(mnemoList.data![8]),
arrayCell(mnemoList.data![9]),
arrayCell(mnemoList.data![10]),
arrayCell(mnemoList.data![11])
]),
pw.Expanded(
child: pw.Align(
alignment: pw.Alignment.bottomCenter,
child: pw.Text(
"Gardez cette feuille préciseusement, à labri des lézards indiscrets.",
style: pw.TextStyle(fontSize: 15, font: ttf),
)))
],
);
}, },
), ),
); );

View File

@ -214,7 +214,7 @@ class SubstrateSdk with ChangeNotifier {
generatedMnemonic = gen.mnemonic!; generatedMnemonic = gen.mnemonic!;
// final res = await importAccount(fromMnemonic: true); // final res = await importAccount(fromMnemonic: true);
await Clipboard.setData(ClipboardData(text: generatedMnemonic)); // await Clipboard.setData(ClipboardData(text: generatedMnemonic));
return gen.mnemonic!; return gen.mnemonic!;
} }

View File

@ -1,5 +1,5 @@
import 'package:dots_indicator/dots_indicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:bubble/bubble.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
class CommonElements { class CommonElements {
@ -8,95 +8,104 @@ class CommonElements {
return const Text('Coucou'); return const Text('Coucou');
} }
Widget bubbleSpeak(String text, Widget buildImage(String assetName,
{double? long, Key? textKey, bool isMaxWidth = true}) { [double boxHeight = 440, double imageWidth = 350]) {
return Container(
padding: const EdgeInsets.all(0),
width: 440,
height: boxHeight,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xffd2d4cf),
Color(0xffeaeae7),
],
),
border: Border.all(color: Colors.grey[900]!)),
child: Image.asset('assets/onBoarding/$assetName', width: imageWidth));
}
Widget buildText(List<TextSpan> text, [double size = 20]) {
return Container(
padding: const EdgeInsets.all(12),
width: 440,
decoration: BoxDecoration(
color: Colors.white, border: Border.all(color: Colors.grey[900]!)),
child: RichText(
textAlign: TextAlign.justify,
text: TextSpan(
style: TextStyle(
fontSize: size, color: Colors.black, letterSpacing: 0.3),
children: text,
),
),
);
}
Widget nextButton(
BuildContext context, String text, nextScreen, bool isFast) {
return SizedBox( return SizedBox(
width: isMaxWidth ? double.infinity : 300, width: 410,
child: Bubble( height: 70,
padding: long == null child: ElevatedButton(
? const BubbleEdges.all(18) style: ElevatedButton.styleFrom(
: BubbleEdges.symmetric(horizontal: long, vertical: 30), elevation: 4,
elevation: 5, primary: orangeC, // background
color: Colors.white, onPrimary: Colors.white, // foreground
margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), ),
// nip: BubbleNip.leftTop, onPressed: () {
Navigator.push(
context, FaderTransition(page: nextScreen, isFast: isFast));
},
child: Text( child: Text(
text, text,
key: textKey, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
style: const TextStyle(
color: Colors.black, fontSize: 18, fontWeight: FontWeight.w400),
), ),
), ),
); );
} }
Widget bubbleSpeakRich(List<TextSpan> text, {Key? textKey}) { Widget buildProgressBar(double pagePosition) {
return SizedBox( return DotsIndicator(
width: double.infinity, dotsCount: 11,
child: Bubble( position: pagePosition,
padding: const BubbleEdges.all(18), decorator: DotsDecorator(
elevation: 5, spacing: const EdgeInsets.symmetric(horizontal: 10),
color: Colors.white, color: Colors.grey[300]!, // Inactive color
margin: const BubbleEdges.fromLTRB(10, 0, 20, 10), activeColor: orangeC,
// nip: BubbleNip.leftTop,
child: RichText(
key: textKey,
text: TextSpan(
style: const TextStyle(
fontSize: 18.0,
color: Colors.black,
),
children: text,
),
),
), ),
); );
} }
Widget onboardingProgressBar( Widget infoIntro(
BuildContext context, String screenTitle, int progress) { BuildContext context,
return Stack(children: [ List<TextSpan> text,
Container(height: 100), String assetName,
Positioned( String buttonText,
top: 0, left: 0, right: 0, child: GeckoSpeechAppBar(screenTitle)), nextScreen,
Positioned( double pagePosition, {
top: 0, bool isFast = false,
left: 0, double boxHeight = 440,
child: GestureDetector( double imageWidth = 350,
onTap: () { double textSize = 20,
Navigator.popUntil( }) {
context, return Column(children: <Widget>[
ModalRoute.withName('/'), SizedBox(height: isTall ? 40 : 20),
); buildProgressBar(pagePosition),
}, SizedBox(height: isTall ? 40 : 20),
child: Image.asset(
'assets/onBoarding/gecko_bar.png', buildText(text, textSize),
), buildImage(assetName, boxHeight, imageWidth),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: nextButton(context, buttonText, nextScreen, false),
), ),
), ),
if (progress != 0) // const SizedBox(height: 40),
Positioned( SizedBox(height: isTall ? 40 : 10),
top: 75,
left: 90,
child: Image.asset(
'assets/onBoarding/progress_bar/total.png',
),
),
if (progress != 0)
Positioned(
top: 75,
left: 90,
child: Image.asset(
'assets/onBoarding/progress_bar/$progress.png',
),
),
if (progress != 0)
Positioned(
top: 70,
right: 90,
child: Text(progress == 12 ? '11/11' : '$progress/11',
style: const TextStyle(fontSize: 12, color: Colors.black)),
),
]); ]);
} }

View File

@ -483,7 +483,7 @@ Widget welcomeHome(context) {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) { builder: (context) {
return OnboardingStepOne(); return const OnboardingStepOne();
}, },
), ),
); );

View File

@ -100,10 +100,11 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier {
), ),
onPressed: () async { onPressed: () async {
final _chest = chestBox.get(configBox.get('currentChest')); final _chest = chestBox.get(configBox.get('currentChest'));
_sub.changePassword( await _sub.changePassword(
_chest!.address!, walletProvider.pinCode, newPin.text); _chest!.address!, walletProvider.pinCode, newPin.text);
newPin.text = '';
walletProvider.pinCode = newPin.text; walletProvider.pinCode = newPin.text;
newPin.text = '';
Navigator.pop(context);
}, },
child: const Text( child: const Text(
'Confirmer', 'Confirmer',

View File

@ -24,14 +24,15 @@ class ChestOptions extends StatelessWidget {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
toolbarHeight: 60 * ratio, toolbarHeight: 60 * ratio,
leading: IconButton( // leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black), // icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () { // onPressed: () {
Navigator.popUntil( // // Navigator.popUntil(
context, // // context,
ModalRoute.withName('/mywallets'), // // ModalRoute.withName('/mywallets'),
); // // );
}), // Navigator.pop(context);
// }),
title: SizedBox( title: SizedBox(
height: 22, height: 22,
child: Text(currentChest.name!), child: Text(currentChest.name!),

View File

@ -4,7 +4,6 @@ import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart'; import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/screens/myWallets/confirm_wallet_storage.dart'; import 'package:gecko/screens/myWallets/confirm_wallet_storage.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:printing/printing.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
@ -141,17 +140,17 @@ class GenerateFastChestScreen extends StatelessWidget {
child: const Text('Enregistrer ce coffre', child: const Text('Enregistrer ce coffre',
style: TextStyle(fontSize: 20))), style: TextStyle(fontSize: 20))),
const SizedBox(height: 20), const SizedBox(height: 20),
GestureDetector( // GestureDetector(
onTap: () { // onTap: () {
Navigator.push( // Navigator.push(
context, // context,
MaterialPageRoute(builder: (context) { // MaterialPageRoute(builder: (context) {
return PrintWallet( // return PrintWallet(
_generateWalletProvider.generatedMnemonic); // _generateWalletProvider.generatedMnemonic);
}), // }),
); // );
}, // },
child: const Icon(Icons.print)) // child: const Icon(Icons.print))
]), ]),
), ),
), ),
@ -194,30 +193,30 @@ class GenerateFastChestScreen extends StatelessWidget {
} }
} }
// ignore: must_be_immutable // // ignore: must_be_immutable
class PrintWallet extends StatelessWidget { // class PrintWallet extends StatelessWidget {
const PrintWallet(this.sentence, {Key? key}) : super(key: key); // const PrintWallet(this.sentence, {Key? key}) : super(key: key);
final String? sentence; // final String? sentence;
@override // @override
Widget build(BuildContext context) { // Widget build(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider = // GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context); // Provider.of<GenerateWalletsProvider>(context);
return MaterialApp( // return MaterialApp(
home: Scaffold( // home: Scaffold(
appBar: AppBar( // appBar: AppBar(
leading: IconButton( // leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.white), // icon: const Icon(Icons.arrow_back, color: Colors.white),
onPressed: () { // onPressed: () {
Navigator.pop(context); // Navigator.pop(context);
}), // }),
toolbarHeight: 60 * ratio, // toolbarHeight: 60 * ratio,
title: const Text('Imprimer ce coffre')), // title: const Text('Imprimer ce coffre')),
body: PdfPreview( // body: PdfPreview(
build: (format) => _generateWalletProvider.printWallet(sentence), // build: (format) => _generateWalletProvider.printWallet(sentence),
), // ),
), // ),
); // );
} // }
} // }

View File

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:gecko/providers/generate_wallets.dart'; import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/11.dart'; import 'package:gecko/screens/onBoarding/9.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// import 'package:gecko/models/home.dart'; // import 'package:gecko/models/home.dart';
// import 'package:provider/provider.dart'; // import 'package:provider/provider.dart';

View File

@ -1,70 +0,0 @@
// ignore_for_file: file_names
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/1.dart';
class NoKeyChainScreen extends StatelessWidget {
const NoKeyChainScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
CommonElements common = CommonElements();
return Scaffold(
extendBodyBehindAppBar: true,
// backgroundColor: Colors.white,
// appBar: GeckoSpeechAppBar('Mes portefeuilles'),
body: SafeArea(
child: Column(children: <Widget>[
common.onboardingProgressBar(context, 'Mes portefeuilles', 0),
common.bubbleSpeak(
"Je ne connais pour linstant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant.",
textKey: const Key('textOnboarding')),
const SizedBox(height: 90),
Container(
child: ClipOval(
child: Material(
color: const Color(0xffFFD58D), // button color
child: InkWell(
key: const Key('goStep1'),
splashColor: orangeC, // inkwell color
child: const Padding(
padding: EdgeInsets.all(8),
child: Image(
image: AssetImage('assets/onBoarding/wallet.png'),
height: 90)),
onTap: () {
Navigator.push(
context,
FaderTransition(
page: OnboardingStepOne(), isFast: true));
}),
),
),
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 4.0,
offset: Offset(2.0, 2.5),
spreadRadius: 0.5)
],
),
),
const SizedBox(height: 15),
const Text(
"Créer un nouveau\nportefeuille",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w500),
),
]),
));
}
}

View File

@ -1,73 +1,47 @@
// ignore_for_file: file_names // ignore_for_file: file_names
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/2.dart'; import 'package:gecko/screens/onBoarding/2.dart';
// import 'package:gecko/models/home.dart';
// import 'package:provider/provider.dart';
// ignore: must_be_immutable
class OnboardingStepOne extends StatelessWidget { class OnboardingStepOne extends StatelessWidget {
TextEditingController tplController = TextEditingController(); const OnboardingStepOne({Key? key}) : super(key: key);
final int progress = 1;
OnboardingStepOne({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
////TODO: Continue onbarding refactoring CommonElements common = CommonElements();
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
toolbarHeight: 60 * ratio, toolbarHeight: 60 * ratio,
title: const SizedBox( title: const SizedBox(
height: 22, height: 22,
child: Text( child: Text(
'Nouveau portefeuille', 'Nouveau portefeuille',
style: TextStyle(fontWeight: FontWeight.w600), style: TextStyle(fontWeight: FontWeight.w600),
),
), ),
), ),
extendBodyBehindAppBar: true, ),
body: SafeArea( extendBodyBehindAppBar: true,
child: Column(children: <Widget>[ body: SafeArea(
// common.onboardingProgressBar( child: common.infoIntro(
// context, 'Nouveau portefeuilles', progress), context,
// common.bubbleSpeak( <TextSpan>[
// "Il semblerait que vous nayez pas encore de coffre.\n\nUn coffre vous permet de gérer un ou plusieurs portefeuilles.", const TextSpan(
// textKey: const Key('step1')), text: 'Gecko fabrique votre portefeuille à partir dune '),
const SizedBox(height: 90), const TextSpan(
Image.asset( text: 'phrase de restauration',
'assets/onBoarding/fabrication-de-portefeuille.png', style: TextStyle(fontWeight: FontWeight.bold)),
height: 200, const TextSpan(
), text:
Expanded( '. Elle est un peu comme le plan qui permet de construire votre portefeuille.'),
child: Align( ],
alignment: Alignment.bottomCenter, 'fabrication-de-portefeuille.png',
child: SizedBox( '>',
width: 400, const OnboardingStepTwo(),
height: 62, 0),
child: ElevatedButton( ),
key: const Key('goStep2'), );
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.push(
context,
FaderTransition(
page: OnboardingStepTwo(), isFast: true));
},
child: const Text('Créer mon coffre',
style: TextStyle(fontSize: 20))),
))),
const SizedBox(height: 80),
]),
));
} }
} }

View File

@ -1,64 +1,167 @@
// ignore_for_file: file_names // ignore_for_file: file_names
import 'dart:async';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/11.dart'; import 'package:gecko/screens/onBoarding/11_congratulations.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class OnboardingStepTwelve extends StatelessWidget { class OnboardingStepFourteen extends StatelessWidget {
TextEditingController tplController = TextEditingController(); OnboardingStepFourteen({
final int progress = 9; Key? validationKey,
}) : super(key: validationKey);
OnboardingStepTwelve({Key? key}) : super(key: key); final formKey = GlobalKey<FormState>();
Color? pinColor = const Color(0xFFA4B600);
bool hasError = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
WalletOptionsProvider _walletOptions =
Provider.of<WalletOptionsProvider>(context);
CommonElements common = CommonElements(); CommonElements common = CommonElements();
final int _pinLenght = _generateWalletProvider.pin.text.length;
return Scaffold( return Scaffold(
appBar: AppBar(
toolbarHeight: 60 * ratio,
title: const SizedBox(
height: 22,
child: Text(
'Mon code secret',
style: TextStyle(fontWeight: FontWeight.w600),
),
),
),
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: SafeArea( body: SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
common.onboardingProgressBar( SizedBox(height: isTall ? 40 : 20),
context, 'Ma phrase de restauration', progress), common.buildProgressBar(9),
common.bubbleSpeak( SizedBox(height: isTall ? 40 : 20),
"Si un jour vous changez de téléphone, votre code secret sera différent, mais il vous suffira de me redonner votre phrase de restauration pour recréer votre coffre.", common.buildText(<TextSpan>[
textKey: const Key('step10'), TextSpan(
), text:
const SizedBox(height: 10), "Gecko va vérifier avec vous si vous avez bien mémorisé votre code secret.\n\nTapez votre code secret dans le champ ci-dessous pour vérifier que vous lavez bien noté.",
Image.asset( style: TextStyle(fontSize: 16 * ratio))
'assets/onBoarding/plusieurs-codes-secrets-un-trousseau.png', ]),
height: isTall ? 410 : 380, SizedBox(height: isTall ? 80 : 20),
), pinForm(context, _walletOptions, _pinLenght, 1, 2)
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('goStep11'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.push(
context,
FaderTransition(
page: const OnboardingStepThirteen(),
isFast: true),
);
},
child: const Text("Générer le code secret",
style: TextStyle(fontSize: 20))),
))),
const SizedBox(height: 80),
]), ]),
)); ));
} }
Widget pinForm(context, WalletOptionsProvider _walletOptions, _pinLenght,
int _walletNbr, int _derivation) {
// var _walletPin = '';
// ignore: close_sinks
StreamController<ErrorAnimationType> errorController =
StreamController<ErrorAnimationType>();
TextEditingController _enterPin = TextEditingController();
MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
final int? _currentChest = _myWalletProvider.getCurrentChest();
return Form(
key: formKey,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30),
child: PinCodeTextField(
key: const Key('formKey2'),
autoFocus: true,
appContext: context,
pastedTextStyle: TextStyle(
color: Colors.green.shade600,
fontWeight: FontWeight.bold,
),
length: _pinLenght,
obscureText: true,
obscuringCharacter: '*',
animationType: AnimationType.fade,
validator: (v) {
if (v!.length < _pinLenght) {
return "Votre code PIN fait $_pinLenght caractères";
} else {
return null;
}
},
pinTheme: PinTheme(
activeColor: pinColor,
borderWidth: 4,
shape: PinCodeFieldShape.box,
borderRadius: BorderRadius.circular(5),
fieldHeight: 60,
fieldWidth: 50,
activeFillColor: hasError ? Colors.blueAccent : Colors.black,
),
cursorColor: Colors.black,
animationDuration: const Duration(milliseconds: 300),
textStyle: const TextStyle(fontSize: 20, height: 1.6),
backgroundColor: const Color(0xffF9F9F1),
enableActiveFill: false,
errorAnimationController: errorController,
controller: _enterPin,
keyboardType: TextInputType.text,
boxShadows: const [
BoxShadow(
offset: Offset(0, 1),
color: Colors.black12,
blurRadius: 10,
)
],
onCompleted: (_pin) async {
_myWalletProvider.pinCode = _pin.toUpperCase();
_myWalletProvider.pinLenght = _pinLenght;
log.d(_pin + ' || ' + _generateWalletProvider.pin.text);
if (_pin.toUpperCase() == _generateWalletProvider.pin.text) {
pinColor = Colors.green[500];
final address = await _sub.importAccount(
fromMnemonic: true,
mnemonic: _generateWalletProvider.generatedMnemonic!,
derivePath: '//2',
password: _generateWalletProvider.pin.text);
await _generateWalletProvider.storeHDWChest(
address, 'Mon portefeuille courant', context);
_myWalletProvider.readAllWallets(_currentChest);
// scheduleMicrotask(() {
// _walletOptions.reloadBuild();
_myWalletProvider.rebuildWidget();
// });
_generateWalletProvider.generatedMnemonic = '';
Navigator.push(
context,
FaderTransition(
page: const OnboardingStepFiveteen(), isFast: false),
);
} else {
errorController.add(ErrorAnimationType
.shake); // Triggering error shake animation
hasError = true;
pinColor = Colors.red[600];
_walletOptions.reloadBuild();
}
},
onChanged: (value) {
if (pinColor != const Color(0xFFA4B600)) {
pinColor = const Color(0xFFA4B600);
}
},
)),
);
}
} }

View File

@ -1,121 +0,0 @@
// ignore_for_file: file_names
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/12.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class OnboardingStepThirteen extends StatelessWidget {
final int progress = 10;
const OnboardingStepThirteen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
// MyWalletsProvider myWalletProvider =
// Provider.of<MyWalletsProvider>(context);
CommonElements common = CommonElements();
_generateWalletProvider.pin.text = kDebugMode && debugPin
? 'AAAAA'
: _generateWalletProvider.changePinCode(reload: false);
return Scaffold(
extendBodyBehindAppBar: true,
body: SafeArea(
child: Column(children: <Widget>[
common.onboardingProgressBar(
context, 'Ma phrase de restauration', progress),
common.bubbleSpeakRich(
<TextSpan>[
const TextSpan(
text:
"Et voilà votre code secret !\n\nMémorisez-le ou notez-le, car il vous sera demandé "),
const TextSpan(
text: 'à chaque fois',
style: TextStyle(fontWeight: FontWeight.bold)),
const TextSpan(
text:
" que vous voudrez effectuer un paiement sur cet appareil."),
],
textKey: const Key('step11'),
),
const SizedBox(height: 100),
Stack(
alignment: Alignment.centerRight,
children: <Widget>[
TextField(
key: const Key('generatedPin'),
enabled: false,
controller: _generateWalletProvider.pin,
maxLines: 1,
textAlign: TextAlign.center,
decoration: const InputDecoration(),
style: const TextStyle(
letterSpacing: 5,
fontSize: 35.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
IconButton(
icon: const Icon(Icons.replay),
color: orangeC,
onPressed: () {
_generateWalletProvider.changePinCode(reload: true);
},
),
],
),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('changeSecretCode'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: const Color(0xffFFD58D),
onPrimary: Colors.black, // foreground
),
onPressed: () {
_generateWalletProvider.changePinCode(reload: true);
},
child: const Text("Choisir un autre code secret",
style: TextStyle(fontSize: 20))),
))),
const SizedBox(height: 25),
SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('goStep12'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () async {
_generateWalletProvider.isAskedWordValid = false;
_generateWalletProvider.askedWordColor = Colors.black;
Navigator.push(
context,
FaderTransition(
page: OnboardingStepFourteen(), isFast: true),
);
},
child: const Text("J'ai noté mon code secret",
style: TextStyle(fontSize: 20))),
),
const SizedBox(height: 80),
]),
));
}
}

View File

@ -0,0 +1,78 @@
// ignore_for_file: file_names
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart';
// ignore: must_be_immutable
class OnboardingStepFiveteen extends StatelessWidget {
const OnboardingStepFiveteen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
CommonElements common = CommonElements();
return Scaffold(
appBar: AppBar(
toolbarHeight: 60 * ratio,
title: const SizedBox(
height: 22,
child: Text(
'Cest tout bon !',
style: TextStyle(fontWeight: FontWeight.w600),
),
),
),
extendBodyBehindAppBar: true,
body: SafeArea(
child: Column(children: <Widget>[
const SizedBox(height: 40),
common.buildText(<TextSpan>[
const TextSpan(
text:
"Top !\n\nVotre coffre votre premier portefeuille ont été créés avec un immense succès.\n\nFélicitations !",
)
]),
SizedBox(height: isTall ? 20 : 10),
Image.asset(
'assets/onBoarding/gecko-clin.gif',
height: isTall ? 400 : 300,
),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: finishButton(context)),
),
const SizedBox(height: 40),
]),
));
}
}
Widget finishButton(BuildContext context) {
return SizedBox(
width: 410,
height: 70,
child: ElevatedButton(
key: const Key('goWalletHome'),
style: ElevatedButton.styleFrom(
elevation: 4,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) {
return const WalletsHome();
}),
ModalRoute.withName('/'),
);
},
child: const Text("Accéder à mon coffre",
style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600))),
);
}

View File

@ -1,155 +0,0 @@
// ignore_for_file: file_names
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/13_congratulations.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class OnboardingStepFourteen extends StatelessWidget {
OnboardingStepFourteen({
Key? validationKey,
}) : super(key: validationKey);
final int progress = 11;
final formKey = GlobalKey<FormState>();
Color? pinColor = const Color(0xFFA4B600);
bool hasError = false;
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
WalletOptionsProvider _walletOptions =
Provider.of<WalletOptionsProvider>(context);
CommonElements common = CommonElements();
final int _pinLenght = _generateWalletProvider.pin.text.length;
return Scaffold(
extendBodyBehindAppBar: true,
body: SafeArea(
child: Column(children: <Widget>[
common.onboardingProgressBar(
context, 'Ma phrase de restauration', progress),
common.bubbleSpeak(
"Avez-vous bien mémorisé votre code secret ?\n\nVérifions ça ensemble !\n\nTapez votre code secret dans le champ ci-dessous (après cest fini, promis-juré-gecko).",
textKey: const Key('step12'),
),
SizedBox(height: isTall ? 80 : 10),
pinForm(context, _walletOptions, _pinLenght, 1, 2)
]),
));
}
Widget pinForm(context, WalletOptionsProvider _walletOptions, _pinLenght,
int _walletNbr, int _derivation) {
// var _walletPin = '';
// ignore: close_sinks
StreamController<ErrorAnimationType> errorController =
StreamController<ErrorAnimationType>();
TextEditingController _enterPin = TextEditingController();
MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
final int? _currentChest = _myWalletProvider.getCurrentChest();
return Form(
key: formKey,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30),
child: PinCodeTextField(
key: const Key('formKey2'),
autoFocus: true,
appContext: context,
pastedTextStyle: TextStyle(
color: Colors.green.shade600,
fontWeight: FontWeight.bold,
),
length: _pinLenght,
obscureText: true,
obscuringCharacter: '*',
animationType: AnimationType.fade,
validator: (v) {
if (v!.length < _pinLenght) {
return "Votre code PIN fait $_pinLenght caractères";
} else {
return null;
}
},
pinTheme: PinTheme(
activeColor: pinColor,
borderWidth: 4,
shape: PinCodeFieldShape.box,
borderRadius: BorderRadius.circular(5),
fieldHeight: 60,
fieldWidth: 50,
activeFillColor: hasError ? Colors.blueAccent : Colors.black,
),
cursorColor: Colors.black,
animationDuration: const Duration(milliseconds: 300),
textStyle: const TextStyle(fontSize: 20, height: 1.6),
backgroundColor: const Color(0xffF9F9F1),
enableActiveFill: false,
errorAnimationController: errorController,
controller: _enterPin,
keyboardType: TextInputType.text,
boxShadows: const [
BoxShadow(
offset: Offset(0, 1),
color: Colors.black12,
blurRadius: 10,
)
],
onCompleted: (_pin) async {
_myWalletProvider.pinCode = _pin.toUpperCase();
_myWalletProvider.pinLenght = _pinLenght;
log.d(_pin + ' || ' + _generateWalletProvider.pin.text);
if (_pin.toUpperCase() == _generateWalletProvider.pin.text) {
pinColor = Colors.green[500];
final address = await _sub.importAccount(
fromMnemonic: true,
mnemonic: _generateWalletProvider.generatedMnemonic!,
derivePath: '//2',
password: _generateWalletProvider.pin.text);
await _generateWalletProvider.storeHDWChest(
address, 'Mon portefeuille courant', context);
_myWalletProvider.readAllWallets(_currentChest);
// scheduleMicrotask(() {
// _walletOptions.reloadBuild();
_myWalletProvider.rebuildWidget();
// });
_generateWalletProvider.generatedMnemonic = '';
Navigator.push(
context,
FaderTransition(
page: OnboardingStepFiveteen(), isFast: false),
);
} else {
errorController.add(ErrorAnimationType
.shake); // Triggering error shake animation
hasError = true;
pinColor = Colors.red[600];
_walletOptions.reloadBuild();
}
},
onChanged: (value) {
if (pinColor != const Color(0xFFA4B600)) {
pinColor = const Color(0xFFA4B600);
}
},
)),
);
}
}

View File

@ -1,67 +0,0 @@
// ignore_for_file: file_names
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart';
// ignore: must_be_immutable
class OnboardingStepFiveteen extends StatelessWidget {
TextEditingController tplController = TextEditingController();
final int progress = 12;
OnboardingStepFiveteen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
CommonElements common = CommonElements();
return Scaffold(
extendBodyBehindAppBar: true,
body: SafeArea(
child: Column(children: <Widget>[
common.onboardingProgressBar(
context, 'Ma phrase de restauration', progress),
common.bubbleSpeak(
"Top !\n\nVotre coffre de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !",
textKey: const Key('step13'),
),
SizedBox(height: isTall ? 20 : 10),
Image.asset(
'assets/onBoarding/gecko-clin.gif',
height: isTall ? 400 : 300,
),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('goWalletHome'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) {
return const WalletsHome();
}),
ModalRoute.withName('/'),
);
},
child: const Text("Accéder à mes portefeuilles",
style: TextStyle(fontSize: 20))),
),
),
),
const SizedBox(height: 80),
]),
));
}
}

View File

@ -5,16 +5,9 @@ import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/3.dart'; import 'package:gecko/screens/onBoarding/3.dart';
// import 'package:gecko/screens/commonElements.dart';
// import 'package:gecko/models/home.dart';
// import 'package:provider/provider.dart';
// ignore: must_be_immutable
class OnboardingStepTwo extends StatelessWidget { class OnboardingStepTwo extends StatelessWidget {
TextEditingController tplController = TextEditingController(); const OnboardingStepTwo({Key? key}) : super(key: key);
final int progress = 2;
OnboardingStepTwo({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -22,44 +15,30 @@ class OnboardingStepTwo extends StatelessWidget {
CommonElements common = CommonElements(); CommonElements common = CommonElements();
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, appBar: AppBar(
body: SafeArea( toolbarHeight: 60 * ratio,
child: Column(children: <Widget>[ title: const SizedBox(
common.onboardingProgressBar( height: 22,
context, 'Nouveau portefeuilles', progress), child: Text(
common.bubbleSpeak( 'Votre phrase de restauration',
"Un coffre est créé à partir dune phrase de restauration.", style: TextStyle(fontWeight: FontWeight.w600),
textKey: const Key('step2'), ),
), ),
const SizedBox(height: 70), ),
Image.asset( extendBodyBehindAppBar: true,
'assets/onBoarding/keys-and-wallets-horizontal-plus-phrase.png'), body: SafeArea(
Expanded( child: common.infoIntro(
child: Align( context,
alignment: Alignment.bottomCenter, <TextSpan>[
child: SizedBox( const TextSpan(
width: 400, text:
height: 62, 'Conservez cette phrase précieusement, car sans elle Gecko ne pourra pas reconstruire vos portefeuilles le jour où vous changez de téléphone.'),
child: ElevatedButton( ],
key: const Key('goStep3'), 'fabrication-de-portefeuille-impossible-sans-phrase.png',
style: ElevatedButton.styleFrom( '>',
elevation: 5, const OnboardingStepThree(),
primary: orangeC, 1),
onPrimary: Colors.white, // foreground ),
), );
onPressed: () {
Navigator.push(
context,
FaderTransition(
page: OnboardingStepFor(), isFast: true),
);
},
child: const Text("D'accord",
style: TextStyle(fontSize: 20)),
),
))),
const SizedBox(height: 80),
]),
));
} }
} }

View File

@ -6,12 +6,8 @@ import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/4.dart'; import 'package:gecko/screens/onBoarding/4.dart';
// ignore: must_be_immutable class OnboardingStepThree extends StatelessWidget {
class OnboardingStepFor extends StatelessWidget { const OnboardingStepThree({Key? key}) : super(key: key);
TextEditingController tplController = TextEditingController();
final int progress = 3;
OnboardingStepFor({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -19,50 +15,28 @@ class OnboardingStepFor extends StatelessWidget {
CommonElements common = CommonElements(); CommonElements common = CommonElements();
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, appBar: AppBar(
body: SafeArea( toolbarHeight: 60 * ratio,
child: Column(children: <Widget>[ title: const SizedBox(
common.onboardingProgressBar( height: 22,
context, 'Ma phrase de restauration', progress), child: Text(
common.bubbleSpeak( 'Votre phrase de restauration',
"Si un jour vous changez de téléphone, il vous suffira de me redonner votre phrase de restauration pour recréer votre coffre.", style: TextStyle(fontWeight: FontWeight.w600),
textKey: const Key('step3'), ),
), ),
SizedBox(height: isTall ? 15 : 0), ),
// Row(children: <Widget>[ extendBodyBehindAppBar: true,
// Align( body: SafeArea(
// alignment: Alignment.centerRight, child: common.infoIntro(
// child: context,
Image.asset( <TextSpan>[
'assets/onBoarding/plusieurs-appareils-un-trousseau.png', const TextSpan(text: 'Dans une blockchain, pas de procédure de récupération par mail. Seule votre phrase de restauration peut vous permettre de récupérer vos Ğ1 à tout moment.'),
height: 400 * ratio, ],
), 'mot-de-passe-oublie.png',
// ]), '>',
Expanded( const OnboardingStepFor(),
child: Align( 2),
alignment: Alignment.bottomCenter, ),
child: SizedBox( );
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('goStep4'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.push(
context,
FaderTransition(
page: OnboardingStepFive(), isFast: true),
);
},
child: const Text("J'ai compris",
style: TextStyle(fontSize: 20))),
))),
const SizedBox(height: 80),
]),
));
} }
} }

View File

@ -6,12 +6,8 @@ import 'package:gecko/globals.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/5.dart'; import 'package:gecko/screens/onBoarding/5.dart';
// ignore: must_be_immutable class OnboardingStepFor extends StatelessWidget {
class OnboardingStepFive extends StatelessWidget { const OnboardingStepFor({Key? key}) : super(key: key);
TextEditingController tplController = TextEditingController();
final int progress = 4;
OnboardingStepFive({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -19,45 +15,33 @@ class OnboardingStepFive extends StatelessWidget {
CommonElements common = CommonElements(); CommonElements common = CommonElements();
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, appBar: AppBar(
body: SafeArea( toolbarHeight: 60 * ratio,
child: Column(children: <Widget>[ title: const SizedBox(
common.onboardingProgressBar( height: 22,
context, 'Ma phrase de restauration', progress), child: Text(
common.bubbleSpeak( 'Votre phrase de restauration',
"Par contre, attention :\n\nDans une blockchain, il ny a pas de procédure de récupération de coffre.\n\nSi vous perdez votre phrase de restauration, je ne pourrai pas vous la communiquer, et vous ne pourrez donc plus jamais accéder à votre compte.", style: TextStyle(fontWeight: FontWeight.w600),
textKey: const Key('step4'), ),
), ),
SizedBox(height: isTall ? 30 : 10), ),
Image.asset( extendBodyBehindAppBar: true,
'assets/onBoarding/maison-qui-brule.png', body: SafeArea(
width: 320 * ratio, child: common.infoIntro(
), context,
Expanded( <TextSpan>[
child: Align( const TextSpan(text: 'Il est temps de vous munir d'),
alignment: Alignment.bottomCenter, const TextSpan(
child: SizedBox( text: 'un dun papier et dun crayon',
width: 400, style: TextStyle(fontWeight: FontWeight.bold)),
height: 62, const TextSpan(
child: ElevatedButton( text: ' afin de pouvoir noter votre phrase de restauration.'),
key: const Key('goStep5'), ],
style: ElevatedButton.styleFrom( 'gecko-oublie-aussi.png',
elevation: 5, '>',
primary: orangeC, const OnboardingStepFive(),
onPrimary: Colors.white, // foreground 3),
), ),
onPressed: () { );
Navigator.push(
context,
FaderTransition(
page: OnboardingStepSeven(), isFast: true),
);
},
child: const Text("J'ai compris",
style: TextStyle(fontSize: 20))),
))),
const SizedBox(height: 80),
]),
));
} }
} }

View File

@ -3,78 +3,243 @@
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/6.dart'; import 'package:gecko/screens/onBoarding/6.dart';
import 'package:printing/printing.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable AsyncSnapshot<List>? mnemoList;
class OnboardingStepSeven extends StatelessWidget {
TextEditingController tplController = TextEditingController();
final int progress = 5;
OnboardingStepSeven({Key? key}) : super(key: key); class OnboardingStepFive extends StatelessWidget {
const OnboardingStepFive({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context, listen: false);
CommonElements common = CommonElements(); CommonElements common = CommonElements();
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, appBar: AppBar(
body: SafeArea( toolbarHeight: 60 * ratio,
child: Column(children: <Widget>[ title: const SizedBox(
common.onboardingProgressBar( height: 22,
context, 'Ma phrase de restauration', progress), child: Text(
common.bubbleSpeakRich( 'Votre phrase de restauration',
<TextSpan>[ style: TextStyle(fontWeight: FontWeight.w600),
const TextSpan(text: "Munissez-vous d'"), ),
const TextSpan( ),
text: 'un papier et dun crayon\n', ),
style: TextStyle(fontWeight: FontWeight.bold)), extendBodyBehindAppBar: true,
const TextSpan( body: SafeArea(
text: child: Column(children: [
"afin de pouvoir noter votre phrase de restauration."), SizedBox(height: isTall ? 40 : 20),
], common.buildProgressBar(4),
textKey: const Key('step5'), SizedBox(height: isTall ? 40 : 20),
common.buildText(
<TextSpan>[
const TextSpan(
text:
'Gecko a généré votre phrase de restauration ! Tâchez de la garder bien secrète, car elle permet à quiconque la connaît daccéder à tous vos portefeuilles.'),
],
),
const SizedBox(height: 40),
sentanceArray(context),
const SizedBox(height: 20),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return PrintWallet(_generateWalletProvider.generatedMnemonic);
}),
);
},
child: Image.asset(
'assets/printer.png',
height: 45,
), ),
Expanded( ),
child: Align( const SizedBox(height: 40),
Expanded(
child: Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[ child: SizedBox(
Container( width: 410,
padding: const EdgeInsets.only(bottom: 90), height: 70,
child: common.bubbleSpeak( child: ElevatedButton(
"Moi, jai déjà essayé de\nmémoriser une phrase de\nrestauration, mais je nai\npas une mémoire\ndéléphant.", key: const Key('generateMnemonic'),
isMaxWidth: false), style: ElevatedButton.styleFrom(
), elevation: 4,
Image.asset( primary: const Color(0xffFFD58D),
'assets/onBoarding/chopp-gecko.png', onPrimary: Colors.black, // foreground
height: 200, ),
), onPressed: () {
]), _generateWalletProvider.reloadBuild();
)), // setState(() {});
SizedBox(height: isTall ? 120 : 50), },
SizedBox( child: const Text("Choisir une autre phrase",
width: 400, style: TextStyle(
height: 62, fontSize: 24, fontWeight: FontWeight.w600))),
child: ElevatedButton( ),
key: const Key('goStep6'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.push(
context,
FaderTransition(
page: OnboardingStepEight(), isFast: true),
);
},
child: const Text("J'ai de quoi noter",
style: TextStyle(fontSize: 20))),
), ),
const SizedBox(height: 80), ),
]), const SizedBox(height: 25),
)); nextButton(context, "J'ai noté ma phrase", false),
const SizedBox(height: 40),
]),
),
);
} }
} }
Widget sentanceArray(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
return Padding(
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 {
mnemoList = _data;
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]),
]),
]);
}
}),
),
);
}
Widget arrayCell(dataWord) {
return SizedBox(
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),
),
]),
);
}
// ignore: must_be_immutable
class PrintWallet extends StatelessWidget {
const PrintWallet(this.sentence, {Key? key}) : super(key: key);
final String? sentence;
@override
Widget build(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () {
Navigator.pop(context);
}),
backgroundColor: yellowC,
foregroundColor: Colors.black,
toolbarHeight: 60 * ratio,
title: const SizedBox(
height: 22,
child: Text(
'Imprimer ma phrase de restauration',
style: TextStyle(fontWeight: FontWeight.w600),
),
),
),
body: PdfPreview(
canDebug: false,
canChangeOrientation: false,
build: (format) => _generateWalletProvider.printWallet(mnemoList),
),
),
);
}
}
Widget nextButton(BuildContext context, String text, bool isFast) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context, listen: false);
MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
return SizedBox(
width: 410,
height: 70,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 4,
primary: orangeC, // background
onPrimary: Colors.white, // foreground
),
onPressed: () {
_generateWalletProvider.nbrWord =
_generateWalletProvider.getRandomInt();
_generateWalletProvider.nbrWordAlpha = _generateWalletProvider
.intToString(_generateWalletProvider.nbrWord + 1);
_myWalletProvider.mnemonic = _generateWalletProvider.generatedMnemonic!;
Navigator.push(
context,
FaderTransition(
page: OnboardingStepSix(
generatedMnemonic: _generateWalletProvider.generatedMnemonic),
isFast: true),
);
},
child: Text(
text,
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
),
),
);
}

View File

@ -1,124 +1,238 @@
// ignore_for_file: file_names // ignore_for_file: file_names
import 'dart:ui';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/7.dart'; import 'package:gecko/screens/onBoarding/7.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class OnboardingStepEight extends StatelessWidget { class OnboardingStepSix extends StatelessWidget {
TextEditingController tplController = TextEditingController(); OnboardingStepSix({Key? key, required this.generatedMnemonic})
final int progress = 6; : super(key: key);
OnboardingStepEight({Key? key}) : super(key: key); String? generatedMnemonic;
TextEditingController wordController = TextEditingController();
final TextEditingController _mnemonicController = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
CommonElements common = CommonElements(); GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context, listen: true);
return Scaffold( CommonElements common = CommonElements();
_mnemonicController.text = generatedMnemonic!;
return WillPopScope(
onWillPop: () {
_generateWalletProvider.isAskedWordValid = false;
_generateWalletProvider.askedWordColor = Colors.black;
return Future<bool>.value(true);
},
child: Scaffold(
resizeToAvoidBottomInset: false,
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: SafeArea( appBar: AppBar(
child: Column(children: <Widget>[ toolbarHeight: 60 * ratio,
common.onboardingProgressBar( title: const SizedBox(
context, 'Ma phrase de restauration', progress), height: 22,
common.bubbleSpeak( child: Text(
"Jai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît daccéder à tous vos portefeuilles.", 'Votre phrase de restauration',
textKey: const Key('step6'), style: TextStyle(fontWeight: FontWeight.w600),
), ),
SizedBox(height: isTall ? 70 : 40), ),
// SizedBox(height: 30), ),
sentanceArray(context), body: SafeArea(
// ), child: Align(
Expanded( alignment: Alignment.topCenter,
child: Align( child: Column(children: [
SizedBox(height: isTall ? 40 : 20),
common.buildProgressBar(5),
SizedBox(height: isTall ? 40 : 20),
common.buildText(
<TextSpan>[
TextSpan(
text:
"Avez-vous bien noté votre phrase de restauration ?\n\nPour en être sûr, veuillez taper dans le champ ci-dessous le ",
style: TextStyle(fontSize: 16 * ratio)),
TextSpan(
text: '${_generateWalletProvider.nbrWord + 1}ème mot',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16 * ratio)),
TextSpan(
text: " de votre phrase de restauration :",
style: TextStyle(fontSize: 16 * ratio)),
],
),
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(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: SizedBox( child: nextButton(context, 'Continuer',
width: 400, const OnboardingStepSeven(), false),
height: 62, ),
child: ElevatedButton( ),
key: const Key('goStep7'), ),
style: ElevatedButton.styleFrom( // Visibility(
elevation: 5, // visible: !_generateWalletProvider.isAskedWordValid,
primary: orangeC, // child: const Expanded(
onPrimary: Colors.white, // foreground // child: Align(
), // alignment: Alignment.bottomCenter,
onPressed: () { // child: Text(''),
Navigator.push( // ),
context, // ),
FaderTransition( // ),
page: OnboardingStepNine(), isFast: false), const SizedBox(height: 40),
); ]),
}, ),
child: const Text("Afficher ma phrase", ),
style: TextStyle(fontSize: 20))), ),
))), );
const SizedBox(height: 80),
]),
));
} }
} }
Widget sentanceArray(BuildContext context) { Widget sentanceArray(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12), padding: const EdgeInsets.symmetric(horizontal: 3),
child: Container( child: Container(
constraints: const BoxConstraints(maxWidth: 450), constraints: const BoxConstraints(maxWidth: 450),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.black), border: Border.all(color: Colors.black),
color: Colors.grey[300], color: const Color(0xffeeeedd),
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
Radius.circular(10), Radius.circular(10),
)), )),
// color: Colors.grey[300], padding: const EdgeInsets.all(20),
padding: const EdgeInsets.all(20), child: FutureBuilder(
child: Column( future: _generateWalletProvider.generateWordList(context),
mainAxisAlignment: MainAxisAlignment.center, builder: (BuildContext context, AsyncSnapshot<List> _data) {
mainAxisSize: MainAxisSize.max, if (!_data.hasData) {
crossAxisAlignment: CrossAxisAlignment.center, return const Text('');
children: <Widget>[ } else {
Row(children: <Widget>[ return Column(
arrayCell("1:exquis"), mainAxisAlignment: MainAxisAlignment.center,
arrayCell("2:favori"), mainAxisSize: MainAxisSize.max,
arrayCell("3:curseur"), crossAxisAlignment: CrossAxisAlignment.center,
arrayCell("4:relatif"), children: <Widget>[
]), Row(children: <Widget>[
const SizedBox(height: 15), arrayCell(_data.data![0]),
Row(children: <Widget>[ arrayCell(_data.data![1]),
arrayCell("5:embellir"), arrayCell(_data.data![2]),
arrayCell("6:cultiver"), arrayCell(_data.data![3]),
arrayCell("7:bureau"), ]),
arrayCell("8:ossature"), const SizedBox(height: 15),
]), Row(children: <Widget>[
const SizedBox(height: 15), arrayCell(_data.data![4]),
Row(children: <Widget>[ arrayCell(_data.data![5]),
arrayCell("9:labial"), arrayCell(_data.data![6]),
arrayCell("10:science"), arrayCell(_data.data![7]),
arrayCell("11:théorie"), ]),
arrayCell("12:Monnaie"), const SizedBox(height: 15),
]), Row(children: <Widget>[
]))); arrayCell(_data.data![8]),
arrayCell(_data.data![9]),
arrayCell(_data.data![10]),
arrayCell(_data.data![11]),
]),
]);
}
}),
),
);
} }
Widget arrayCell(dataWord) { Widget arrayCell(dataWord) {
return SizedBox( return SizedBox(
width: 102, width: 100,
child: Column( child: Column(children: <Widget>[
children: <Widget>[ Text(
ImageFiltered( dataWord.split(':')[0],
imageFilter: ImageFilter.blur(sigmaX: 1, sigmaY: 1), style: const TextStyle(fontSize: 15, color: Color(0xff6b6b52)),
child: Text(dataWord.split(':')[0], ),
style: const TextStyle(fontSize: 14, color: Colors.black)), Text(
), dataWord.split(':')[1],
const SizedBox(height: 2), key: Key('word${dataWord.split(':')[0]}'),
ImageFiltered( style: const TextStyle(fontSize: 20, color: Colors.black),
imageFilter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), ),
child: Text(dataWord.split(':')[1], ]),
style: const TextStyle(fontSize: 19, 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(
width: 410,
height: 70,
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),
),
),
);
} }

View File

@ -1,231 +1,43 @@
// ignore_for_file: file_names // ignore_for_file: file_names
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/8.dart'; import 'package:gecko/screens/onBoarding/8.dart';
import 'package:printing/printing.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable class OnboardingStepSeven extends StatelessWidget {
class OnboardingStepNine extends StatelessWidget { const OnboardingStepSeven({Key? key}) : super(key: key);
TextEditingController tplController = TextEditingController();
final int progress = 6;
OnboardingStepNine({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
MyWalletsProvider _myWalletProvider =
Provider.of<MyWalletsProvider>(context);
CommonElements common = CommonElements(); CommonElements common = CommonElements();
// _generateWalletProvider.generateMnemonic();
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, appBar: AppBar(
body: SafeArea( toolbarHeight: 60 * ratio,
child: Column(children: <Widget>[ title: const SizedBox(
common.onboardingProgressBar( height: 22,
context, 'Ma phrase de restauration', progress), child: Text(
common.bubbleSpeak( 'Mon code secret',
"C'est le moment de noter votre phrase !", style: TextStyle(fontWeight: FontWeight.w600),
textKey: const Key('step7'), ),
long: 60,
),
SizedBox(height: isTall ? 100 : 70),
sentanceArray(context),
SizedBox(height: isTall ? 20 : 15),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return PrintWallet(
_generateWalletProvider.generatedMnemonic);
}),
);
},
child: Image.asset(
'assets/printer.png',
height: 35,
),
),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('generateMnemonic'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: const Color(0xffFFD58D),
onPrimary: Colors.black, // foreground
),
onPressed: () {
_generateWalletProvider.reloadBuild();
},
child: const Text("Choisir une autre phrase",
style: TextStyle(fontSize: 20))),
))),
const SizedBox(height: 25),
SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('goStep8'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
_generateWalletProvider.nbrWord =
_generateWalletProvider.getRandomInt();
_generateWalletProvider.nbrWordAlpha =
_generateWalletProvider
.intToString(_generateWalletProvider.nbrWord + 1);
_myWalletProvider.mnemonic =
_generateWalletProvider.generatedMnemonic!;
Navigator.push(
context,
FaderTransition(
page: OnboardingStepTen(
generatedMnemonic:
_generateWalletProvider.generatedMnemonic),
isFast: true),
);
},
child: const Text("J'ai noté ma phrase",
style: TextStyle(fontSize: 20))),
),
const SizedBox(height: 80),
]),
));
}
}
Widget sentanceArray(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
// List formatedArray = _generateWalletProvider.generateWordList();
// List formatedArray = [
// '0:',
// '1:',
// '2:',
// '3:',
// '4:',
// '5:',
// '6:',
// '7:',
// '8:',
// '9:',
// '10:',
// '11:',
// ];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Container(
constraints: const BoxConstraints(maxWidth: 450),
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
color: Colors.grey[300],
borderRadius: const BorderRadius.all(
Radius.circular(10),
)),
// color: Colors.grey[300],
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]),
]),
]);
}
}),
),
);
}
Widget arrayCell(dataWord) {
return SizedBox(
width: 102,
child: Column(children: <Widget>[
Text(
dataWord.split(':')[0],
style: const TextStyle(fontSize: 14),
),
const SizedBox(height: 2),
Text(
dataWord.split(':')[1],
key: Key('word${dataWord.split(':')[0]}'),
style: const TextStyle(fontSize: 19, color: Colors.black),
),
]),
);
}
// ignore: must_be_immutable
class PrintWallet extends StatelessWidget {
const PrintWallet(this.sentence, {Key? key}) : super(key: key);
final String? sentence;
@override
Widget build(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
Navigator.pop(context);
}),
toolbarHeight: 60 * ratio,
title: const Text('Imprimer ce coffre')),
body: PdfPreview(
build: (format) => _generateWalletProvider.printWallet(sentence),
), ),
), ),
extendBodyBehindAppBar: true,
body: SafeArea(
child: common.infoIntro(
context,
<TextSpan>[
const TextSpan(
text:
'Gecko va maintenant générer pour vous un code secret court qui vous permettra daccéder rapidement à vos portefeuilles, sans avoir à taper votre phrase de restauration à chaque fois.'),
],
'coffre-fort-code-secret-dans-telephone.png',
'>',
const OnboardingStepEight(),
6,
boxHeight: 400),
),
); );
} }
} }

View File

@ -2,134 +2,47 @@
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/9.dart'; import 'package:gecko/screens/onBoarding/9.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable class OnboardingStepEight extends StatelessWidget {
class OnboardingStepTen extends StatelessWidget { const OnboardingStepEight({Key? key}) : super(key: key);
OnboardingStepTen({
Key? validationKey,
required this.generatedMnemonic,
}) : super(key: validationKey);
String? generatedMnemonic;
TextEditingController tplController = TextEditingController();
TextEditingController wordController = TextEditingController();
final TextEditingController _mnemonicController = TextEditingController();
final int progress = 7;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
CommonElements common = CommonElements(); CommonElements common = CommonElements();
_mnemonicController.text = generatedMnemonic!; return Scaffold(
appBar: AppBar(
return WillPopScope( toolbarHeight: 60 * ratio,
onWillPop: () { title: const SizedBox(
_generateWalletProvider.isAskedWordValid = false; height: 22,
_generateWalletProvider.askedWordColor = Colors.black; child: Text(
return Future<bool>.value(true); 'Mon code secret',
}, style: TextStyle(fontWeight: FontWeight.w600),
child: Scaffold( ),
resizeToAvoidBottomInset: false, ),
extendBodyBehindAppBar: true, ),
body: SafeArea( extendBodyBehindAppBar: true,
child: Column(children: <Widget>[ body: SafeArea(
common.onboardingProgressBar( child: common.infoIntro(
context, 'Valider ma phrase de restauration', progress), context,
common.bubbleSpeakRich( <TextSpan>[
<TextSpan>[ const TextSpan(
TextSpan( text:
text: 'Ce code secret protège vos portefeuilles dans un coffre-fort '),
"Avez-vous bien noté votre phrase de restauration ?\n\nPour en être sûr, veuillez taper dans le champ ci-dessous le ", const TextSpan(
style: TextStyle(fontSize: 16 * ratio)), text: 'dont vous seul possédez le code',
TextSpan( style: TextStyle(fontWeight: FontWeight.bold)),
text: '${_generateWalletProvider.nbrWord + 1}ème mot', const TextSpan(
style: TextStyle( text:
fontWeight: FontWeight.bold, fontSize: 16 * ratio)), ', de sorte que vos portefeuilles seront inutilisables par dautres.'),
TextSpan( ],
text: " de votre phrase de restauration :", 'coffre-fort-protege-les-portefeuilles.png',
style: TextStyle(fontSize: 16 * ratio)), '>',
], const OnboardingStepThirteen(),
textKey: const Key('step8'), 7),
), ),
SizedBox(height: isTall ? 70 : 10), );
Text('${_generateWalletProvider.nbrWord + 1}',
key: const Key('askedWord'),
style: TextStyle(
fontSize: isTall ? 17 : 10,
color: orangeC,
fontWeight: FontWeight.w400)),
SizedBox(height: isTall ? 10 : 0),
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: Colors.grey[300],
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(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 400,
height: 62,
child: ElevatedButton(
key: const Key('goStep9'),
style: ElevatedButton.styleFrom(
elevation: 5,
primary: orangeC,
onPrimary: Colors.white, // foreground
),
onPressed: () {
Navigator.push(
context,
FaderTransition(
page: OnboardingStepEleven(),
isFast: true),
);
},
child: const Text("Continuer",
style: TextStyle(fontSize: 20))),
)))),
const SizedBox(height: 80),
]),
)));
} }
} }

View File

@ -1,71 +1,109 @@
// ignore_for_file: file_names // ignore_for_file: file_names
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/screens/common_elements.dart'; import 'package:gecko/screens/common_elements.dart';
import 'package:gecko/screens/onBoarding/10.dart'; import 'package:gecko/screens/onBoarding/10.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class OnboardingStepEleven extends StatelessWidget { class OnboardingStepThirteen extends StatelessWidget {
TextEditingController tplController = TextEditingController(); const OnboardingStepThirteen({Key? key}) : super(key: key);
final int progress = 8;
OnboardingStepEleven({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
// MyWalletsProvider myWalletProvider =
// Provider.of<MyWalletsProvider>(context);
CommonElements common = CommonElements(); CommonElements common = CommonElements();
_generateWalletProvider.pin.text = kDebugMode && debugPin
? 'AAAAA'
: _generateWalletProvider.changePinCode(reload: false);
return Scaffold( return Scaffold(
appBar: AppBar(
toolbarHeight: 60 * ratio,
title: const SizedBox(
height: 22,
child: Text(
'Mon code secret',
style: TextStyle(fontWeight: FontWeight.w600),
),
),
),
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: SafeArea( body: SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
common.onboardingProgressBar( SizedBox(height: isTall ? 40 : 20),
context, 'Ma phrase de restauration', progress), common.buildProgressBar(8),
common.bubbleSpeakRich( SizedBox(height: isTall ? 40 : 20),
common.buildText(
<TextSpan>[ <TextSpan>[
const TextSpan( const TextSpan(
text: "Super !\n\nJe vais maintenant créer votre "), text:
"Et voilà votre code secret !\n\nMémorisez-le ou notez-le, car il vous sera demandé "),
const TextSpan( const TextSpan(
text: 'code secret.', text: 'à chaque fois',
style: TextStyle(fontWeight: FontWeight.bold)), style: TextStyle(fontWeight: FontWeight.bold)),
const TextSpan( const TextSpan(
text: text:
" \n\nVotre code secret chiffre votre coffre de clefs, ce qui le rend inutilisable par dautres, par exemple si vous perdez votre téléphone ou si on vous le vole."), " que vous voudrez effectuer un paiement sur cet appareil."),
], ],
textKey: const Key('step9'),
), ),
SizedBox(height: isTall ? 50 : 10), const SizedBox(height: 100),
Image.asset( Stack(
'assets/onBoarding/treasure-chest-gecko-souligne.png', alignment: Alignment.centerRight,
height: 280 * ratio, //5": 400 children: <Widget>[
TextField(
key: const Key('generatedPin'),
enabled: false,
controller: _generateWalletProvider.pin,
maxLines: 1,
textAlign: TextAlign.center,
decoration: const InputDecoration(),
style: const TextStyle(
letterSpacing: 5,
fontSize: 35.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
IconButton(
icon: const Icon(Icons.replay),
color: orangeC,
onPressed: () {
_generateWalletProvider.changePinCode(reload: true);
},
),
],
), ),
Expanded( Expanded(
child: Align( child: Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: SizedBox( child: SizedBox(
width: 400, width: 410,
height: 62, height: 70,
child: ElevatedButton( child: ElevatedButton(
key: const Key('goStep10'), key: const Key('changeSecretCode'),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
elevation: 5, elevation: 4,
primary: orangeC, primary: const Color(0xffFFD58D),
onPrimary: Colors.white, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () { onPressed: () {
Navigator.push( _generateWalletProvider.changePinCode(reload: true);
context,
FaderTransition(
page: OnboardingStepTwelve(), isFast: true),
);
}, },
child: const Text("J'ai compris", child: const Text("Choisir un autre code secret",
style: TextStyle(fontSize: 20))), style: TextStyle(
fontSize: 24, fontWeight: FontWeight.w600))),
))), ))),
const SizedBox(height: 80), const SizedBox(height: 25),
common.nextButton(context, "J'ai noté mon code secret",
OnboardingStepFourteen(), false),
const SizedBox(height: 40),
]), ]),
)); ));
} }

View File

@ -295,6 +295,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.6" version: "4.0.6"
dots_indicator:
dependency: "direct main"
description:
name: dots_indicator
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
durt: durt:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -79,6 +79,7 @@ dependencies:
git: git:
url: https://github.com/poka-IT/sdk.git url: https://github.com/poka-IT/sdk.git
ref: fixAndroidActivityVersion ref: fixAndroidActivityVersion
dots_indicator: ^2.1.0
dev_dependencies: dev_dependencies:
# flutter_launcher_icons: ^0.9.2 # flutter_launcher_icons: ^0.9.2