Fix buggies stuff
This commit is contained in:
parent
0f88f55e04
commit
c68e152040
|
@ -44,6 +44,7 @@ Future<void> main() async {
|
||||||
await _homeProvider.getAppPath();
|
await _homeProvider.getAppPath();
|
||||||
await _homeProvider.createDefaultAvatar();
|
await _homeProvider.createDefaultAvatar();
|
||||||
await _walletsProvider.initWalletFolder();
|
await _walletsProvider.initWalletFolder();
|
||||||
|
_walletsProvider.getDefaultWallet();
|
||||||
appVersion = await _homeProvider.getAppVersion();
|
appVersion = await _homeProvider.getAppVersion();
|
||||||
prefs = await SharedPreferences.getInstance();
|
prefs = await SharedPreferences.getInstance();
|
||||||
// final HiveStore _store =
|
// final HiveStore _store =
|
||||||
|
|
|
@ -11,7 +11,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
int pinLenght;
|
int pinLenght;
|
||||||
|
|
||||||
Future initWalletFolder() async {
|
Future initWalletFolder() async {
|
||||||
getDefaultWallet();
|
// getDefaultWallet();
|
||||||
|
|
||||||
final bool isWalletFolderExist = await walletsDirectory.exists();
|
final bool isWalletFolderExist = await walletsDirectory.exists();
|
||||||
if (!isWalletFolderExist) {
|
if (!isWalletFolderExist) {
|
||||||
|
@ -32,6 +32,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
await File('${walletsDirectory.path}/0/order.conf').create();
|
await File('${walletsDirectory.path}/0/order.conf').create();
|
||||||
await File('${walletsDirectory.path}/1/list.conf').create();
|
await File('${walletsDirectory.path}/1/list.conf').create();
|
||||||
await File('${walletsDirectory.path}/1/order.conf').create();
|
await File('${walletsDirectory.path}/1/order.conf').create();
|
||||||
|
getDefaultWallet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +90,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
if (!defaultWalletFile.existsSync()) {
|
if (!defaultWalletFile.existsSync()) {
|
||||||
File(defaultWalletFile.path).createSync();
|
File(defaultWalletFile.path).createSync();
|
||||||
|
defaultWalletFile.writeAsStringSync("0:0");
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultWallet = getWalletData(defaultWalletFile.readAsStringSync());
|
defaultWallet = getWalletData(defaultWalletFile.readAsStringSync());
|
||||||
|
@ -102,7 +104,9 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
if (_answer) {
|
if (_answer) {
|
||||||
await walletsDirectory.delete(recursive: true);
|
await walletsDirectory.delete(recursive: true);
|
||||||
|
await defaultWalletFile.delete();
|
||||||
await walletsDirectory.create();
|
await walletsDirectory.create();
|
||||||
|
await defaultWalletFile.create();
|
||||||
await initWalletFolder();
|
await initWalletFolder();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
|
@ -74,11 +74,12 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
Future readLocalWallet(
|
Future readLocalWallet(
|
||||||
context, WalletData _wallet, String _pin, int _pinLenght) async {
|
context, WalletData _wallet, String _pin, int _pinLenght) async {
|
||||||
isWalletUnlock = false;
|
isWalletUnlock = false;
|
||||||
// MyWalletsProvider _myWalletProvider = MyWalletsProvider();
|
|
||||||
try {
|
try {
|
||||||
File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif');
|
File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif');
|
||||||
String _localDewif = await _walletFile.readAsString();
|
String _localDewif = await _walletFile.readAsString();
|
||||||
String _localPubkey;
|
String _localPubkey;
|
||||||
|
// log.d("_wallet:");
|
||||||
|
log.d(_pin);
|
||||||
|
|
||||||
if ((_localPubkey = await _getPubkeyFromDewif(
|
if ((_localPubkey = await _getPubkeyFromDewif(
|
||||||
_localDewif, _pin, _pinLenght, _wallet.derivation)) !=
|
_localDewif, _pin, _pinLenght, _wallet.derivation)) !=
|
||||||
|
|
|
@ -337,7 +337,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Text('Commentaire:'),
|
Text('Commentaire:', style: TextStyle(fontSize: 20.0)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
@ -346,18 +346,25 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
decoration: InputDecoration(),
|
decoration: InputDecoration(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14.0,
|
fontSize: 22,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontWeight: FontWeight.bold))),
|
fontWeight: FontWeight.bold))),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Text('Montant (Ğ1):'),
|
Text('Montant (DU/Ğ1):', style: TextStyle(fontSize: 20.0)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
|
style: TextStyle(fontSize: 22),
|
||||||
controller: _historyProvider.payAmount,
|
controller: _historyProvider.payAmount,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(vertical: 25.0, horizontal: 10.0),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10.0)),
|
||||||
|
),
|
||||||
inputFormatters: <TextInputFormatter>[
|
inputFormatters: <TextInputFormatter>[
|
||||||
FilteringTextInputFormatter.allow(RegExp(r'(^\d*\.?\d*)'))
|
FilteringTextInputFormatter.allow(RegExp(r'(^\d*\.?\d*)'))
|
||||||
],
|
],
|
||||||
|
|
|
@ -32,7 +32,9 @@ class UnlockingWallet extends StatelessWidget {
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
WalletOptionsProvider _walletOptions =
|
WalletOptionsProvider _walletOptions =
|
||||||
Provider.of<WalletOptionsProvider>(context);
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
final int _pinLenght = _walletOptions.getPinLenght(this.wallet.number);
|
|
||||||
|
log.d("defaultWallet: " + defaultWallet.toString());
|
||||||
|
final int _pinLenght = _walletOptions.getPinLenght(wallet.number);
|
||||||
errorController = StreamController<ErrorAnimationType>();
|
errorController = StreamController<ErrorAnimationType>();
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -127,6 +129,7 @@ class UnlockingWallet extends StatelessWidget {
|
||||||
],
|
],
|
||||||
onCompleted: (_pin) async {
|
onCompleted: (_pin) async {
|
||||||
log.d("Completed");
|
log.d("Completed");
|
||||||
|
_myWalletProvider.pinCode = _pin;
|
||||||
final resultWallet = await _walletOptions.readLocalWallet(
|
final resultWallet = await _walletOptions.readLocalWallet(
|
||||||
context, this.wallet, _pin.toUpperCase(), _pinLenght);
|
context, this.wallet, _pin.toUpperCase(), _pinLenght);
|
||||||
// _myWalletProvider.pinCode = _pin.toUpperCase();
|
// _myWalletProvider.pinCode = _pin.toUpperCase();
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:gecko/models/myWallets.dart';
|
|
||||||
import 'package:gecko/models/walletOptions.dart';
|
|
||||||
import 'dart:async';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:gecko/globals.dart';
|
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
|
||||||
class WalletOptionsOld extends StatelessWidget with ChangeNotifier {
|
|
||||||
WalletOptionsOld(
|
|
||||||
{Key keyMyWallets,
|
|
||||||
@required this.walletNbr,
|
|
||||||
@required this.walletName,
|
|
||||||
@required this.derivation})
|
|
||||||
: super(key: keyMyWallets);
|
|
||||||
int walletNbr;
|
|
||||||
String walletName;
|
|
||||||
int derivation;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
log.d("Build walletOptions");
|
|
||||||
WalletOptionsProvider _walletOptions =
|
|
||||||
Provider.of<WalletOptionsProvider>(context);
|
|
||||||
MyWalletsProvider _myWalletProvider =
|
|
||||||
Provider.of<MyWalletsProvider>(context);
|
|
||||||
|
|
||||||
final int _currentChest = _myWalletProvider.getCurrentChest();
|
|
||||||
|
|
||||||
return WillPopScope(
|
|
||||||
onWillPop: () {
|
|
||||||
_walletOptions.isWalletUnlock = false;
|
|
||||||
Navigator.popUntil(
|
|
||||||
context,
|
|
||||||
ModalRoute.withName('/mywallets'),
|
|
||||||
);
|
|
||||||
return Future<bool>.value(true);
|
|
||||||
},
|
|
||||||
child: Scaffold(
|
|
||||||
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,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14.0,
|
|
||||||
color: Colors.black,
|
|
||||||
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
|
|
||||||
.readAllWallets(
|
|
||||||
_currentChest);
|
|
||||||
_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,
|
|
||||||
_myWalletProvider.getWalletData(
|
|
||||||
_walletOptions.walletID));
|
|
||||||
WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) {
|
|
||||||
_myWalletProvider.listWallets =
|
|
||||||
_myWalletProvider
|
|
||||||
.readAllWallets(_currentChest);
|
|
||||||
_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)
|
|
||||||
])),
|
|
||||||
]),
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue