Merge redesign part 7.

This commit is contained in:
M
2020-09-15 23:35:49 +03:00
parent d67ab4934d
commit 95917b2cdb
31 changed files with 373 additions and 267 deletions
+20 -20
View File
@@ -82,28 +82,28 @@ Future<void> migrate_wallets({Directory appDocDir}) async {
Future<void> migrate_ios_wallet_info(
{@required Directory appDocDir,
@required Box<WalletInfo> walletsInfo}) async {
final walletsDir = Directory('${appDocDir.path}/wallets');
final moneroWalletsDir = Directory('${walletsDir.path}/monero');
// final walletsDir = Directory('${appDocDir.path}/wallets');
// final moneroWalletsDir = Directory('${walletsDir.path}/monero');
moneroWalletsDir.listSync().forEach((item) async {
try {
if (item is Directory) {
final name = item.path.split('/').last;
final configFile = File('${item.path}/$name.json');
final config =
json.decode(configFile.readAsStringSync()) as Map<String, dynamic>;
final isRecovery = config["isRecovery"] as bool ?? false;
final id =
walletTypeToString(WalletType.monero).toLowerCase() + '_' + name;
final walletInfo =
WalletInfo(id: id, name: name, isRecovery: isRecovery);
// moneroWalletsDir.listSync().forEach((item) async {
// try {
// if (item is Directory) {
// final name = item.path.split('/').last;
// final configFile = File('${item.path}/$name.json');
// final config =
// json.decode(configFile.readAsStringSync()) as Map<String, dynamic>;
// final isRecovery = config["isRecovery"] as bool ?? false;
// final id =
// walletTypeToString(WalletType.monero).toLowerCase() + '_' + name;
// final walletInfo =
// WalletInfo(id: id, name: name, isRecovery: isRecovery);
await walletsInfo.add(walletInfo);
}
} catch (e) {
print(e.toString());
}
});
// await walletsInfo.add(walletInfo);
// }
// } catch (e) {
// print(e.toString());
// }
// });
}
Future<void> migrate_ios_trades_list(
+28 -3
View File
@@ -1,12 +1,26 @@
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
part 'wallet_info.g.dart';
@HiveType(typeId: 4)
class WalletInfo extends HiveObject {
WalletInfo(
{this.id, this.name, this.type, this.isRecovery, this.restoreHeight});
WalletInfo(this.id, this.name, this.type, this.isRecovery, this.restoreHeight,
this.timestamp, this.dirPath, this.path);
factory WalletInfo.external(
{@required String id,
@required String name,
@required WalletType type,
@required bool isRecovery,
@required int restoreHeight,
@required DateTime date,
@required String dirPath,
@required String path}) {
return WalletInfo(id, name, type, isRecovery, restoreHeight,
date.millisecondsSinceEpoch ?? 0, dirPath, path);
}
static const boxName = 'WalletInfo';
@@ -24,4 +38,15 @@ class WalletInfo extends HiveObject {
@HiveField(4)
int restoreHeight;
@HiveField(5)
int timestamp;
@HiveField(6)
String dirPath;
@HiveField(7)
String path;
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timestamp);
}
+12 -11
View File
@@ -47,18 +47,19 @@ class MoneroWallet extends Wallet {
String name,
bool isRecovery = false,
int restoreHeight = 0}) async {
const type = WalletType.monero;
final id = walletTypeToString(type).toLowerCase() + '_' + name;
final walletInfo = WalletInfo(
id: id,
name: name,
type: type,
isRecovery: isRecovery,
restoreHeight: restoreHeight);
await walletInfoSource.add(walletInfo);
// const type = WalletType.monero;
// final id = walletTypeToString(type).toLowerCase() + '_' + name;
// final walletInfo = WalletInfo(
// id: id,
// name: name,
// type: type,
// isRecovery: isRecovery,
// restoreHeight: restoreHeight);
// await walletInfoSource.add(walletInfo);
return await configured(
walletInfo: walletInfo, walletInfoSource: walletInfoSource);
// return await configured(
// walletInfo: walletInfo, walletInfoSource: walletInfoSource);
return null;
}
static Future<MoneroWallet> load(
@@ -12,8 +12,6 @@ import 'package:cake_wallet/src/domain/common/wallet.dart';
import 'package:cake_wallet/src/domain/monero/monero_wallet.dart';
import 'package:cake_wallet/src/domain/common/wallet_description.dart';
class MoneroWalletsManager extends WalletsManager {
MoneroWalletsManager({@required this.walletInfoSource});
@@ -27,7 +25,8 @@ class MoneroWalletsManager extends WalletsManager {
const isRecovery = false;
final path = await pathForWallet(name: name, type: WalletType.monero);
await monero_wallet_manager.createWallet(path: path, password: password, language: language);
await monero_wallet_manager.createWallet(
path: path, password: password, language: language);
final wallet = await MoneroWallet.createdWallet(
walletInfoSource: walletInfoSource,
+10 -10
View File
@@ -65,18 +65,18 @@ void onSyncStatusChange(
{SyncStore syncStore,
WalletStore walletStore,
SettingsStore settingsStore}) {
_onSyncStatusChangeDisposer?.call();
// _onSyncStatusChangeDisposer?.call();
reaction((_) => syncStore.status, (SyncStatus status) async {
if (status is ConnectedSyncStatus) {
await walletStore.startSync();
}
// reaction((_) => syncStore.status, (SyncStatus status) async {
// if (status is ConnectedSyncStatus) {
// await walletStore.startSync();
// }
// Reconnect to the node if the app is not started sync after 30 seconds
if (status is StartingSyncStatus) {
startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
}
});
// // Reconnect to the node if the app is not started sync after 30 seconds
// if (status is StartingSyncStatus) {
// startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
// }
// });
}
void startReconnectionObserver({SyncStore syncStore, WalletStore walletStore}) {