CAKE-306 | merged main branch into current; added _fetchBuyItems() method to buy_view_model.dart; deleted isMoonPayEnabled parameter from settings_store.dart
OleksandrSobol committed
Jun 7, 2021 at 16:40 UTC
d5d1afd89b62344332e0c2473d7154267041d41f
6 files changed
+27
-40
lib/di.dart
+1
-13
@@ -1,11 +1,9 @@
1
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
2
import 'package:cake_wallet/bitcoin/litecoin_wallet_service.dart';
3
-import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart';
3
import 'package:cake_wallet/core/backup_service.dart';
4
import 'package:cake_wallet/core/wallet_service.dart';
5
import 'package:cake_wallet/entities/biometric_auth.dart';
6
import 'package:cake_wallet/entities/contact_record.dart';
8
-import 'package:cake_wallet/entities/load_current_wallet.dart';
7
import 'package:cake_wallet/buy/order.dart';
8
import 'package:cake_wallet/entities/transaction_description.dart';
9
import 'package:cake_wallet/entities/transaction_info.dart';
@@ -92,7 +90,6 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
90
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
91
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
92
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
95
-import 'package:devicelocale/devicelocale.dart';
93
import 'package:flutter/widgets.dart';
94
import 'package:get_it/get_it.dart';
95
import 'package:hive/hive.dart';
@@ -156,17 +153,8 @@ Future setup(
153
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
154
(secrets.wyreAccountId?.isNotEmpty ?? false);
155
159
- var isMoonPayEnabled = false;
160
- try {
161
- isMoonPayEnabled = await MoonPayBuyProvider.onEnabled();
162
- } catch (e) {
163
- isMoonPayEnabled = false;
164
- print(e.toString());
165
- }
166
-
156
final settingsStore = await SettingsStoreBase.load(
168
- nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled,
169
- isMoonPayEnabled: isMoonPayEnabled);
157
+ nodeSource: _nodeSource, isBitcoinBuyEnabled: isBitcoinBuyEnabled);
158
159
if (_isSetupFinished) {
160
return;
lib/entities/push_notifications_service.dart
+1
-1
@@ -21,7 +21,7 @@ class PushNotificationsService {
21
_firebaseMessaging.requestNotificationPermissions();
22
_firebaseMessaging.configure(
23
onMessage: (message) async {
24
- Map<dynamic, dynamic> alert = {};
24
+ Map<dynamic, dynamic> alert = <dynamic, dynamic>{};
25
String msg = '';
26
String title = '';
27
lib/store/settings_store.dart
-16
@@ -1,5 +1,4 @@
1
import 'package:cake_wallet/bitcoin/bitcoin_transaction_priority.dart';
2
-import 'package:cake_wallet/buy/moonpay/moonpay_buy_provider.dart';
2
import 'package:cake_wallet/entities/preferences_key.dart';
3
import 'package:cake_wallet/entities/transaction_priority.dart';
4
import 'package:cake_wallet/themes/theme_base.dart';
@@ -9,7 +8,6 @@ import 'package:flutter/material.dart';
8
import 'package:hive/hive.dart';
9
import 'package:mobx/mobx.dart';
10
import 'package:package_info/package_info.dart';
12
-import 'package:devicelocale/devicelocale.dart';
11
import 'package:cake_wallet/di.dart';
12
import 'package:cake_wallet/entities/wallet_type.dart';
13
import 'package:shared_preferences/shared_preferences.dart';
@@ -41,7 +39,6 @@ abstract class SettingsStoreBase with Store {
39
@required TransactionPriority initialBitcoinTransactionPriority,
40
@required TransactionPriority initialMoneroTransactionPriority,
41
@required this.isBitcoinBuyEnabled,
44
- @required this.isMoonPayEnabled,
42
this.actionlistDisplayMode}) {
43
fiatCurrency = initialFiatCurrency;
44
balanceDisplayMode = initialBalanceDisplayMode;
@@ -150,12 +147,9 @@ abstract class SettingsStoreBase with Store {
147
148
bool isBitcoinBuyEnabled;
149
153
- bool isMoonPayEnabled;
154
-
150
static Future<SettingsStore> load(
151
{@required Box<Node> nodeSource,
152
@required bool isBitcoinBuyEnabled,
158
- @required bool isMoonPayEnabled,
153
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
154
MoneroTransactionPriority initialMoneroTransactionPriority =
155
MoneroTransactionPriority.slow,
@@ -227,7 +221,6 @@ abstract class SettingsStoreBase with Store {
221
},
222
appVersion: packageInfo.version,
223
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
230
- isMoonPayEnabled: isMoonPayEnabled,
224
initialFiatCurrency: currentFiatCurrency,
225
initialBalanceDisplayMode: currentBalanceDisplayMode,
226
initialSaveRecipientAddress: shouldSaveRecipientAddress,
@@ -253,18 +246,9 @@ abstract class SettingsStoreBase with Store {
246
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
247
(secrets.wyreAccountId?.isNotEmpty ?? false);
248
256
- var isMoonPayEnabled = false;
257
- try {
258
- isMoonPayEnabled = await MoonPayBuyProvider.onEnabled();
259
- } catch (e) {
260
- isMoonPayEnabled = false;
261
- print(e.toString());
262
- }
263
-
249
final settings = await SettingsStoreBase.load(
250
nodeSource: nodeSource,
251
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
267
- isMoonPayEnabled: isMoonPayEnabled,
252
initialBalanceDisplayMode: initialBalanceDisplayMode,
253
initialFiatCurrency: initialFiatCurrency,
254
initialMoneroTransactionPriority: initialMoneroTransactionPriority,
lib/view_model/buy/buy_view_model.dart
+21
-10
@@ -21,15 +21,9 @@ class BuyViewModel = BuyViewModelBase with _$BuyViewModel;
21
abstract class BuyViewModelBase with Store {
22
BuyViewModelBase(this.ordersSource, this.ordersStore, this.settingsStore,
23
this.buyAmountViewModel, {@required this.wallet}) {
24
- providerList = [WyreBuyProvider(wallet: wallet)];
24
26
- if (settingsStore.isMoonPayEnabled ?? false) {
27
- providerList.add(MoonPayBuyProvider(wallet: wallet));
28
- }
25
+ _fetchBuyItems();
26
30
- items = providerList.map((provider) =>
31
- BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel))
32
- .toList();
27
isRunning = false;
28
isDisabled = true;
29
isShowProviderButtons = false;
@@ -41,9 +35,6 @@ abstract class BuyViewModelBase with Store {
35
final BuyAmountViewModel buyAmountViewModel;
36
final WalletBase wallet;
37
44
- @observable
45
- List<BuyProvider> providerList;
46
-
38
@observable
39
BuyProvider selectedProvider;
40
@@ -96,4 +87,24 @@ abstract class BuyViewModelBase with Store {
87
buyAmountViewModel.amount = '';
88
selectedProvider = null;
89
}
90
+
91
+ Future<void> _fetchBuyItems() async {
92
+ final List<BuyProvider> _providerList = [WyreBuyProvider(wallet: wallet)];
93
+
94
+ var isMoonPayEnabled = false;
95
+ try {
96
+ isMoonPayEnabled = await MoonPayBuyProvider.onEnabled();
97
+ } catch (e) {
98
+ isMoonPayEnabled = false;
99
+ print(e.toString());
100
+ }
101
+
102
+ if (isMoonPayEnabled) {
103
+ _providerList.add(MoonPayBuyProvider(wallet: wallet));
104
+ }
105
+
106
+ items = _providerList.map((provider) =>
107
+ BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel))
108
+ .toList();
109
+ }
110
}
\ No newline at end of file
res/values/strings_hr.arb
+2
@@ -478,5 +478,7 @@
478
479
"apk_update" : "APK ažuriranje",
480
481
+ "buy_bitcoin" : "Kupite Bitcoin",
482
+ "buy_with" : "Kupite s",
483
"moonpay_alert_text" : "Vrijednost iznosa mora biti veća ili jednaka ${minAmount} ${fiatCurrency}"
484
}
\ No newline at end of file
res/values/strings_it.arb
+2
@@ -478,5 +478,7 @@
478
479
"apk_update" : "Aggiornamento APK",
480
481
+ "buy_bitcoin" : "Acquista Bitcoin",
482
+ "buy_with" : "Acquista con",
483
"moonpay_alert_text" : "Il valore dell'importo deve essere maggiore o uguale a ${minAmount} ${fiatCurrency}"
484
}
\ No newline at end of file