cake_wallet/lib/view_model/settings/display_settings_view_model.dart

70 lines
2 KiB
Dart
Raw Normal View History

2022-11-23 17:06:41 +00:00
import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:mobx/mobx.dart';
2022-12-08 07:56:04 +00:00
import 'package:cake_wallet/entities/fiat_api_mode.dart';
2022-11-23 17:06:41 +00:00
part 'display_settings_view_model.g.dart';
class DisplaySettingsViewModel = DisplaySettingsViewModelBase with _$DisplaySettingsViewModel;
abstract class DisplaySettingsViewModelBase with Store {
DisplaySettingsViewModelBase(
2022-12-01 19:21:51 +00:00
this._settingsStore,
2022-11-23 17:06:41 +00:00
);
final SettingsStore _settingsStore;
@computed
FiatCurrency get fiatCurrency => _settingsStore.fiatCurrency;
@computed
String get languageCode => _settingsStore.languageCode;
@computed
2022-12-01 19:21:51 +00:00
BalanceDisplayMode get balanceDisplayMode => _settingsStore.balanceDisplayMode;
2022-11-23 17:06:41 +00:00
@computed
bool get shouldDisplayBalance => balanceDisplayMode == BalanceDisplayMode.displayableBalance;
@computed
bool get shouldShowMarketPlaceInDashboard => _settingsStore.shouldShowMarketPlaceInDashboard;
2022-11-23 17:06:41 +00:00
@computed
ThemeBase get theme => _settingsStore.currentTheme;
2022-12-08 07:56:04 +00:00
@computed
bool get disabledFiatApiMode => _settingsStore.fiatApiMode == FiatApiMode.disabled;
2022-11-23 17:06:41 +00:00
@action
2022-12-01 19:21:51 +00:00
void setBalanceDisplayMode(BalanceDisplayMode value) => _settingsStore.balanceDisplayMode = value;
2022-11-23 17:06:41 +00:00
@action
2022-12-01 19:21:51 +00:00
void setShouldDisplayBalance(bool value) {
if (value) {
_settingsStore.balanceDisplayMode = BalanceDisplayMode.displayableBalance;
2022-11-23 17:06:41 +00:00
} else {
2022-12-01 19:21:51 +00:00
_settingsStore.balanceDisplayMode = BalanceDisplayMode.hiddenBalance;
2022-11-23 17:06:41 +00:00
}
}
@action
2022-12-01 19:21:51 +00:00
void onLanguageSelected(String code) {
2022-11-23 17:06:41 +00:00
_settingsStore.languageCode = code;
}
@action
2022-12-01 19:21:51 +00:00
void setTheme(ThemeBase newTheme) {
_settingsStore.currentTheme = newTheme;
2022-11-23 17:06:41 +00:00
}
@action
2022-12-01 19:21:51 +00:00
void setFiatCurrency(FiatCurrency value) => _settingsStore.fiatCurrency = value;
@action
void setShouldShowMarketPlaceInDashbaord(bool value) {
_settingsStore.shouldShowMarketPlaceInDashboard = value;
}
2022-12-01 19:21:51 +00:00
}