2021-02-27 20:29:35 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2021-11-08 23:12:25 +01:00
|
|
|
import 'package:gecko/globals.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/models/generate_wallets.dart';
|
|
|
|
import 'package:gecko/screens/myWallets/confirm_wallet_storage.dart';
|
2021-01-13 00:00:11 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-01-29 02:20:15 +01:00
|
|
|
import 'package:printing/printing.dart';
|
2021-01-26 21:00:26 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2021-01-13 05:36:23 +01:00
|
|
|
import 'package:super_tooltip/super_tooltip.dart';
|
2021-01-13 00:00:11 +01:00
|
|
|
|
2021-01-26 21:00:26 +01:00
|
|
|
// ignore: must_be_immutable
|
2021-11-18 04:41:45 +01:00
|
|
|
class GenerateFastChestScreen extends StatelessWidget {
|
2021-01-13 05:36:23 +01:00
|
|
|
SuperTooltip tooltip;
|
2021-01-13 00:00:11 +01:00
|
|
|
bool hasError = false;
|
|
|
|
String validPin = 'NO PIN';
|
|
|
|
String currentText = "";
|
|
|
|
var pinColor = Colors.grey[300];
|
|
|
|
|
2021-11-14 19:21:20 +01:00
|
|
|
final GlobalKey _toolTipSentence = GlobalKey();
|
|
|
|
final GlobalKey _toolTipSecret = GlobalKey();
|
|
|
|
|
2021-11-18 04:41:45 +01:00
|
|
|
GenerateFastChestScreen({Key key}) : super(key: key);
|
2021-01-29 02:20:15 +01:00
|
|
|
|
2021-01-13 00:00:11 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-02-27 20:29:35 +01:00
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2021-01-28 15:10:09 +01:00
|
|
|
GenerateWalletsProvider _generateWalletProvider =
|
|
|
|
Provider.of<GenerateWalletsProvider>(context);
|
2021-01-26 21:00:26 +01:00
|
|
|
_generateWalletProvider.generateMnemonic();
|
2021-02-18 04:42:57 +01:00
|
|
|
|
2021-01-13 00:00:11 +01:00
|
|
|
return Scaffold(
|
2021-01-15 03:11:58 +01:00
|
|
|
appBar: AppBar(
|
2021-11-15 04:16:25 +01:00
|
|
|
toolbarHeight: 60 * ratio,
|
2021-11-14 19:21:20 +01:00
|
|
|
title: const SizedBox(
|
2021-11-15 04:16:25 +01:00
|
|
|
height: 22,
|
|
|
|
child: Text('Générer un trousseau'),
|
|
|
|
)),
|
2021-11-14 19:21:20 +01:00
|
|
|
floatingActionButton: SizedBox(
|
2021-01-13 00:00:11 +01:00
|
|
|
height: 80.0,
|
|
|
|
width: 80.0,
|
|
|
|
child: FittedBox(
|
|
|
|
child: FloatingActionButton(
|
|
|
|
heroTag: "buttonGenerateWallet",
|
2021-01-26 21:00:26 +01:00
|
|
|
onPressed: () => _generateWalletProvider.generateMnemonic(),
|
2021-11-14 19:21:20 +01:00
|
|
|
child: SizedBox(
|
2021-01-16 03:32:41 +01:00
|
|
|
height: 40.0,
|
|
|
|
width: 40.0,
|
|
|
|
child: Icon(Icons.replay, color: Colors.grey[850]),
|
|
|
|
),
|
2021-11-08 23:12:25 +01:00
|
|
|
backgroundColor:
|
|
|
|
floattingYellow, //smoothYellow, //Color.fromARGB(500, 204, 255, 255),
|
2021-01-13 00:00:11 +01:00
|
|
|
))),
|
2021-02-07 02:59:48 +01:00
|
|
|
body: Builder(
|
|
|
|
builder: (ctx) => SafeArea(
|
|
|
|
child: Column(children: <Widget>[
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 20),
|
2021-02-07 02:59:48 +01:00
|
|
|
toolTips(_toolTipSentence, 'Phrase de restauration:',
|
|
|
|
"Notez et gardez cette phrase précieusement sur un papier, elle vous servira à restaurer votre portefeuille sur un autre appareil"),
|
|
|
|
TextField(
|
|
|
|
enabled: false,
|
|
|
|
controller: _generateWalletProvider.mnemonicController,
|
|
|
|
maxLines: 3,
|
|
|
|
textAlign: TextAlign.center,
|
2021-11-14 19:21:20 +01:00
|
|
|
decoration: const InputDecoration(
|
2021-02-07 02:59:48 +01:00
|
|
|
contentPadding: EdgeInsets.all(15.0),
|
|
|
|
),
|
2021-11-14 19:21:20 +01:00
|
|
|
style: const TextStyle(
|
2021-02-07 02:59:48 +01:00
|
|
|
fontSize: 22.0,
|
|
|
|
color: Colors.black,
|
|
|
|
fontWeight: FontWeight.w400)),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 8),
|
2021-02-07 02:59:48 +01:00
|
|
|
toolTips(_toolTipSecret, 'Code secret:',
|
|
|
|
"Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"),
|
2021-11-14 19:21:20 +01:00
|
|
|
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(
|
|
|
|
fontSize: 30.0,
|
|
|
|
color: Colors.black,
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.replay),
|
|
|
|
color: orangeC,
|
|
|
|
onPressed: () {
|
|
|
|
_generateWalletProvider.changePinCode(
|
|
|
|
reload: false);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
2021-02-07 02:59:48 +01:00
|
|
|
),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 20),
|
2021-02-17 00:15:08 +01:00
|
|
|
ElevatedButton(
|
2021-11-14 19:21:20 +01:00
|
|
|
key: const Key('storeKeychain'),
|
2021-02-07 02:59:48 +01:00
|
|
|
style: ElevatedButton.styleFrom(
|
2021-11-08 23:12:25 +01:00
|
|
|
primary: yellowC, // background
|
2021-02-07 02:59:48 +01:00
|
|
|
onPrimary: Colors.black, // foreground
|
|
|
|
),
|
|
|
|
onPressed: _generateWalletProvider.walletIsGenerated
|
2021-11-18 04:41:45 +01:00
|
|
|
? () async {
|
2021-02-07 02:59:48 +01:00
|
|
|
_generateWalletProvider.nbrWord =
|
|
|
|
_generateWalletProvider.getRandomInt();
|
2021-11-18 04:41:45 +01:00
|
|
|
await Navigator.push(
|
2021-02-07 02:59:48 +01:00
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return ConfirmStoreWallet(
|
|
|
|
generatedMnemonic:
|
|
|
|
_generateWalletProvider
|
|
|
|
.generatedMnemonic,
|
|
|
|
generatedWallet: _generateWalletProvider
|
|
|
|
.actualWallet);
|
|
|
|
}),
|
|
|
|
);
|
2021-11-18 04:41:45 +01:00
|
|
|
await Future.delayed(
|
|
|
|
const Duration(milliseconds: 20));
|
2021-11-19 03:18:39 +01:00
|
|
|
// if (_generateWalletProvider.hasBeenStored) {
|
|
|
|
// _generateWalletProvider.hasBeenStored = false;
|
|
|
|
// await Navigator.pushAndRemoveUntil(context,
|
|
|
|
// MaterialPageRoute(builder: (context) {
|
|
|
|
// return UnlockingWallet(
|
|
|
|
// wallet: _myWalletClass.getDefaultWallet(
|
|
|
|
// configBox.get('currentChest')),
|
|
|
|
// action: "mywallets",
|
|
|
|
// );
|
|
|
|
// }), ModalRoute.withName('/'));
|
|
|
|
// }
|
2021-02-07 02:59:48 +01:00
|
|
|
}
|
|
|
|
: null,
|
2021-11-14 19:21:20 +01:00
|
|
|
child: const Text('Enregistrer ce trousseau',
|
2021-02-07 02:59:48 +01:00
|
|
|
style: TextStyle(fontSize: 20))),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 20),
|
2021-02-07 02:59:48 +01:00
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) {
|
|
|
|
return PrintWallet(
|
2021-02-14 21:04:58 +01:00
|
|
|
_generateWalletProvider.generatedMnemonic);
|
2021-02-07 02:59:48 +01:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
2021-11-14 19:21:20 +01:00
|
|
|
child: const Icon(Icons.print))
|
2021-02-07 02:59:48 +01:00
|
|
|
]),
|
|
|
|
)));
|
2021-01-13 00:00:11 +01:00
|
|
|
}
|
2021-01-29 02:20:15 +01:00
|
|
|
|
|
|
|
Widget toolTips(_key, _text, _message) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
final dynamic _toolTip = _key.currentState;
|
|
|
|
_toolTip.ensureTooltipVisible();
|
|
|
|
},
|
|
|
|
child: Tooltip(
|
2021-11-14 19:21:20 +01:00
|
|
|
padding: const EdgeInsets.all(10),
|
2021-01-29 02:20:15 +01:00
|
|
|
key: _key,
|
2021-11-14 19:21:20 +01:00
|
|
|
showDuration: const Duration(seconds: 5),
|
2021-01-29 02:20:15 +01:00
|
|
|
message: _message,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(width: 20),
|
2021-01-29 02:20:15 +01:00
|
|
|
Column(children: <Widget>[
|
|
|
|
SizedBox(
|
|
|
|
width: 30,
|
|
|
|
height: 25,
|
2021-11-08 23:12:25 +01:00
|
|
|
child:
|
|
|
|
Icon(Icons.info_outline, size: 22, color: orangeC)),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(height: 1)
|
2021-01-29 02:20:15 +01:00
|
|
|
]),
|
|
|
|
Text(
|
|
|
|
_text,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15.0,
|
|
|
|
color: Colors.grey[600],
|
|
|
|
fontWeight: FontWeight.w400),
|
|
|
|
),
|
2021-11-14 19:21:20 +01:00
|
|
|
const SizedBox(width: 45)
|
2021-01-29 02:20:15 +01:00
|
|
|
])));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
class PrintWallet extends StatelessWidget {
|
2021-11-14 19:21:20 +01:00
|
|
|
const PrintWallet(this.sentence, {Key key}) : super(key: key);
|
2021-01-29 02:20:15 +01:00
|
|
|
|
|
|
|
final String sentence;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
GenerateWalletsProvider _generateWalletProvider =
|
|
|
|
Provider.of<GenerateWalletsProvider>(context);
|
|
|
|
return MaterialApp(
|
|
|
|
home: Scaffold(
|
2021-11-15 04:16:25 +01:00
|
|
|
appBar: AppBar(
|
|
|
|
toolbarHeight: 60 * ratio,
|
|
|
|
title: const Text('Imprimer ce trousseau')),
|
2021-01-29 02:20:15 +01:00
|
|
|
body: PdfPreview(
|
2021-02-14 21:04:58 +01:00
|
|
|
build: (format) => _generateWalletProvider.printWallet(sentence),
|
2021-01-29 02:20:15 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-01-13 00:00:11 +01:00
|
|
|
}
|