Change wallet list store format; Start to implement figma wallet options screen
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 264 B |
After Width: | Height: | Size: 585 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 482 B |
After Width: | Height: | Size: 284 B |
After Width: | Height: | Size: 719 B |
After Width: | Height: | Size: 492 B |
After Width: | Height: | Size: 2.2 KiB |
|
@ -1,9 +1,12 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
// Files paths
|
||||||
Directory appPath;
|
Directory appPath;
|
||||||
Directory walletsDirectory;
|
Directory walletsDirectory;
|
||||||
File defaultWalletFile;
|
File defaultWalletFile;
|
||||||
|
File currentChestFile;
|
||||||
|
|
||||||
String defaultWallet;
|
String defaultWallet;
|
||||||
String appVersion;
|
String appVersion;
|
||||||
SharedPreferences prefs;
|
SharedPreferences prefs;
|
||||||
|
|
|
@ -28,7 +28,7 @@ Future<void> main() async {
|
||||||
MyWalletsProvider _walletsProvider = MyWalletsProvider();
|
MyWalletsProvider _walletsProvider = MyWalletsProvider();
|
||||||
await _homeProvider.getAppPath();
|
await _homeProvider.getAppPath();
|
||||||
await _homeProvider.createDefaultAvatar();
|
await _homeProvider.createDefaultAvatar();
|
||||||
await _walletsProvider.getDefaultWallet();
|
await _walletsProvider.initWalletFolder();
|
||||||
appVersion = await _homeProvider.getAppVersion();
|
appVersion = await _homeProvider.getAppVersion();
|
||||||
prefs = await SharedPreferences.getInstance();
|
prefs = await SharedPreferences.getInstance();
|
||||||
final HiveStore _store =
|
final HiveStore _store =
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CesiumPlusProvider with ChangeNotifier {
|
||||||
String _name;
|
String _name;
|
||||||
|
|
||||||
List queryOptions = await _buildQuery(_pubkey);
|
List queryOptions = await _buildQuery(_pubkey);
|
||||||
final response = await http.post(queryOptions[0],
|
final response = await http.post((Uri.parse(queryOptions[0])),
|
||||||
body: queryOptions[1], headers: queryOptions[2]);
|
body: queryOptions[1], headers: queryOptions[2]);
|
||||||
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
||||||
final responseJson = json.decode(response.body);
|
final responseJson = json.decode(response.body);
|
||||||
|
@ -87,7 +87,7 @@ class CesiumPlusProvider with ChangeNotifier {
|
||||||
|
|
||||||
Future<List> getAvatar(String _pubkey) async {
|
Future<List> getAvatar(String _pubkey) async {
|
||||||
List queryOptions = await _buildQuery(_pubkey);
|
List queryOptions = await _buildQuery(_pubkey);
|
||||||
final response = await http.post(queryOptions[0],
|
final response = await http.post((Uri.parse(queryOptions[0])),
|
||||||
body: queryOptions[1], headers: queryOptions[2]);
|
body: queryOptions[1], headers: queryOptions[2]);
|
||||||
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
||||||
final responseJson = json.decode(response.body);
|
final responseJson = json.decode(response.body);
|
||||||
|
|
|
@ -39,14 +39,16 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
bool canImport = false;
|
bool canImport = false;
|
||||||
bool isPinChanged = false;
|
bool isPinChanged = false;
|
||||||
|
|
||||||
Future storeHDWallet(
|
Future storeHDWChest(
|
||||||
NewWallet _wallet, String _name, BuildContext context) async {
|
NewWallet _wallet, String _name, BuildContext context) async {
|
||||||
// Directory walletDirectory;
|
// Directory walletDirectory;
|
||||||
|
|
||||||
final Directory hdDirectory = Directory('${walletsDirectory.path}/0');
|
final Directory hdDirectory = Directory('${walletsDirectory.path}/0');
|
||||||
await hdDirectory.create();
|
await hdDirectory.create();
|
||||||
|
|
||||||
final configFile = File('${hdDirectory.path}/config.txt');
|
final configFile = File('${hdDirectory.path}/list.conf');
|
||||||
|
File _currentChestFile = File('${walletsDirectory.path}/currentChest.conf');
|
||||||
|
|
||||||
final dewifFile = File('${hdDirectory.path}/wallet.dewif');
|
final dewifFile = File('${hdDirectory.path}/wallet.dewif');
|
||||||
|
|
||||||
// List<String> _lastConfig = [];
|
// List<String> _lastConfig = [];
|
||||||
|
@ -61,8 +63,14 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
accountsIndex: [_derivationNbr]);
|
accountsIndex: [_derivationNbr]);
|
||||||
String _pubkey = _pubkeysTmp[0];
|
String _pubkey = _pubkeysTmp[0];
|
||||||
|
|
||||||
await configFile.writeAsString('0:$_name:$_derivationNbr:$_pubkey');
|
await configFile.writeAsString('0:0:$_name:$_derivationNbr:$_pubkey');
|
||||||
await dewifFile.writeAsString(_wallet.dewif);
|
await dewifFile.writeAsString(_wallet.dewif);
|
||||||
|
bool isCurrentChestExist = _currentChestFile.existsSync();
|
||||||
|
if (isCurrentChestExist) {
|
||||||
|
await _currentChestFile.delete();
|
||||||
|
}
|
||||||
|
await _currentChestFile.create();
|
||||||
|
await _currentChestFile.writeAsString('0');
|
||||||
|
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
@ -147,11 +155,9 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
generatedMnemonic = await DubpRust.genMnemonic(language: Language.french);
|
generatedMnemonic = await DubpRust.genMnemonic(language: Language.french);
|
||||||
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
||||||
walletIsGenerated = true;
|
walletIsGenerated = true;
|
||||||
// notifyListeners();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
// await checkIfWalletExist();
|
|
||||||
return generatedMnemonic;
|
return generatedMnemonic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,6 @@ class HistoryProvider with ChangeNotifier {
|
||||||
// Lion simone: 78jhpprYkMNF6i5kQPXfkAVBpd2aqcpieNsXTSW4c21f
|
// Lion simone: 78jhpprYkMNF6i5kQPXfkAVBpd2aqcpieNsXTSW4c21f
|
||||||
|
|
||||||
List parseHistory(txs, _pubkey) {
|
List parseHistory(txs, _pubkey) {
|
||||||
// print(txs);
|
|
||||||
var transBC = [];
|
var transBC = [];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ class HistoryProvider with ChangeNotifier {
|
||||||
transBC[i].add(date);
|
transBC[i].add(date);
|
||||||
// print(
|
// print(
|
||||||
// "DEBUG date et comment: ${date.toString()} -- ${transaction['comment'].toString()}");
|
// "DEBUG date et comment: ${date.toString()} -- ${transaction['comment'].toString()}");
|
||||||
int amountBrut = int.parse(output.split(':')[0]);
|
final int amountBrut = int.parse(output.split(':')[0]);
|
||||||
final base = int.parse(output.split(':')[1]);
|
final base = int.parse(output.split(':')[1]);
|
||||||
final int applyBase = base - currentBase;
|
final int applyBase = base - currentBase;
|
||||||
final num amount =
|
final num amount =
|
||||||
|
|
|
@ -8,15 +8,50 @@ import 'package:provider/provider.dart';
|
||||||
class MyWalletsProvider with ChangeNotifier {
|
class MyWalletsProvider with ChangeNotifier {
|
||||||
String listWallets;
|
String listWallets;
|
||||||
|
|
||||||
|
Future initWalletFolder() async {
|
||||||
|
await getDefaultWallet();
|
||||||
|
|
||||||
|
final bool isWalletFolderExist = await walletsDirectory.exists();
|
||||||
|
if (!isWalletFolderExist) {
|
||||||
|
await Directory(walletsDirectory.path).create();
|
||||||
|
}
|
||||||
|
|
||||||
|
File _currentChestFile = File('${walletsDirectory.path}/currentChest.conf');
|
||||||
|
|
||||||
|
await _currentChestFile.create();
|
||||||
|
await _currentChestFile.writeAsString('0');
|
||||||
|
|
||||||
|
final bool isChestsExist =
|
||||||
|
await Directory('${walletsDirectory.path}/0').exists();
|
||||||
|
if (!isChestsExist) {
|
||||||
|
await Directory('${walletsDirectory.path}/0').create();
|
||||||
|
await Directory('${walletsDirectory.path}/1').create();
|
||||||
|
await File('${walletsDirectory.path}/0/list.conf').create();
|
||||||
|
await File('${walletsDirectory.path}/0/order.conf').create();
|
||||||
|
await File('${walletsDirectory.path}/1/list.conf').create();
|
||||||
|
await File('${walletsDirectory.path}/1/order.conf').create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int getCurrentChest() {
|
||||||
|
File _currentChestFile = File('${walletsDirectory.path}/currentChest.conf');
|
||||||
|
|
||||||
|
bool isCurrentChestExist = _currentChestFile.existsSync();
|
||||||
|
if (!isCurrentChestExist) {
|
||||||
|
_currentChestFile.createSync();
|
||||||
|
_currentChestFile.writeAsString('0');
|
||||||
|
}
|
||||||
|
return int.parse(_currentChestFile.readAsStringSync());
|
||||||
|
}
|
||||||
|
|
||||||
bool checkIfWalletExist() {
|
bool checkIfWalletExist() {
|
||||||
if (appPath == null) {
|
if (appPath == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
print(walletsDirectory.listSync());
|
final String _walletList = getAllWalletsNames(0);
|
||||||
|
|
||||||
List contents = walletsDirectory.listSync();
|
if (_walletList == '') {
|
||||||
if (contents.length == 0) {
|
|
||||||
print('No wallets detected');
|
print('No wallets detected');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,12 +60,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAllWalletsNames() {
|
String getAllWalletsNames(int _chest) {
|
||||||
final bool _isWalletsExists = checkIfWalletExist();
|
|
||||||
if (!_isWalletsExists) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listWallets != null && listWallets.isNotEmpty) {
|
if (listWallets != null && listWallets.isNotEmpty) {
|
||||||
listWallets = '';
|
listWallets = '';
|
||||||
}
|
}
|
||||||
|
@ -39,17 +69,13 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// int i = 0;
|
// int i = 0;
|
||||||
walletsDirectory
|
File _walletConfig = File('${walletsDirectory.path}/$_chest/list.conf');
|
||||||
.listSync(recursive: false, followLinks: false)
|
_walletConfig.readAsLinesSync().forEach((element) {
|
||||||
.forEach((_wallet) {
|
if (listWallets != '') {
|
||||||
File _walletConfig = File('${_wallet.path}/config.txt');
|
listWallets += '\n';
|
||||||
_walletConfig.readAsLinesSync().forEach((element) {
|
}
|
||||||
if (listWallets != '') {
|
listWallets += element;
|
||||||
listWallets += '\n';
|
// listWallets += "${element.split(':')[0]}:${element.split(':')[1]}:${element.split(':')[2]}"
|
||||||
}
|
|
||||||
listWallets += element;
|
|
||||||
// listWallets += "${element.split(':')[0]}:${element.split(':')[1]}:${element.split(':')[2]}"
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
print(listWallets);
|
print(listWallets);
|
||||||
|
|
||||||
|
@ -68,9 +94,9 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
try {
|
try {
|
||||||
defaultWallet = await defaultWalletFile.readAsString();
|
defaultWallet = await defaultWalletFile.readAsString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
defaultWallet = '0:3';
|
defaultWallet = '0:0';
|
||||||
}
|
}
|
||||||
if (defaultWallet == '') defaultWallet = '0:3';
|
if (defaultWallet == '') defaultWallet = '0:0';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> deleteAllWallet(context) async {
|
Future<int> deleteAllWallet(context) async {
|
||||||
|
@ -82,6 +108,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
if (_answer) {
|
if (_answer) {
|
||||||
await walletsDirectory.delete(recursive: true);
|
await walletsDirectory.delete(recursive: true);
|
||||||
await walletsDirectory.create();
|
await walletsDirectory.create();
|
||||||
|
await initWalletFolder();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +141,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_myWalletProvider.listWallets =
|
_myWalletProvider.listWallets =
|
||||||
_myWalletProvider.getAllWalletsNames();
|
_myWalletProvider.getAllWalletsNames(getCurrentChest());
|
||||||
_myWalletProvider.rebuildWidget();
|
_myWalletProvider.rebuildWidget();
|
||||||
});
|
});
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
|
@ -128,18 +155,24 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
Future<void> generateNewDerivation(context, String _name) async {
|
Future<void> generateNewDerivation(context, String _name) async {
|
||||||
int _newDerivationNbr;
|
int _newDerivationNbr;
|
||||||
final _walletConfig = File('${walletsDirectory.path}/0/config.txt');
|
int _newWalletNbr;
|
||||||
|
final _walletConfig = File('${walletsDirectory.path}/0/list.conf');
|
||||||
|
|
||||||
if (await _walletConfig.readAsString() == '') {
|
if (await _walletConfig.readAsString() == '') {
|
||||||
_newDerivationNbr = 3;
|
_newDerivationNbr = 3;
|
||||||
|
_newWalletNbr = 0;
|
||||||
} else {
|
} else {
|
||||||
String _lastWallet =
|
String _lastWallet =
|
||||||
await _walletConfig.readAsLines().then((value) => value.last);
|
await _walletConfig.readAsLines().then((value) => value.last);
|
||||||
int _lastDerivation = int.parse(_lastWallet.split(':')[2]);
|
int _lastDerivation = int.parse(_lastWallet.split(':')[3]);
|
||||||
_newDerivationNbr = _lastDerivation + 3;
|
_newDerivationNbr = _lastDerivation + 3;
|
||||||
|
|
||||||
|
int _lastWalletNbr = int.parse(_lastWallet.split(':')[1]);
|
||||||
|
_newWalletNbr = _lastWalletNbr + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _walletConfig.writeAsString('\n0:$_name:$_newDerivationNbr',
|
await _walletConfig.writeAsString(
|
||||||
|
'\n0:$_newWalletNbr:$_name:$_newDerivationNbr',
|
||||||
mode: FileMode.append);
|
mode: FileMode.append);
|
||||||
|
|
||||||
print(await _walletConfig.readAsString());
|
print(await _walletConfig.readAsString());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const String getHistory = r'''
|
const String getHistory = r'''
|
||||||
query ($pubkey: String!, $number: Int!, $cursor: String) {
|
query ($pubkey: String!, $number: Int!, $cursor: String) {
|
||||||
txsHistoryBc(
|
txsHistoryBc(
|
||||||
pubkeyOrScript: $pubkey
|
script: $pubkey
|
||||||
pagination: { pageSize: $number, ord: DESC, cursor: $cursor }
|
pagination: { pageSize: $number, ord: DESC, cursor: $cursor }
|
||||||
) {
|
) {
|
||||||
both {
|
both {
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:dubp/dubp.dart';
|
import 'package:dubp/dubp.dart';
|
||||||
|
import 'package:fast_base58/fast_base58.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:truncate/truncate.dart';
|
||||||
|
|
||||||
class WalletOptionsProvider with ChangeNotifier {
|
class WalletOptionsProvider with ChangeNotifier {
|
||||||
TextEditingController pubkey = TextEditingController();
|
TextEditingController pubkey = TextEditingController();
|
||||||
|
@ -65,8 +68,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
int _walletNbr, String _pin, int _pinLenght, int derivation) async {
|
int _walletNbr, String _pin, int _pinLenght, int derivation) async {
|
||||||
isWalletUnlock = false;
|
isWalletUnlock = false;
|
||||||
try {
|
try {
|
||||||
File _walletFile =
|
File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif');
|
||||||
File('${walletsDirectory.path}/$_walletNbr/wallet.dewif');
|
|
||||||
String _localDewif = await _walletFile.readAsString();
|
String _localDewif = await _walletFile.readAsString();
|
||||||
String _localPubkey;
|
String _localPubkey;
|
||||||
|
|
||||||
|
@ -107,8 +109,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
int getPinLenght(_walletNbr) {
|
int getPinLenght(_walletNbr) {
|
||||||
String _localDewif;
|
String _localDewif;
|
||||||
if (_walletNbr is int) {
|
if (_walletNbr is int) {
|
||||||
File _walletFile =
|
File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif');
|
||||||
File('${walletsDirectory.path}/$_walletNbr/wallet.dewif');
|
|
||||||
_localDewif = _walletFile.readAsStringSync();
|
_localDewif = _walletFile.readAsStringSync();
|
||||||
} else {
|
} else {
|
||||||
_localDewif = _walletNbr;
|
_localDewif = _walletNbr;
|
||||||
|
@ -121,21 +122,21 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _renameWallet(_walletName, _newName, _walletNbr, _derivation) async {
|
Future _renameWallet(_walletName, _newName, _walletNbr, _derivation) async {
|
||||||
final _walletConfig =
|
final _walletConfig = File('${walletsDirectory.path}/0/list.conf');
|
||||||
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
|
||||||
|
|
||||||
String newConfig =
|
String newConfig =
|
||||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||||
int nbrLines = lines.length;
|
int nbrLines = lines.length;
|
||||||
int _index = lines.indexOf('$_walletNbr:$_walletName:$_derivation');
|
print(lines);
|
||||||
print(nbrLines);
|
print(nbrLines);
|
||||||
|
int _index = lines.indexOf('0:$_walletNbr:$_walletName:$_derivation');
|
||||||
if (nbrLines != 1) {
|
if (nbrLines != 1) {
|
||||||
lines.removeWhere((element) =>
|
lines.removeWhere((element) =>
|
||||||
element.contains('$_walletNbr:$_walletName:$_derivation'));
|
element.contains('0:$_walletNbr:$_walletName:$_derivation'));
|
||||||
lines.insert(_index, '$_walletNbr:$_newName:$_derivation');
|
lines.insert(_index, '0:$_walletNbr:$_newName:$_derivation');
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
} else {
|
} else {
|
||||||
return '$_walletNbr:$_newName:$_derivation';
|
return '0:$_walletNbr:$_newName:$_derivation';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -189,14 +190,13 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
final bool _answer = await _confirmDeletingWallet(context, _name);
|
final bool _answer = await _confirmDeletingWallet(context, _name);
|
||||||
|
|
||||||
if (_answer) {
|
if (_answer) {
|
||||||
final _walletConfig =
|
final _walletConfig = File('${walletsDirectory.path}/0/list.conf');
|
||||||
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
|
||||||
|
|
||||||
if (_derivation != -1) {
|
if (_derivation != -1) {
|
||||||
String newConfig =
|
String newConfig =
|
||||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||||
lines.removeWhere(
|
lines.removeWhere((element) =>
|
||||||
(element) => element.contains('$_walletNbr:$_name:$_derivation'));
|
element.contains('0:$_walletNbr:$_name:$_derivation'));
|
||||||
|
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
});
|
});
|
||||||
|
@ -289,6 +289,22 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getShortPubkey(String pubkey) {
|
||||||
|
List<int> pubkeyByte = Base58Decode(pubkey);
|
||||||
|
Digest pubkeyS256 = sha256.convert(sha256.convert(pubkeyByte).bytes);
|
||||||
|
String pubkeyCheksum = Base58Encode(pubkeyS256.bytes);
|
||||||
|
String pubkeyChecksumShort = truncate(pubkeyCheksum, 3,
|
||||||
|
omission: "", position: TruncatePosition.end);
|
||||||
|
|
||||||
|
String pubkeyShort = truncate(pubkey, 5,
|
||||||
|
omission: String.fromCharCode(0x2026),
|
||||||
|
position: TruncatePosition.end) +
|
||||||
|
truncate(pubkey, 4, omission: "", position: TruncatePosition.start) +
|
||||||
|
':$pubkeyChecksumShort';
|
||||||
|
|
||||||
|
return pubkeyShort;
|
||||||
|
}
|
||||||
|
|
||||||
void reloadBuild() {
|
void reloadBuild() {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
initialData: '...',
|
initialData: '...',
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
return Text(
|
return Text(
|
||||||
snapshot.data != ''
|
snapshot.data != null
|
||||||
? snapshot.data
|
? snapshot.data
|
||||||
: '-',
|
: '-',
|
||||||
style:
|
style:
|
||||||
|
|
|
@ -28,6 +28,8 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
Provider.of<GenerateWalletsProvider>(context);
|
Provider.of<GenerateWalletsProvider>(context);
|
||||||
MyWalletsProvider _myWalletProvider =
|
MyWalletsProvider _myWalletProvider =
|
||||||
Provider.of<MyWalletsProvider>(context);
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
final int _currentChest = _myWalletProvider.getCurrentChest();
|
||||||
|
|
||||||
|
|
||||||
this._mnemonicController.text = generatedMnemonic;
|
this._mnemonicController.text = generatedMnemonic;
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
|
@ -126,7 +128,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
.isAskedWordValid &&
|
.isAskedWordValid &&
|
||||||
this.walletName.text != '')
|
this.walletName.text != '')
|
||||||
? () async {
|
? () async {
|
||||||
await _generateWalletProvider.storeHDWallet(
|
await _generateWalletProvider.storeHDWChest(
|
||||||
generatedWallet,
|
generatedWallet,
|
||||||
walletName.text,
|
walletName.text,
|
||||||
context);
|
context);
|
||||||
|
@ -138,7 +140,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
.addPostFrameCallback((_) {
|
.addPostFrameCallback((_) {
|
||||||
_myWalletProvider.listWallets =
|
_myWalletProvider.listWallets =
|
||||||
_myWalletProvider
|
_myWalletProvider
|
||||||
.getAllWalletsNames();
|
.getAllWalletsNames(_currentChest);
|
||||||
_myWalletProvider.rebuildWidget();
|
_myWalletProvider.rebuildWidget();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,164 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
// 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]);
|
||||||
|
print("Build walletOptions");
|
||||||
|
WalletOptionsProvider _walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
|
MyWalletsProvider _myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
|
||||||
|
// _walletOptions.isWalletUnlock = false;
|
||||||
|
print("Is unlock ? ${_walletOptions.isWalletUnlock}");
|
||||||
|
|
||||||
|
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
|
||||||
|
.getAllWalletsNames(_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,
|
||||||
|
walletNbr, walletName, derivation);
|
||||||
|
WidgetsBinding.instance
|
||||||
|
.addPostFrameCallback((_) {
|
||||||
|
_myWalletProvider.listWallets =
|
||||||
|
_myWalletProvider.getAllWalletsNames(_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)
|
||||||
|
])),
|
||||||
|
]),
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,12 +27,12 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
||||||
MyWalletsProvider _myWalletProvider =
|
MyWalletsProvider _myWalletProvider =
|
||||||
Provider.of<MyWalletsProvider>(context);
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
|
||||||
// _walletOptions.isWalletUnlock = false;
|
final int _currentChest = _myWalletProvider.getCurrentChest();
|
||||||
print("Is unlock ? ${_walletOptions.isWalletUnlock}");
|
final String shortPubkey =
|
||||||
|
_walletOptions.getShortPubkey(_walletOptions.pubkey.text);
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
_walletOptions.isWalletUnlock = false;
|
|
||||||
Navigator.popUntil(
|
Navigator.popUntil(
|
||||||
context,
|
context,
|
||||||
ModalRoute.withName('/mywallets'),
|
ModalRoute.withName('/mywallets'),
|
||||||
|
@ -45,7 +45,6 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(Icons.arrow_back, color: Colors.black),
|
icon: Icon(Icons.arrow_back, color: Colors.black),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_walletOptions.isWalletUnlock = false;
|
|
||||||
Navigator.popUntil(
|
Navigator.popUntil(
|
||||||
context,
|
context,
|
||||||
ModalRoute.withName('/mywallets'),
|
ModalRoute.withName('/mywallets'),
|
||||||
|
@ -57,105 +56,124 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
||||||
)),
|
)),
|
||||||
body: Builder(
|
body: Builder(
|
||||||
builder: (ctx) => SafeArea(
|
builder: (ctx) => SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Expanded(
|
||||||
Expanded(
|
child: Column(children: <Widget>[
|
||||||
child: Column(children: <Widget>[
|
SizedBox(height: 25),
|
||||||
SizedBox(height: 15),
|
Row(children: <Widget>[
|
||||||
Text(
|
SizedBox(width: 25),
|
||||||
'Clé publique:',
|
Image.asset(
|
||||||
style: TextStyle(
|
'assets/chopp-gecko2.png',
|
||||||
fontSize: 15.0,
|
),
|
||||||
color: Colors.grey[600],
|
Image.asset(
|
||||||
fontWeight: FontWeight.w400),
|
'assets/walletOptions/camera.png',
|
||||||
),
|
),
|
||||||
SizedBox(height: 15),
|
// SizedBox(width: 20),
|
||||||
GestureDetector(
|
Column(children: <Widget>[
|
||||||
onTap: () {
|
Row(children: <Widget>[
|
||||||
Clipboard.setData(ClipboardData(
|
Column(children: <Widget>[
|
||||||
text: _walletOptions.pubkey.text));
|
SizedBox(
|
||||||
_walletOptions.snackCopyKey(ctx);
|
width: 250,
|
||||||
},
|
child: Text(
|
||||||
child: Text(
|
walletName,
|
||||||
_walletOptions.pubkey.text,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 27),
|
||||||
fontSize: 14.0,
|
)),
|
||||||
color: Colors.black,
|
SizedBox(height: 5),
|
||||||
fontWeight: FontWeight.bold,
|
Text(
|
||||||
fontFamily: 'Monospace'),
|
'500 DU',
|
||||||
)),
|
style: TextStyle(
|
||||||
Expanded(
|
fontSize: 20, color: Colors.black),
|
||||||
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 {
|
SizedBox(height: 5),
|
||||||
await _walletOptions.deleteWallet(context,
|
Image.asset(
|
||||||
walletNbr, walletName, derivation);
|
'assets/walletOptions/icon_oeuil.png',
|
||||||
WidgetsBinding.instance
|
),
|
||||||
.addPostFrameCallback((_) {
|
]),
|
||||||
_myWalletProvider.listWallets =
|
SizedBox(width: 0),
|
||||||
_myWalletProvider.getAllWalletsNames();
|
Column(children: <Widget>[
|
||||||
_myWalletProvider.rebuildWidget();
|
Image.asset(
|
||||||
});
|
'assets/walletOptions/edit.png',
|
||||||
},
|
),
|
||||||
child: Text('Supprimer ce portefeuille',
|
SizedBox(
|
||||||
style: TextStyle(fontSize: 20)))),
|
height: 60,
|
||||||
SizedBox(height: 50),
|
)
|
||||||
Text(
|
])
|
||||||
'Portefeuille déverrouillé',
|
]),
|
||||||
style: TextStyle(
|
]),
|
||||||
color: Colors.green,
|
]),
|
||||||
fontWeight: FontWeight.w700,
|
Image.asset(
|
||||||
fontSize: 15),
|
'assets/walletOptions/QR_icon.png',
|
||||||
),
|
),
|
||||||
SizedBox(height: 10)
|
SizedBox(height: 15),
|
||||||
])),
|
Row(children: <Widget>[
|
||||||
]),
|
SizedBox(width: 30),
|
||||||
|
Image.asset(
|
||||||
|
'assets/walletOptions/key.png',
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text("${shortPubkey.split(':')[0]}:",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
fontFamily: 'Monospace',
|
||||||
|
color: Colors.black)),
|
||||||
|
Text(shortPubkey.split(':')[1],
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
fontFamily: 'Monospace')),
|
||||||
|
SizedBox(width: 15),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: new BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
elevation: 1,
|
||||||
|
primary: Color(0xffD28928), // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
print('COPY PUBKEY');
|
||||||
|
},
|
||||||
|
child: Text('Copier',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15, color: Colors.grey[50]))),
|
||||||
|
]),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Row(children: <Widget>[
|
||||||
|
SizedBox(width: 30),
|
||||||
|
Image.asset(
|
||||||
|
'assets/walletOptions/clock.png',
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text('Historique des transactions',
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 20, color: Colors.black)),
|
||||||
|
]),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
Row(children: <Widget>[
|
||||||
|
SizedBox(width: 35),
|
||||||
|
Image.asset(
|
||||||
|
'assets/walletOptions/android-checkmark.png',
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text('Portefeuille par defaut',
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 20, color: Colors.black)),
|
||||||
|
]),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
Row(children: <Widget>[
|
||||||
|
SizedBox(width: 30),
|
||||||
|
Image.asset(
|
||||||
|
'assets/walletOptions/trash.png',
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text('Supprimer ce portefeuille',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20, color: Color(0xffD80000))),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,16 @@ class WalletsHome extends StatelessWidget {
|
||||||
WalletOptionsProvider _walletOptions =
|
WalletOptionsProvider _walletOptions =
|
||||||
Provider.of<WalletOptionsProvider>(context);
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
_walletOptions.isWalletUnlock = false;
|
_walletOptions.isWalletUnlock = false;
|
||||||
myWalletProvider.listWallets = myWalletProvider.getAllWalletsNames();
|
|
||||||
|
final int _currentChest = myWalletProvider.getCurrentChest();
|
||||||
|
|
||||||
|
myWalletProvider.listWallets =
|
||||||
|
myWalletProvider.getAllWalletsNames(_currentChest);
|
||||||
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
||||||
|
|
||||||
if (myWalletProvider.listWallets != '') {
|
if (myWalletProvider.listWallets != '') {
|
||||||
firstWalletDerivation =
|
firstWalletDerivation =
|
||||||
int.parse(myWalletProvider.listWallets.split('\n')[0].split(':')[2]);
|
int.parse(myWalletProvider.listWallets.split('\n')[0].split(':')[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -95,114 +99,79 @@ class WalletsHome extends StatelessWidget {
|
||||||
for (String _repository in _listWallets)
|
for (String _repository in _listWallets)
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.all(16),
|
||||||
child: ClipRRect(
|
child: GestureDetector(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
onTap: () {
|
||||||
child: Column(children: <Widget>[
|
Navigator.push(context,
|
||||||
Expanded(
|
MaterialPageRoute(builder: (context) {
|
||||||
child: Container(
|
return UnlockingWallet(
|
||||||
width: double.infinity,
|
walletNbr: int.parse(_repository.split(':')[1]),
|
||||||
height: double.infinity,
|
walletName: _repository.split(':')[2],
|
||||||
decoration: BoxDecoration(
|
derivation: int.parse(_repository.split(':')[3]));
|
||||||
gradient: RadialGradient(
|
}));
|
||||||
radius: 1,
|
},
|
||||||
colors: [
|
child: ClipRRect(
|
||||||
Colors.green[100],
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||||
Colors.green[500],
|
child: Column(children: <Widget>[
|
||||||
],
|
Expanded(
|
||||||
)),
|
child: Container(
|
||||||
child:
|
width: double.infinity,
|
||||||
// SvgPicture.asset('assets/chopp-gecko2.png',
|
height: double.infinity,
|
||||||
// semanticsLabel: 'Gecko', height: 48),
|
decoration: BoxDecoration(
|
||||||
Image.asset(
|
gradient: RadialGradient(
|
||||||
'assets/chopp-gecko2.png',
|
radius: 1,
|
||||||
),
|
colors: [
|
||||||
)),
|
Colors.green[100],
|
||||||
ListTile(
|
Colors.green[500],
|
||||||
// contentPadding: const EdgeInsets.only(left: 7.0),
|
],
|
||||||
tileColor:
|
)),
|
||||||
"${_repository.split(':')[0]}:${_repository.split(':')[2]}" ==
|
child:
|
||||||
defaultWallet
|
// SvgPicture.asset('assets/chopp-gecko2.png',
|
||||||
? Color(0xffD28928)
|
// semanticsLabel: 'Gecko', height: 48),
|
||||||
: Color(0xffFFD58D),
|
Image.asset(
|
||||||
// leading: Text('IMAGE'),
|
'assets/chopp-gecko2.png',
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
ListTile(
|
||||||
|
// contentPadding: const EdgeInsets.only(left: 7.0),
|
||||||
|
tileColor:
|
||||||
|
"${_repository.split(':')[0]}:${_repository.split(':')[1]}" ==
|
||||||
|
defaultWallet
|
||||||
|
? Color(0xffD28928)
|
||||||
|
: Color(0xffFFD58D),
|
||||||
|
// leading: Text('IMAGE'),
|
||||||
|
|
||||||
// subtitle: Text(_repository.split(':')[3],
|
// subtitle: Text(_repository.split(':')[3],
|
||||||
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
|
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
|
||||||
title: Center(
|
title: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
padding:
|
||||||
child: Text(_repository.split(':')[1],
|
EdgeInsets.symmetric(horizontal: 5),
|
||||||
textAlign: TextAlign.center,
|
child: Text(_repository.split(':')[2],
|
||||||
style: TextStyle(
|
textAlign: TextAlign.center,
|
||||||
fontSize: 16.0,
|
style: TextStyle(
|
||||||
color:
|
fontSize: 16.0,
|
||||||
"${_repository.split(':')[0]}:${_repository.split(':')[2]}" ==
|
color:
|
||||||
defaultWallet
|
"${_repository.split(':')[0]}:${_repository.split(':')[1]}" ==
|
||||||
? Color(0xffF9F9F1)
|
defaultWallet
|
||||||
: Colors.black)))),
|
? Color(0xffF9F9F1)
|
||||||
// dense: true,
|
: Colors.black)))),
|
||||||
onTap: () {
|
// dense: true,
|
||||||
Navigator.push(context,
|
onTap: () {
|
||||||
MaterialPageRoute(builder: (context) {
|
Navigator.push(context,
|
||||||
return UnlockingWallet(
|
MaterialPageRoute(builder: (context) {
|
||||||
walletNbr: int.parse(_repository.split(':')[0]),
|
return UnlockingWallet(
|
||||||
walletName: _repository.split(':')[1],
|
walletNbr:
|
||||||
derivation:
|
int.parse(_repository.split(':')[1]),
|
||||||
int.parse(_repository.split(':')[2]));
|
walletName: _repository.split(':')[2],
|
||||||
}));
|
derivation:
|
||||||
},
|
int.parse(_repository.split(':')[3]));
|
||||||
)
|
}));
|
||||||
])))
|
},
|
||||||
|
)
|
||||||
|
]))))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget myWalletsList(BuildContext context) {
|
|
||||||
MyWalletsProvider _myWalletProvider =
|
|
||||||
Provider.of<MyWalletsProvider>(context);
|
|
||||||
|
|
||||||
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
|
||||||
|
|
||||||
if (!isWalletsExists) {
|
|
||||||
return Text('');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_myWalletProvider.listWallets == '') {
|
|
||||||
return Expanded(
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
'Veuillez générer votre premier portefeuille',
|
|
||||||
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
List _listWallets = _myWalletProvider.listWallets.split('\n');
|
|
||||||
|
|
||||||
return Expanded(
|
|
||||||
child: ListView(children: <Widget>[
|
|
||||||
SizedBox(height: 8),
|
|
||||||
for (String _repository in _listWallets)
|
|
||||||
ListTile(
|
|
||||||
contentPadding: const EdgeInsets.only(left: 7.0),
|
|
||||||
leading: Padding(
|
|
||||||
padding: const EdgeInsets.all(6.0),
|
|
||||||
child: Text("0 Ğ1", style: TextStyle(fontSize: 14.0))),
|
|
||||||
// subtitle: Text(_repository.split(':')[3],
|
|
||||||
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
|
|
||||||
title:
|
|
||||||
Text(_repository.split(':')[1], style: TextStyle(fontSize: 16.0)),
|
|
||||||
dense: true,
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
|
||||||
return UnlockingWallet(
|
|
||||||
walletNbr: int.parse(_repository.split(':')[0]),
|
|
||||||
walletName: _repository.split(':')[1],
|
|
||||||
derivation: int.parse(_repository.split(':')[2]));
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget addNewDerivation(context, int _walletNbr) {
|
Widget addNewDerivation(context, int _walletNbr) {
|
||||||
final TextEditingController _newDerivationName = TextEditingController();
|
final TextEditingController _newDerivationName = TextEditingController();
|
||||||
MyWalletsProvider _myWalletProvider =
|
MyWalletsProvider _myWalletProvider =
|
||||||
|
|
|
@ -1,157 +0,0 @@
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:gecko/models/myWallets.dart';
|
|
||||||
import 'package:gecko/models/walletOptions.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:gecko/screens/myWallets/unlockingWallet.dart';
|
|
||||||
import 'package:gecko/screens/onBoarding/0_noKeychainFound.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
|
||||||
class WalletsHome extends StatelessWidget {
|
|
||||||
final _derivationKey = GlobalKey<FormState>();
|
|
||||||
int firstWalletDerivation;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
||||||
MyWalletsProvider myWalletProvider =
|
|
||||||
Provider.of<MyWalletsProvider>(context);
|
|
||||||
WalletOptionsProvider _walletOptions =
|
|
||||||
Provider.of<WalletOptionsProvider>(context);
|
|
||||||
_walletOptions.isWalletUnlock = false;
|
|
||||||
myWalletProvider.listWallets = myWalletProvider.getAllWalletsNames();
|
|
||||||
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
|
||||||
|
|
||||||
if (myWalletProvider.listWallets != '') {
|
|
||||||
firstWalletDerivation =
|
|
||||||
int.parse(myWalletProvider.listWallets.split('\n')[0].split(':')[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text('Mes portefeuilles',
|
|
||||||
style: TextStyle(color: Colors.grey[850])),
|
|
||||||
backgroundColor: Color(0xffFFD58D),
|
|
||||||
),
|
|
||||||
floatingActionButton: Visibility(
|
|
||||||
visible: (isWalletsExists && firstWalletDerivation != -1),
|
|
||||||
child: Container(
|
|
||||||
height: 80.0,
|
|
||||||
width: 80.0,
|
|
||||||
child: FittedBox(
|
|
||||||
child: FloatingActionButton(
|
|
||||||
heroTag: "buttonGenerateWallet",
|
|
||||||
onPressed: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return addNewDerivation(context, 1);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
height: 40,
|
|
||||||
width: 40,
|
|
||||||
child: Icon(Icons.person_add_alt_1_rounded,
|
|
||||||
color: Colors.grey[850])),
|
|
||||||
backgroundColor: Color(0xffEFEFBF))))),
|
|
||||||
body: SafeArea(
|
|
||||||
child: !isWalletsExists
|
|
||||||
? NoKeyChainScreen()
|
|
||||||
: myWalletsList(context)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget myWalletsList(BuildContext context) {
|
|
||||||
MyWalletsProvider _myWalletProvider =
|
|
||||||
Provider.of<MyWalletsProvider>(context);
|
|
||||||
|
|
||||||
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
|
||||||
|
|
||||||
if (!isWalletsExists) {
|
|
||||||
return Text('');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_myWalletProvider.listWallets == '') {
|
|
||||||
return Expanded(
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
'Veuillez générer votre premier portefeuille',
|
|
||||||
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
List _listWallets = _myWalletProvider.listWallets.split('\n');
|
|
||||||
|
|
||||||
return Expanded(
|
|
||||||
child: ListView(children: <Widget>[
|
|
||||||
SizedBox(height: 8),
|
|
||||||
for (String _repository in _listWallets)
|
|
||||||
ListTile(
|
|
||||||
contentPadding: const EdgeInsets.only(left: 7.0),
|
|
||||||
leading: Padding(
|
|
||||||
padding: const EdgeInsets.all(6.0),
|
|
||||||
child: Text("0 Ğ1", style: TextStyle(fontSize: 14.0))),
|
|
||||||
// subtitle: Text(_repository.split(':')[3],
|
|
||||||
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
|
|
||||||
title:
|
|
||||||
Text(_repository.split(':')[1], style: TextStyle(fontSize: 16.0)),
|
|
||||||
dense: true,
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
|
||||||
return UnlockingWallet(
|
|
||||||
walletNbr: int.parse(_repository.split(':')[0]),
|
|
||||||
walletName: _repository.split(':')[1],
|
|
||||||
derivation: int.parse(_repository.split(':')[2]));
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget addNewDerivation(context, int _walletNbr) {
|
|
||||||
final TextEditingController _newDerivationName = TextEditingController();
|
|
||||||
MyWalletsProvider _myWalletProvider =
|
|
||||||
Provider.of<MyWalletsProvider>(context);
|
|
||||||
|
|
||||||
return AlertDialog(
|
|
||||||
content: Stack(
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
children: <Widget>[
|
|
||||||
Form(
|
|
||||||
key: _derivationKey,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
Text('Nom du portefeuille:'),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _newDerivationName,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
autofocus: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: 20),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
elevation: 1,
|
|
||||||
primary: Color(0xffFFD68E), // background
|
|
||||||
onPrimary: Colors.black, // foreground
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
await _myWalletProvider
|
|
||||||
.generateNewDerivation(
|
|
||||||
context, _newDerivationName.text)
|
|
||||||
.then((_) => _newDerivationName.text == '');
|
|
||||||
},
|
|
||||||
child: Text("Créer")),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -61,6 +61,8 @@ class OnboardingStepFourteen extends StatelessWidget {
|
||||||
GenerateWalletsProvider _generateWalletProvider =
|
GenerateWalletsProvider _generateWalletProvider =
|
||||||
Provider.of<GenerateWalletsProvider>(context);
|
Provider.of<GenerateWalletsProvider>(context);
|
||||||
|
|
||||||
|
final int _currentChest = _myWalletProvider.getCurrentChest();
|
||||||
|
|
||||||
return Form(
|
return Form(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
@ -116,9 +118,9 @@ class OnboardingStepFourteen extends StatelessWidget {
|
||||||
if (resultWallet) {
|
if (resultWallet) {
|
||||||
pinColor = Colors.green[500];
|
pinColor = Colors.green[500];
|
||||||
print(generatedWallet.pin);
|
print(generatedWallet.pin);
|
||||||
await _generateWalletProvider.storeHDWallet(
|
await _generateWalletProvider.storeHDWChest(
|
||||||
generatedWallet, 'Mon portefeuille courant', context);
|
generatedWallet, 'Mon portefeuille courant', context);
|
||||||
_myWalletProvider.getAllWalletsNames();
|
_myWalletProvider.getAllWalletsNames(_currentChest);
|
||||||
_walletOptions.reloadBuild();
|
_walletOptions.reloadBuild();
|
||||||
_myWalletProvider.rebuildWidget();
|
_myWalletProvider.rebuildWidget();
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
|
|
|
@ -67,3 +67,4 @@ flutter:
|
||||||
- assets/icon/
|
- assets/icon/
|
||||||
- assets/onBoarding/
|
- assets/onBoarding/
|
||||||
- assets/onBoarding/progress_bar/
|
- assets/onBoarding/progress_bar/
|
||||||
|
- assets/walletOptions/
|
||||||
|
|