mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
CAKE-306 | merged main branch into current; added _fetchBuyItems() method to buy_view_model.dart; deleted isMoonPayEnabled parameter from settings_store.dart
This commit is contained in:
@@ -21,15 +21,9 @@ class BuyViewModel = BuyViewModelBase with _$BuyViewModel;
|
||||
abstract class BuyViewModelBase with Store {
|
||||
BuyViewModelBase(this.ordersSource, this.ordersStore, this.settingsStore,
|
||||
this.buyAmountViewModel, {@required this.wallet}) {
|
||||
providerList = [WyreBuyProvider(wallet: wallet)];
|
||||
|
||||
if (settingsStore.isMoonPayEnabled ?? false) {
|
||||
providerList.add(MoonPayBuyProvider(wallet: wallet));
|
||||
}
|
||||
_fetchBuyItems();
|
||||
|
||||
items = providerList.map((provider) =>
|
||||
BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel))
|
||||
.toList();
|
||||
isRunning = false;
|
||||
isDisabled = true;
|
||||
isShowProviderButtons = false;
|
||||
@@ -41,9 +35,6 @@ abstract class BuyViewModelBase with Store {
|
||||
final BuyAmountViewModel buyAmountViewModel;
|
||||
final WalletBase wallet;
|
||||
|
||||
@observable
|
||||
List<BuyProvider> providerList;
|
||||
|
||||
@observable
|
||||
BuyProvider selectedProvider;
|
||||
|
||||
@@ -96,4 +87,24 @@ abstract class BuyViewModelBase with Store {
|
||||
buyAmountViewModel.amount = '';
|
||||
selectedProvider = null;
|
||||
}
|
||||
|
||||
Future<void> _fetchBuyItems() async {
|
||||
final List<BuyProvider> _providerList = [WyreBuyProvider(wallet: wallet)];
|
||||
|
||||
var isMoonPayEnabled = false;
|
||||
try {
|
||||
isMoonPayEnabled = await MoonPayBuyProvider.onEnabled();
|
||||
} catch (e) {
|
||||
isMoonPayEnabled = false;
|
||||
print(e.toString());
|
||||
}
|
||||
|
||||
if (isMoonPayEnabled) {
|
||||
_providerList.add(MoonPayBuyProvider(wallet: wallet));
|
||||
}
|
||||
|
||||
items = _providerList.map((provider) =>
|
||||
BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user