2021-11-14 19:21:20 +01:00
|
|
|
// ignore_for_file: file_names
|
|
|
|
|
2022-06-17 01:13:14 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
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';
|
|
|
|
import 'package:gecko/providers/my_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/6.dart';
|
2022-05-23 10:53:44 +02:00
|
|
|
import 'package:printing/printing.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2021-02-28 02:38:52 +01:00
|
|
|
|
2022-05-23 10:53:44 +02:00
|
|
|
AsyncSnapshot<List>? mnemoList;
|
2021-02-28 02:38:52 +01:00
|
|
|
|
2022-05-29 01:38:27 +02:00
|
|
|
class OnboardingStepFive extends StatefulWidget {
|
2022-05-25 20:40:25 +02:00
|
|
|
const OnboardingStepFive({Key? key, this.skipIntro = false})
|
|
|
|
: super(key: key);
|
|
|
|
final bool skipIntro;
|
2021-11-14 19:21:20 +01:00
|
|
|
|
2022-05-29 01:38:27 +02:00
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _ChooseChestState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore: unused_element
|
|
|
|
class _ChooseChestState extends State<OnboardingStepFive> {
|
2021-02-28 02:38:52 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2022-08-06 02:22:41 +02:00
|
|
|
GenerateWalletsProvider generateWalletProvider =
|
2022-05-23 10:53:44 +02:00
|
|
|
Provider.of<GenerateWalletsProvider>(context, listen: false);
|
|
|
|
|
2022-05-29 01:38:27 +02:00
|
|
|
final CommonElements common = CommonElements();
|
2021-03-01 04:48:28 +01:00
|
|
|
|
2021-02-28 02:38:52 +01:00
|
|
|
return Scaffold(
|
2022-05-29 00:00:57 +02:00
|
|
|
backgroundColor: backgroundColor,
|
2022-05-23 10:53:44 +02:00
|
|
|
appBar: AppBar(
|
|
|
|
toolbarHeight: 60 * ratio,
|
2022-06-17 23:10:01 +02:00
|
|
|
title: SizedBox(
|
2022-05-23 10:53:44 +02:00
|
|
|
height: 22,
|
|
|
|
child: Text(
|
2022-06-17 23:10:01 +02:00
|
|
|
'yourMnemonic'.tr(),
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
extendBodyBehindAppBar: true,
|
|
|
|
body: SafeArea(
|
|
|
|
child: Column(children: [
|
|
|
|
SizedBox(height: isTall ? 40 : 20),
|
|
|
|
common.buildProgressBar(4),
|
|
|
|
SizedBox(height: isTall ? 40 : 20),
|
2022-06-17 23:10:01 +02:00
|
|
|
common.buildText('geckoGeneratedYourMnemonicKeepItSecret'.tr()),
|
2022-05-25 20:40:25 +02:00
|
|
|
SizedBox(height: 35 * ratio),
|
2022-05-23 10:53:44 +02:00
|
|
|
sentanceArray(context),
|
2022-05-25 20:40:25 +02:00
|
|
|
SizedBox(height: 17 * ratio),
|
2022-05-23 10:53:44 +02:00
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
2022-08-06 02:22:41 +02:00
|
|
|
return PrintWallet(generateWalletProvider.generatedMnemonic);
|
2022-05-23 10:53:44 +02:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Image.asset(
|
|
|
|
'assets/printer.png',
|
2022-05-25 20:40:25 +02:00
|
|
|
height: 42 * ratio,
|
2021-02-28 02:38:52 +01:00
|
|
|
),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
|
|
|
const SizedBox(height: 40),
|
|
|
|
Expanded(
|
|
|
|
child: Align(
|
2021-02-28 02:38:52 +01:00
|
|
|
alignment: Alignment.bottomCenter,
|
2022-05-23 10:53:44 +02:00
|
|
|
child: 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(
|
|
|
|
key: const Key('generateMnemonic'),
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
elevation: 4,
|
|
|
|
primary: const Color(0xffFFD58D),
|
|
|
|
onPrimary: Colors.black, // foreground
|
|
|
|
),
|
|
|
|
onPressed: () {
|
2022-05-29 01:38:27 +02:00
|
|
|
// _generateWalletProvider.reloadBuild();
|
|
|
|
setState(() {});
|
2022-05-23 10:53:44 +02:00
|
|
|
},
|
2022-06-17 01:13:14 +02:00
|
|
|
child: Text("chooseAnotherMnemonic".tr(),
|
|
|
|
textAlign: TextAlign.center,
|
2022-05-23 10:53:44 +02:00
|
|
|
style: TextStyle(
|
2022-05-25 20:40:25 +02:00
|
|
|
fontSize: 22 * ratio,
|
|
|
|
fontWeight: FontWeight.w600))),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
2021-02-28 02:38:52 +01:00
|
|
|
),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
2022-05-25 20:40:25 +02:00
|
|
|
SizedBox(height: 22 * ratio),
|
2022-06-17 01:13:14 +02:00
|
|
|
nextButton(context, "iNotedMyMnemonic".tr(), false, widget.skipIntro),
|
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
|
|
|
}
|
|
|
|
}
|
2022-05-23 10:53:44 +02:00
|
|
|
|
|
|
|
Widget sentanceArray(BuildContext context) {
|
2022-08-06 02:22:41 +02:00
|
|
|
GenerateWalletsProvider generateWalletProvider =
|
2022-05-29 01:38:27 +02:00
|
|
|
Provider.of<GenerateWalletsProvider>(context, listen: false);
|
2022-05-23 10:53:44 +02:00
|
|
|
|
|
|
|
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(
|
2022-08-06 02:22:41 +02:00
|
|
|
future: generateWalletProvider.generateWordList(context),
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<List> data) {
|
|
|
|
if (!data.hasData) {
|
2022-05-23 10:53:44 +02:00
|
|
|
return const Text('');
|
|
|
|
} else {
|
2022-08-06 02:22:41 +02:00
|
|
|
mnemoList = data;
|
2022-05-23 10:53:44 +02:00
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(children: <Widget>[
|
2022-08-06 02:22:41 +02:00
|
|
|
arrayCell(data.data![0]),
|
|
|
|
arrayCell(data.data![1]),
|
|
|
|
arrayCell(data.data![2]),
|
|
|
|
arrayCell(data.data![3]),
|
2022-05-23 10:53:44 +02:00
|
|
|
]),
|
|
|
|
const SizedBox(height: 15),
|
|
|
|
Row(children: <Widget>[
|
2022-08-06 02:22:41 +02:00
|
|
|
arrayCell(data.data![4]),
|
|
|
|
arrayCell(data.data![5]),
|
|
|
|
arrayCell(data.data![6]),
|
|
|
|
arrayCell(data.data![7]),
|
2022-05-23 10:53:44 +02:00
|
|
|
]),
|
|
|
|
const SizedBox(height: 15),
|
|
|
|
Row(children: <Widget>[
|
2022-08-06 02:22:41 +02:00
|
|
|
arrayCell(data.data![8]),
|
|
|
|
arrayCell(data.data![9]),
|
|
|
|
arrayCell(data.data![10]),
|
|
|
|
arrayCell(data.data![11]),
|
2022-05-23 10:53:44 +02:00
|
|
|
]),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget arrayCell(dataWord) {
|
|
|
|
return SizedBox(
|
|
|
|
width: 100,
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Text(
|
|
|
|
dataWord.split(':')[0],
|
2022-05-25 20:40:25 +02:00
|
|
|
style: TextStyle(fontSize: 13 * ratio, color: const Color(0xff6b6b52)),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
|
|
|
Text(
|
|
|
|
dataWord.split(':')[1],
|
|
|
|
key: Key('word${dataWord.split(':')[0]}'),
|
2022-05-25 20:40:25 +02:00
|
|
|
style: TextStyle(fontSize: 17 * ratio, color: Colors.black),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2022-08-06 02:22:41 +02:00
|
|
|
GenerateWalletsProvider generateWalletProvider =
|
2022-05-29 01:38:27 +02:00
|
|
|
Provider.of<GenerateWalletsProvider>(context, listen: false);
|
2022-05-23 10:53:44 +02:00
|
|
|
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(
|
2022-06-17 01:13:14 +02:00
|
|
|
'printMyMnemonic',
|
2022-05-23 10:53:44 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.w600),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: PdfPreview(
|
|
|
|
canDebug: false,
|
|
|
|
canChangeOrientation: false,
|
2022-08-06 02:22:41 +02:00
|
|
|
build: (format) => generateWalletProvider.printWallet(mnemoList),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-25 20:40:25 +02:00
|
|
|
Widget nextButton(
|
|
|
|
BuildContext context, String text, bool isFast, bool skipIntro) {
|
2022-08-06 02:22:41 +02:00
|
|
|
GenerateWalletsProvider generateWalletProvider =
|
2022-05-23 10:53:44 +02:00
|
|
|
Provider.of<GenerateWalletsProvider>(context, listen: false);
|
2022-08-06 02:22:41 +02:00
|
|
|
MyWalletsProvider myWalletProvider =
|
2022-05-23 10:53:44 +02:00
|
|
|
Provider.of<MyWalletsProvider>(context, listen: false);
|
|
|
|
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: () {
|
2022-08-06 02:22:41 +02:00
|
|
|
generateWalletProvider.nbrWord = generateWalletProvider.getRandomInt();
|
|
|
|
generateWalletProvider.nbrWordAlpha = generateWalletProvider
|
|
|
|
.intToString(generateWalletProvider.nbrWord + 1);
|
|
|
|
myWalletProvider.mnemonic = generateWalletProvider.generatedMnemonic!;
|
2022-05-23 10:53:44 +02:00
|
|
|
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
FaderTransition(
|
|
|
|
page: OnboardingStepSix(
|
2022-08-06 02:22:41 +02:00
|
|
|
generatedMnemonic: generateWalletProvider.generatedMnemonic,
|
2022-05-25 20:40:25 +02:00
|
|
|
skipIntro: skipIntro),
|
2022-05-23 10:53:44 +02:00
|
|
|
isFast: true),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
text,
|
2022-05-25 20:40:25 +02:00
|
|
|
style: TextStyle(fontSize: 22 * ratio, fontWeight: FontWeight.w600),
|
2022-05-23 10:53:44 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|