mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-25 05:58:42 +01:00
Enable different currencies (#401)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
|
||||
@@ -6,12 +8,24 @@ part 'buy_amount_view_model.g.dart';
|
||||
class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel;
|
||||
|
||||
abstract class BuyAmountViewModelBase with Store {
|
||||
BuyAmountViewModelBase() : amount = '';
|
||||
BuyAmountViewModelBase() {
|
||||
amount = '';
|
||||
|
||||
int selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
||||
.indexOf(getIt.get<SettingsStore>().fiatCurrency);
|
||||
|
||||
if (selectedIndex == -1) {
|
||||
selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
|
||||
.indexOf(FiatCurrency.usd);
|
||||
}
|
||||
fiatCurrency = FiatCurrency.currenciesAvailableToBuyWith[selectedIndex];
|
||||
}
|
||||
|
||||
@observable
|
||||
String amount;
|
||||
|
||||
FiatCurrency get fiatCurrency => FiatCurrency.usd;
|
||||
@observable
|
||||
FiatCurrency fiatCurrency;
|
||||
|
||||
@computed
|
||||
double get doubleAmount {
|
||||
@@ -25,4 +39,4 @@ abstract class BuyAmountViewModelBase with Store {
|
||||
|
||||
return _amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ abstract class BuyViewModelBase with Store {
|
||||
|
||||
double get doubleAmount => buyAmountViewModel.doubleAmount;
|
||||
|
||||
@computed
|
||||
FiatCurrency get fiatCurrency => buyAmountViewModel.fiatCurrency;
|
||||
|
||||
CryptoCurrency get cryptoCurrency => walletTypeToCryptoCurrency(type);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/entities/language_service.dart';
|
||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
|
||||
@@ -172,9 +171,9 @@ abstract class SettingsViewModelBase with Store {
|
||||
displayItem: (dynamic code) {
|
||||
return LanguageService.list[code];
|
||||
},
|
||||
selectedItem: () => getIt.get<SettingsStore>().languageCode,
|
||||
selectedItem: () => _settingsStore.languageCode,
|
||||
onItemSelected: (String code) {
|
||||
getIt.get<SettingsStore>().languageCode = code;
|
||||
_settingsStore.languageCode = code;
|
||||
},
|
||||
images: LanguageService.list.keys.map(
|
||||
(e) => Image.asset("assets/images/flags/${LanguageService.localeCountryCode[e]}.png"))
|
||||
|
||||
Reference in New Issue
Block a user