2021-01-28 15:26:26 +01:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2021-01-28 21:45:35 +01:00
|
|
|
import 'package:gecko/models/myWallets.dart';
|
2021-01-28 15:26:26 +01:00
|
|
|
import 'package:gecko/models/walletOptions.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:provider/provider.dart';
|
2021-02-06 08:31:14 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2021-01-28 15:26:26 +01:00
|
|
|
|
|
|
|
// ignore: must_be_immutable
|
|
|
|
class WalletOptions extends StatelessWidget with ChangeNotifier {
|
2021-02-14 23:17:03 +01:00
|
|
|
WalletOptions(
|
2021-02-15 01:44:25 +01:00
|
|
|
{Key keyMyWallets,
|
|
|
|
@required this.walletNbr,
|
|
|
|
@required this.walletName,
|
|
|
|
@required this.derivation})
|
2021-01-28 15:26:26 +01:00
|
|
|
: super(key: keyMyWallets);
|
2021-02-14 23:17:03 +01:00
|
|
|
int walletNbr;
|
2021-01-28 15:26:26 +01:00
|
|
|
String walletName;
|
2021-02-15 01:44:25 +01:00
|
|
|
int derivation;
|
2021-01-28 15:26:26 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-02-27 20:29:35 +01:00
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2021-01-28 21:45:35 +01:00
|
|
|
print("Build walletOptions");
|
2021-01-28 15:26:26 +01:00
|
|
|
WalletOptionsProvider _walletOptions =
|
|
|
|
Provider.of<WalletOptionsProvider>(context);
|
2021-01-28 21:45:35 +01:00
|
|
|
MyWalletsProvider _myWalletProvider =
|
|
|
|
Provider.of<MyWalletsProvider>(context);
|
2021-03-08 02:20:48 +01:00
|
|
|
|
2021-01-28 15:26:26 +01:00
|
|
|
// _walletOptions.isWalletUnlock = false;
|
2021-03-06 22:26:30 +01:00
|
|
|
print("Is unlock ? ${_walletOptions.isWalletUnlock}");
|
2021-02-09 22:11:57 +01:00
|
|
|
|
2021-01-28 15:26:26 +01:00
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: () {
|
|
|
|
_walletOptions.isWalletUnlock = false;
|
2021-03-08 02:20:48 +01:00
|
|
|
Navigator.popUntil(
|
|
|
|
context,
|
|
|
|
ModalRoute.withName('/mywallets'),
|
|
|
|
);
|
2021-01-28 15:26:26 +01:00
|
|
|
return Future<bool>.value(true);
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
2021-03-08 02:20:48 +01:00
|
|
|
resizeToAvoidBottomInset: false,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: IconButton(
|
|
|
|
icon: Icon(Icons.arrow_back, color: Colors.black),
|
|
|
|
onPressed: () {
|
|
|
|
_walletOptions.isWalletUnlock = false;
|
|
|
|
Navigator.popUntil(
|
|
|
|
context,
|
|
|
|
ModalRoute.withName('/mywallets'),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
title: SizedBox(
|
|
|
|
height: 22,
|
|
|
|
child: Text(walletName),
|
|
|
|
)),
|
|
|
|
body: Builder(
|
|
|
|
builder: (ctx) => SafeArea(
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
SizedBox(height: 15),
|
|
|
|
Text(
|
|
|
|
'Clé publique:',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15.0,
|
|
|
|
color: Colors.grey[600],
|
|
|
|
fontWeight: FontWeight.w400),
|
|
|
|
),
|
|
|
|
SizedBox(height: 15),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Clipboard.setData(ClipboardData(
|
|
|
|
text: _walletOptions.pubkey.text));
|
|
|
|
_walletOptions.snackCopyKey(ctx);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
_walletOptions.pubkey.text,
|
2021-02-06 08:31:14 +01:00
|
|
|
style: TextStyle(
|
2021-03-08 02:20:48 +01:00
|
|
|
fontSize: 14.0,
|
2021-02-06 08:31:14 +01:00
|
|
|
color: Colors.black,
|
2021-03-08 02:20:48 +01:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontFamily: 'Monospace'),
|
|
|
|
)),
|
|
|
|
Expanded(
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
child: SizedBox(
|
|
|
|
height: 50,
|
|
|
|
width: 300,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
elevation: 5,
|
|
|
|
primary: Color(
|
|
|
|
0xffFFD68E), //Color(0xffFFD68E), // background
|
|
|
|
onPrimary: Colors.black, // foreground
|
|
|
|
),
|
|
|
|
onPressed: () => _walletOptions
|
|
|
|
.renameWalletAlerte(
|
|
|
|
context,
|
|
|
|
walletName,
|
|
|
|
walletNbr,
|
|
|
|
derivation)
|
|
|
|
.then((_result) {
|
|
|
|
if (_result == true) {
|
|
|
|
WidgetsBinding.instance
|
|
|
|
.addPostFrameCallback((_) {
|
|
|
|
_myWalletProvider
|
|
|
|
.listWallets =
|
|
|
|
_myWalletProvider
|
|
|
|
.getAllWalletsNames();
|
|
|
|
_myWalletProvider
|
|
|
|
.rebuildWidget();
|
|
|
|
});
|
|
|
|
Navigator.popUntil(
|
|
|
|
context,
|
|
|
|
ModalRoute.withName(
|
|
|
|
'/mywallets'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
child: Text('Renommer ce portefeuille',
|
|
|
|
style: TextStyle(fontSize: 20)))))),
|
|
|
|
SizedBox(height: 30),
|
|
|
|
SizedBox(
|
|
|
|
height: 50,
|
|
|
|
width: 300,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
elevation: 6,
|
|
|
|
primary: Colors
|
|
|
|
.redAccent, //Color(0xffFFD68E), // background
|
|
|
|
onPrimary: Colors.black, // foreground
|
|
|
|
),
|
|
|
|
onPressed: () async {
|
|
|
|
await _walletOptions.deleteWallet(context,
|
|
|
|
walletNbr, walletName, derivation);
|
|
|
|
WidgetsBinding.instance
|
|
|
|
.addPostFrameCallback((_) {
|
|
|
|
_myWalletProvider.listWallets =
|
|
|
|
_myWalletProvider.getAllWalletsNames();
|
|
|
|
_myWalletProvider.rebuildWidget();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Text('Supprimer ce portefeuille',
|
|
|
|
style: TextStyle(fontSize: 20)))),
|
|
|
|
SizedBox(height: 50),
|
|
|
|
Text(
|
|
|
|
'Portefeuille déverrouillé',
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.green,
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
fontSize: 15),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10)
|
|
|
|
])),
|
|
|
|
]),
|
|
|
|
)),
|
|
|
|
));
|
2021-03-06 22:26:30 +01:00
|
|
|
}
|
2021-01-28 15:26:26 +01:00
|
|
|
}
|