gecko/lib/screens/onBoarding/5.dart

259 lines
8.9 KiB
Dart
Raw Normal View History

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/material.dart';
import 'package:flutter/services.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/widgets_keys.dart';
2022-05-23 10:53:44 +02:00
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/wallets_profiles.dart';
2023-11-17 13:12:18 +01:00
import 'package:gecko/screens/myWallets/show_seed.dart';
2022-12-10 08:16:38 +01:00
import 'package:gecko/widgets/commons/build_progress_bar.dart';
import 'package:gecko/widgets/commons/build_text.dart';
2021-03-08 06:21:04 +01:00
import 'package:gecko/screens/onBoarding/6.dart';
2022-12-10 08:16:38 +01:00
import 'package:gecko/widgets/commons/fader_transition.dart';
import 'package:gecko/widgets/commons/offline_info.dart';
2022-05-23 10:53:44 +02:00
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
class OnboardingStepFive extends StatefulWidget {
const OnboardingStepFive({Key? key, this.skipIntro = false})
: super(key: key);
final bool skipIntro;
2021-11-14 19:21:20 +01: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) {
final generateWalletProvider =
2022-05-23 10:53:44 +02:00
Provider.of<GenerateWalletsProvider>(context, listen: false);
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: Stack(children: [
Column(children: [
SizedBox(height: isTall ? 40 : 20),
2022-12-10 08:16:38 +01:00
const BuildProgressBar(pagePosition: 4),
SizedBox(height: isTall ? 40 : 20),
2022-12-10 08:16:38 +01:00
BuildText(text: 'geckoGeneratedYourMnemonicKeepItSecret'.tr()),
SizedBox(height: 35 * ratio),
sentanceArray(context),
SizedBox(height: 17 * ratio),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return PrintWallet(
2023-11-17 13:12:18 +01:00
generateWalletProvider.generatedMnemonic!);
}),
);
},
child: Image.asset(
'assets/printer.png',
height: 42 * ratio,
),
),
SizedBox(
height: 40,
width: 120,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
backgroundColor: orangeC,
elevation: 1, // foreground
),
onPressed: () {
Clipboard.setData(ClipboardData(
2023-05-24 14:37:28 +02:00
text: generateWalletProvider.generatedMnemonic!));
snackCopySeed(context);
},
child: Row(children: <Widget>[
Image.asset(
'assets/walletOptions/copy-white.png',
height: 25,
),
const SizedBox(width: 7),
Text(
'copy'.tr(),
style: TextStyle(fontSize: 15, color: Colors.grey[50]),
)
]),
),
),
],
2021-02-28 02:38:52 +01:00
),
const SizedBox(height: 40),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 380 * ratio,
height: 60 * ratio,
child: ElevatedButton(
key: keyGenerateMnemonic,
style: ElevatedButton.styleFrom(
2022-09-05 08:12:24 +02:00
foregroundColor: Colors.black, elevation: 4,
backgroundColor: const Color(0xffFFD58D), // foreground
),
onPressed: () {
// _generateWalletProvider.reloadBuild();
setState(() {});
},
child: Text("chooseAnotherMnemonic".tr(),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22 * ratio,
fontWeight: FontWeight.w600))),
),
2022-05-23 10:53:44 +02:00
),
2021-02-28 02:38:52 +01:00
),
SizedBox(height: 22 * ratio),
nextButton(
context, "iNotedMyMnemonic".tr(), false, widget.skipIntro),
2022-09-01 04:51:51 +02:00
const Spacer(),
// SizedBox(height: 35 * ratio),
]),
2022-12-10 08:16:38 +01:00
const OfflineInfo(),
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) {
final generateWalletProvider =
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(
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 {
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>[
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>[
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>[
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],
style: TextStyle(fontSize: 13 * ratio, color: const Color(0xff6b6b52)),
2022-05-23 10:53:44 +02:00
),
Text(
dataWord.split(':')[1],
key: keyMnemonicWord(dataWord.split(':')[0]),
style: TextStyle(fontSize: 17 * ratio, color: Colors.black),
2022-05-23 10:53:44 +02:00
),
]),
);
}
Widget nextButton(
BuildContext context, String text, bool isFast, bool skipIntro) {
final generateWalletProvider =
2022-05-23 10:53:44 +02:00
Provider.of<GenerateWalletsProvider>(context, listen: false);
final myWalletProvider =
2022-05-23 10:53:44 +02:00
Provider.of<MyWalletsProvider>(context, listen: false);
return SizedBox(
width: 380 * ratio,
height: 60 * ratio,
2022-05-23 10:53:44 +02:00
child: ElevatedButton(
2022-09-01 04:51:51 +02:00
key: keyGoNext,
2022-05-23 10:53:44 +02:00
style: ElevatedButton.styleFrom(
2022-09-05 08:12:24 +02:00
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
2022-05-23 10:53:44 +02:00
),
onPressed: () {
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(
generatedMnemonic: generateWalletProvider.generatedMnemonic,
skipIntro: skipIntro),
2022-05-23 10:53:44 +02:00
isFast: true),
);
},
child: Text(
text,
style: TextStyle(fontSize: 22 * ratio, fontWeight: FontWeight.w600),
2022-05-23 10:53:44 +02:00
),
),
);
}