From cfde445d3242d1df8259b1c628e4a32b52ae45cb Mon Sep 17 00:00:00 2001 From: M Date: Wed, 3 Jun 2020 12:56:23 +0300 Subject: [PATCH] TMP 3 --- lib/core/app_service.dart | 16 +++ lib/core/app_store.dart | 12 -- lib/core/bitcoin_wallet.dart | 4 +- lib/core/wallet_creation_service.dart | 4 + lib/main.dart | 18 ++- .../screens/new_wallet/new_wallet_page.dart | 111 ++++++++++-------- 6 files changed, 102 insertions(+), 63 deletions(-) create mode 100644 lib/core/app_service.dart delete mode 100644 lib/core/app_store.dart diff --git a/lib/core/app_service.dart b/lib/core/app_service.dart new file mode 100644 index 000000000..201f1eb68 --- /dev/null +++ b/lib/core/app_service.dart @@ -0,0 +1,16 @@ +import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/core/auth_service.dart'; +import 'package:cake_wallet/core/wallet_base.dart'; +import 'package:cake_wallet/core/wallet_creation_service.dart'; + +part 'app_service.g.dart'; + +class AppService = AppServiceBase with _$AppService; + +abstract class AppServiceBase with Store { + AppServiceBase({this.walletCreationService, this.authService, this.wallet}); + + WalletCreationService walletCreationService; + AuthService authService; + WalletBase wallet; +} \ No newline at end of file diff --git a/lib/core/app_store.dart b/lib/core/app_store.dart deleted file mode 100644 index ac1730a61..000000000 --- a/lib/core/app_store.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:mobx/mobx.dart'; - -part 'app_store.g.dart'; - -class AppStore = AppStoreBase with _$AppStore; - -abstract class AppStoreBase with Store { - // Sign Up - // Auth - // Wallet - // Settings -} \ No newline at end of file diff --git a/lib/core/bitcoin_wallet.dart b/lib/core/bitcoin_wallet.dart index 2bf57b96a..0a69b23b0 100644 --- a/lib/core/bitcoin_wallet.dart +++ b/lib/core/bitcoin_wallet.dart @@ -24,7 +24,7 @@ part 'bitcoin_wallet.g.dart'; class BitcoinWallet = BitcoinWalletBase with _$BitcoinWallet; abstract class BitcoinWalletBase extends WalletBase with Store { - static Future load( + static Future load( {@required String name, @required String password}) async { final walletDirPath = await pathForWalletDir(name: name, type: WalletType.bitcoin); @@ -37,7 +37,7 @@ abstract class BitcoinWalletBase extends WalletBase with Store { ? 0 : int.parse(jsoned['account_index'] as String); - return BitcoinWallet.build( + return BitcoinWalletBase.build( mnemonic: mnemonic, password: password, name: name, diff --git a/lib/core/wallet_creation_service.dart b/lib/core/wallet_creation_service.dart index 123acd8d0..129b6ad17 100644 --- a/lib/core/wallet_creation_service.dart +++ b/lib/core/wallet_creation_service.dart @@ -16,9 +16,13 @@ abstract class WalletCreationServiceBase with Store { @observable WalletCreationState state; + WalletType type; + WalletListService _service; void changeWalletType({@required WalletType type}) { + this.type = type; + switch (type) { case WalletType.monero: _service = MoneroWalletListService(); diff --git a/lib/main.dart b/lib/main.dart index 0feef41c7..9f0dd47a8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,6 @@ +import 'package:cake_wallet/core/app_service.dart'; +import 'package:cake_wallet/core/auth_service.dart'; +import 'package:cake_wallet/core/wallet_creation_service.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -41,7 +44,6 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/domain/common/language.dart'; import 'package:cake_wallet/src/stores/seed_language/seed_language_store.dart'; - void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -73,7 +75,8 @@ void main() async { await Hive.openBox(Trade.boxName, encryptionKey: tradesBoxKey); final walletInfoSource = await Hive.openBox(WalletInfo.boxName); final templates = await Hive.openBox