Newer
Older
import 'package:gecko/screens/myWallets/confirmWalletStorage.dart';
import 'package:flutter/material.dart';

poka
committed
import 'package:printing/printing.dart';

poka
committed
import 'package:super_tooltip/super_tooltip.dart';
// ignore: must_be_immutable
class GenerateWalletsScreen extends StatelessWidget {

poka
committed
SuperTooltip tooltip;
bool hasError = false;
String validPin = 'NO PIN';
String currentText = "";
var pinColor = Colors.grey[300];

poka
committed
GlobalKey _toolTipPubkey = GlobalKey();
GlobalKey _toolTipSentence = GlobalKey();
GlobalKey _toolTipSecret = GlobalKey();
@override
Widget build(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
print('IS GENERATED ? : ' +
_generateWalletProvider.walletIsGenerated.toString());
return Scaffold(

poka
committed
appBar: AppBar(
title: SizedBox(

poka
committed
height: 22,

poka
committed
child: Text('Générer un portefeuille'),
)),
floatingActionButton: Container(
height: 80.0,
width: 80.0,
child: FittedBox(
child: FloatingActionButton(
heroTag: "buttonGenerateWallet",
onPressed: () => _generateWalletProvider.generateMnemonic(),
child: Container(

poka
committed
height: 40.0,
width: 40.0,
child: Icon(Icons.replay, color: Colors.grey[850]),
),
backgroundColor: Color(
0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255),
))),
body: SafeArea(
child: Column(children: <Widget>[
SizedBox(height: 20),

poka
committed
toolTips(_toolTipPubkey, 'Clé publique:',
"C'est votre RIB en Ğ1, les gens l'utiliseront pour vous payer"),
TextField(
enabled: false,
maxLines: 1,
textAlign: TextAlign.center,
decoration: InputDecoration(),
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
SizedBox(height: 8),

poka
committed
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,
maxLines: 3,
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(15.0),
),
style: TextStyle(
fontSize: 22.0,
color: Colors.black,
fontWeight: FontWeight.w400)),
SizedBox(height: 8),

poka
committed
toolTips(_toolTipSecret, 'Code secret:',
"Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"),

poka
committed
Container(
child: Stack(
alignment: Alignment.centerRight,
children: <Widget>[
TextField(
enabled: false,

poka
committed
maxLines: 1,
textAlign: TextAlign.center,
decoration: InputDecoration(),
style: TextStyle(
fontSize: 30.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
IconButton(
icon: Icon(Icons.replay),
color: Color(0xffD28928),
onPressed: () {

poka
committed
},
),
],
),
),
SizedBox(height: 20),
new ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground
),
_generateWalletProvider.nbrWord =
_generateWalletProvider.getRandomInt();
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ConfirmStoreWallet(
generatedMnemonic:
_generateWalletProvider.generatedMnemonic,
generatedWallet:
_generateWalletProvider.actualWallet);
}
: null,
child: Text('Enregistrer ce portefeuille',
style: TextStyle(fontSize: 20))),

poka
committed
SizedBox(height: 20),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return PrintWallet(
_generateWalletProvider.generatedMnemonic,
_generateWalletProvider.actualWallet.publicKey);
}),
);
},
child: Icon(Icons.print))
]),
));
}

poka
committed
Widget toolTips(_key, _text, _message) {
return GestureDetector(
onTap: () {
final dynamic _toolTip = _key.currentState;
_toolTip.ensureTooltipVisible();
},
child: Tooltip(
padding: EdgeInsets.all(10),
key: _key,
showDuration: Duration(seconds: 5),
message: _message,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[

poka
committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
Column(children: <Widget>[
SizedBox(
width: 30,
height: 25,
child: Icon(Icons.info_outline,
size: 22, color: Color(0xffD28928))),
SizedBox(height: 1)
]),
Text(
_text,
style: TextStyle(
fontSize: 15.0,
color: Colors.grey[600],
fontWeight: FontWeight.w400),
),
SizedBox(width: 45)
])));
}
}
// ignore: must_be_immutable
class PrintWallet extends StatelessWidget {
PrintWallet(this.sentence, this.pubkey);
final String sentence;
final String pubkey;
@override
Widget build(BuildContext context) {
GenerateWalletsProvider _generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context);
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Imprimer ce portefeuille')),
body: PdfPreview(
build: (format) =>
_generateWalletProvider.printWallet(sentence, pubkey),
),
),
);
}