Fix bugs on startup and deleting wallets
This commit is contained in:
parent
94cbb3dfec
commit
263e7d4e88
|
@ -44,7 +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();
|
// _walletsProvider.getDefaultWallet();
|
||||||
appVersion = await _homeProvider.getAppVersion();
|
appVersion = await _homeProvider.getAppVersion();
|
||||||
prefs = await SharedPreferences.getInstance();
|
prefs = await SharedPreferences.getInstance();
|
||||||
// final HiveStore _store =
|
// final HiveStore _store =
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:audioplayers/audio_cache.dart';
|
||||||
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -21,6 +23,7 @@ class HomeProvider with ChangeNotifier {
|
||||||
Text('Explorateur', style: TextStyle(color: Colors.grey[850]));
|
Text('Explorateur', style: TextStyle(color: Colors.grey[850]));
|
||||||
|
|
||||||
List currentTab = [HistoryScreen(), WalletsHome()];
|
List currentTab = [HistoryScreen(), WalletsHome()];
|
||||||
|
AudioCache player = AudioCache(prefix: 'sounds/');
|
||||||
|
|
||||||
get currentIndex => _currentIndex;
|
get currentIndex => _currentIndex;
|
||||||
|
|
||||||
|
@ -54,11 +57,15 @@ class HomeProvider with ChangeNotifier {
|
||||||
do {
|
do {
|
||||||
i++;
|
i++;
|
||||||
log.d(i.toString() + ' ème essai de recherche de endpoint GVA.');
|
log.d(i.toString() + ' ème essai de recherche de endpoint GVA.');
|
||||||
log.d('Try GVA endpoint: ${_listEndpoints[i]}');
|
log.d('Try GVA endpoint: ${_listEndpoints[i - 1]}');
|
||||||
if (i > 2) {
|
int listLenght = _listEndpoints.length - 1;
|
||||||
|
if (i > listLenght) {
|
||||||
log.e('NO VALID GVA ENDPOINT FOUND');
|
log.e('NO VALID GVA ENDPOINT FOUND');
|
||||||
|
playSound('faché');
|
||||||
_endpoint = 'HS';
|
_endpoint = 'HS';
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
playSound('start');
|
||||||
}
|
}
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
await Future.delayed(const Duration(milliseconds: 300));
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
@ -121,6 +128,11 @@ class HomeProvider with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playSound(String customSound) async {
|
||||||
|
await player.play('$customSound.wav',
|
||||||
|
volume: 1, mode: PlayerMode.LOW_LATENCY, stayAwake: false);
|
||||||
|
}
|
||||||
|
|
||||||
void handleSearchEnd() {
|
void handleSearchEnd() {
|
||||||
searchIcon = Icon(
|
searchIcon = Icon(
|
||||||
Icons.search,
|
Icons.search,
|
||||||
|
|
|
@ -32,8 +32,9 @@ 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();
|
// getDefaultWallet();
|
||||||
}
|
}
|
||||||
|
await getDefaultWalletAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCurrentChest() {
|
int getCurrentChest() {
|
||||||
|
@ -77,6 +78,8 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletData getWalletData(String _id) {
|
WalletData getWalletData(String _id) {
|
||||||
|
// log.d(_id);
|
||||||
|
if (_id == '') return WalletData('');
|
||||||
int chest = int.parse(_id.split(':')[0]);
|
int chest = int.parse(_id.split(':')[0]);
|
||||||
final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf');
|
final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf');
|
||||||
|
|
||||||
|
@ -85,6 +88,19 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
.firstWhere((element) => element.startsWith(_id)));
|
.firstWhere((element) => element.startsWith(_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<WalletData> getWalletDataAsync(String _id) async {
|
||||||
|
// log.d(_id);
|
||||||
|
if (_id == '') return WalletData('');
|
||||||
|
int chest = int.parse(_id.split(':')[0]);
|
||||||
|
final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf');
|
||||||
|
|
||||||
|
List configLines = await _walletConfig.readAsLines();
|
||||||
|
log.d(configLines);
|
||||||
|
|
||||||
|
return WalletData(
|
||||||
|
configLines.firstWhere((element) => element.startsWith(_id)));
|
||||||
|
}
|
||||||
|
|
||||||
void getDefaultWallet() {
|
void getDefaultWallet() {
|
||||||
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
||||||
|
|
||||||
|
@ -96,6 +112,18 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
defaultWallet = getWalletData(defaultWalletFile.readAsStringSync());
|
defaultWallet = getWalletData(defaultWalletFile.readAsStringSync());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future getDefaultWalletAsync() async {
|
||||||
|
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
||||||
|
|
||||||
|
if (!await defaultWalletFile.exists()) {
|
||||||
|
await File(defaultWalletFile.path).create();
|
||||||
|
await defaultWalletFile.writeAsString("0:0");
|
||||||
|
} else {
|
||||||
|
defaultWallet =
|
||||||
|
await getWalletDataAsync(await defaultWalletFile.readAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> deleteAllWallet(context) async {
|
Future<int> deleteAllWallet(context) async {
|
||||||
try {
|
try {
|
||||||
log.w('DELETE THAT ?: $walletsDirectory');
|
log.w('DELETE THAT ?: $walletsDirectory');
|
||||||
|
@ -106,9 +134,11 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
await walletsDirectory.delete(recursive: true);
|
await walletsDirectory.delete(recursive: true);
|
||||||
await defaultWalletFile.delete();
|
await defaultWalletFile.delete();
|
||||||
await walletsDirectory.create();
|
await walletsDirectory.create();
|
||||||
await defaultWalletFile.create();
|
// await defaultWalletFile.create();
|
||||||
await initWalletFolder();
|
await initWalletFolder();
|
||||||
|
await Future.delayed(Duration(milliseconds: 100));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
rebuildWidget();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -193,6 +223,7 @@ class WalletData {
|
||||||
|
|
||||||
// constructor from ':'-separated string
|
// constructor from ':'-separated string
|
||||||
WalletData(String element) {
|
WalletData(String element) {
|
||||||
|
if (element != '') {
|
||||||
List parts = element.split(':');
|
List parts = element.split(':');
|
||||||
|
|
||||||
this.chest = int.parse(parts[0]);
|
this.chest = int.parse(parts[0]);
|
||||||
|
@ -200,6 +231,7 @@ class WalletData {
|
||||||
this.name = parts[2];
|
this.name = parts[2];
|
||||||
this.derivation = int.parse(parts[3]);
|
this.derivation = int.parse(parts[3]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// representation of WalletData when debugging
|
// representation of WalletData when debugging
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -28,7 +28,6 @@ class HomeScreen extends StatelessWidget {
|
||||||
isTall = true;
|
isTall = true;
|
||||||
ratio = 1.125;
|
ratio = 1.125;
|
||||||
}
|
}
|
||||||
// CommonElements commonElements = CommonElements();
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
drawer: Drawer(
|
drawer: Drawer(
|
||||||
|
|
|
@ -119,6 +119,7 @@ class OnboardingStepFourteen extends StatelessWidget {
|
||||||
_myWalletProvider.readAllWallets(_currentChest);
|
_myWalletProvider.readAllWallets(_currentChest);
|
||||||
_walletOptions.reloadBuild();
|
_walletOptions.reloadBuild();
|
||||||
_myWalletProvider.rebuildWidget();
|
_myWalletProvider.rebuildWidget();
|
||||||
|
await _myWalletProvider.getDefaultWalletAsync();
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
FaderTransition(
|
FaderTransition(
|
||||||
|
|
|
@ -22,6 +22,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.5.0"
|
||||||
|
audioplayers:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: audioplayers
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.18.3"
|
||||||
barcode:
|
barcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.1+24
|
version: 0.0.2+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
@ -46,6 +46,7 @@ dependencies:
|
||||||
responsive_framework: ^0.0.14
|
responsive_framework: ^0.0.14
|
||||||
responsive_builder: ^0.3.0
|
responsive_builder: ^0.3.0
|
||||||
jdenticon_dart: ^2.0.0
|
jdenticon_dart: ^2.0.0
|
||||||
|
audioplayers: ^0.18.3
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: "ic_launcher"
|
android: "ic_launcher"
|
||||||
|
@ -69,3 +70,4 @@ flutter:
|
||||||
- assets/onBoarding/
|
- assets/onBoarding/
|
||||||
- assets/onBoarding/progress_bar/
|
- assets/onBoarding/progress_bar/
|
||||||
- assets/walletOptions/
|
- assets/walletOptions/
|
||||||
|
- sounds/
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue