looks up domain ui

This commit is contained in:
Serhii 2023-10-26 18:51:16 +03:00
parent cef3029f6f
commit 7321840dfe
9 changed files with 134 additions and 1 deletions

View file

@ -246,6 +246,9 @@ class BackupService {
final sortBalanceTokensBy = data[PreferencesKey.sortBalanceBy] as int?; final sortBalanceTokensBy = data[PreferencesKey.sortBalanceBy] as int?;
final pinNativeTokenAtTop = data[PreferencesKey.pinNativeTokenAtTop] as bool?; final pinNativeTokenAtTop = data[PreferencesKey.pinNativeTokenAtTop] as bool?;
final useEtherscan = data[PreferencesKey.useEtherscan] as bool?; final useEtherscan = data[PreferencesKey.useEtherscan] as bool?;
final looksUpTwitter = data[PreferencesKey.looksUpTwitter] as bool?;
final looksUpMastodon = data[PreferencesKey.looksUpMastodon] as bool?;
final looksUpENS = data[PreferencesKey.looksUpENS] as bool?;
final syncAll = data[PreferencesKey.syncAllKey] as bool?; final syncAll = data[PreferencesKey.syncAllKey] as bool?;
final syncMode = data[PreferencesKey.syncModeKey] as int?; final syncMode = data[PreferencesKey.syncModeKey] as int?;
final autoGenerateSubaddressStatus = data[PreferencesKey.autoGenerateSubaddressStatusKey] as int?; final autoGenerateSubaddressStatus = data[PreferencesKey.autoGenerateSubaddressStatusKey] as int?;
@ -373,6 +376,15 @@ class BackupService {
if (useEtherscan != null) if (useEtherscan != null)
await _sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan); await _sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan);
if (looksUpTwitter != null)
await _sharedPreferences.setBool(PreferencesKey.looksUpTwitter, looksUpTwitter);
if (looksUpMastodon != null)
await _sharedPreferences.setBool(PreferencesKey.looksUpMastodon, looksUpMastodon);
if (looksUpENS != null)
await _sharedPreferences.setBool(PreferencesKey.looksUpENS, looksUpENS);
if (syncAll != null) if (syncAll != null)
await _sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll); await _sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
@ -529,6 +541,12 @@ class BackupService {
_sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop), _sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),
PreferencesKey.useEtherscan: PreferencesKey.useEtherscan:
_sharedPreferences.getBool(PreferencesKey.useEtherscan), _sharedPreferences.getBool(PreferencesKey.useEtherscan),
PreferencesKey.looksUpTwitter:
_sharedPreferences.getBool(PreferencesKey.looksUpTwitter),
PreferencesKey.looksUpMastodon:
_sharedPreferences.getBool(PreferencesKey.looksUpMastodon),
PreferencesKey.looksUpENS:
_sharedPreferences.getBool(PreferencesKey.looksUpENS),
PreferencesKey.syncModeKey: PreferencesKey.syncModeKey:
_sharedPreferences.getInt(PreferencesKey.syncModeKey), _sharedPreferences.getInt(PreferencesKey.syncModeKey),
PreferencesKey.syncAllKey: PreferencesKey.syncAllKey:

View file

@ -36,6 +36,7 @@ import 'package:cake_wallet/src/screens/receive/anonpay_invoice_page.dart';
import 'package:cake_wallet/src/screens/receive/anonpay_receive_page.dart'; import 'package:cake_wallet/src/screens/receive/anonpay_receive_page.dart';
import 'package:cake_wallet/src/screens/restore/wallet_restore_choose_derivation.dart'; import 'package:cake_wallet/src/screens/restore/wallet_restore_choose_derivation.dart';
import 'package:cake_wallet/src/screens/settings/display_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/display_settings_page.dart';
import 'package:cake_wallet/src/screens/settings/domain_lookups_page.dart';
import 'package:cake_wallet/src/screens/settings/manage_nodes_page.dart'; import 'package:cake_wallet/src/screens/settings/manage_nodes_page.dart';
import 'package:cake_wallet/src/screens/settings/other_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/other_settings_page.dart';
import 'package:cake_wallet/src/screens/settings/privacy_page.dart'; import 'package:cake_wallet/src/screens/settings/privacy_page.dart';
@ -750,6 +751,8 @@ Future<void> setup({
getIt.registerFactory(() => PrivacyPage(getIt.get<PrivacySettingsViewModel>())); getIt.registerFactory(() => PrivacyPage(getIt.get<PrivacySettingsViewModel>()));
getIt.registerFactory(() => DomainLookupsPage(getIt.get<PrivacySettingsViewModel>()));
getIt.registerFactory(() => DisplaySettingsPage(getIt.get<DisplaySettingsViewModel>())); getIt.registerFactory(() => DisplaySettingsPage(getIt.get<DisplaySettingsViewModel>()));
getIt.registerFactory(() => OtherSettingsPage(getIt.get<OtherSettingsViewModel>())); getIt.registerFactory(() => OtherSettingsPage(getIt.get<OtherSettingsViewModel>()));

View file

@ -50,6 +50,9 @@ class PreferencesKey {
static const sortBalanceBy = 'sort_balance_by'; static const sortBalanceBy = 'sort_balance_by';
static const pinNativeTokenAtTop = 'pin_native_token_at_top'; static const pinNativeTokenAtTop = 'pin_native_token_at_top';
static const useEtherscan = 'use_etherscan'; static const useEtherscan = 'use_etherscan';
static const looksUpTwitter = 'looks_up_twitter';
static const looksUpMastodon = 'looks_up_mastodon';
static const looksUpENS = 'looks_up_ens';
static String moneroWalletUpdateV1Key(String name) => static String moneroWalletUpdateV1Key(String name) =>
'${PreferencesKey.moneroWalletPasswordUpdateV1Base}_${name}'; '${PreferencesKey.moneroWalletPasswordUpdateV1Base}_${name}';

View file

@ -23,6 +23,7 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart
import 'package:cake_wallet/src/screens/restore/wallet_restore_choose_derivation.dart'; import 'package:cake_wallet/src/screens/restore/wallet_restore_choose_derivation.dart';
import 'package:cake_wallet/src/screens/settings/desktop_settings/desktop_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/desktop_settings/desktop_settings_page.dart';
import 'package:cake_wallet/src/screens/settings/display_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/display_settings_page.dart';
import 'package:cake_wallet/src/screens/settings/domain_lookups_page.dart';
import 'package:cake_wallet/src/screens/settings/manage_nodes_page.dart'; import 'package:cake_wallet/src/screens/settings/manage_nodes_page.dart';
import 'package:cake_wallet/src/screens/settings/other_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/other_settings_page.dart';
import 'package:cake_wallet/src/screens/settings/privacy_page.dart'; import 'package:cake_wallet/src/screens/settings/privacy_page.dart';
@ -320,6 +321,10 @@ Route<dynamic> createRoute(RouteSettings settings) {
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, builder: (_) => getIt.get<PrivacyPage>()); fullscreenDialog: true, builder: (_) => getIt.get<PrivacyPage>());
case Routes.domainLookupsPage:
return CupertinoPageRoute<void>(
fullscreenDialog: true, builder: (_) => getIt.get<DomainLookupsPage>());
case Routes.displaySettingsPage: case Routes.displaySettingsPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, builder: (_) => getIt.get<DisplaySettingsPage>()); fullscreenDialog: true, builder: (_) => getIt.get<DisplaySettingsPage>());

View file

@ -81,6 +81,7 @@ class Routes {
static const connectionSync = '/connection_sync_page'; static const connectionSync = '/connection_sync_page';
static const securityBackupPage = '/security_and_backup_page'; static const securityBackupPage = '/security_and_backup_page';
static const privacyPage = '/privacy_page'; static const privacyPage = '/privacy_page';
static const domainLookupsPage = '/domain_lookups_page';
static const displaySettingsPage = '/display_settings_page'; static const displaySettingsPage = '/display_settings_page';
static const otherSettingsPage = '/other_settings_page'; static const otherSettingsPage = '/other_settings_page';
static const advancedPrivacySettings = '/advanced_privacy_settings'; static const advancedPrivacySettings = '/advanced_privacy_settings';

View file

@ -0,0 +1,42 @@
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
import 'package:cake_wallet/view_model/settings/privacy_settings_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class DomainLookupsPage extends BasePage {
DomainLookupsPage(this._privacySettingsViewModel);
@override
String get title => "S.current.display_settings";
final PrivacySettingsViewModel _privacySettingsViewModel;
@override
Widget body(BuildContext context) {
return SingleChildScrollView(
child: Observer(builder: (_) {
return Container(
padding: EdgeInsets.only(top: 10),
child: Column(
children: [
SettingsSwitcherCell(
title: 'S.current.settings_display_balance',
value: _privacySettingsViewModel.lookupTwitter,
onValueChange: (_, bool value) => _privacySettingsViewModel.setLookupTwitter(value)),
SettingsSwitcherCell(
title: 'S.current.settings_display_balance',
value: _privacySettingsViewModel.looksUpMastodon,
onValueChange: (_, bool value) => _privacySettingsViewModel.setLooksUpMastodon(value)),
SettingsSwitcherCell(
title: 'S.current.settings_display_balance',
value: _privacySettingsViewModel.looksUpENS,
onValueChange: (_, bool value) => _privacySettingsViewModel.setLooksUpENS(value)),
//if (!isHaven) it does not work correctly
],
),
);
}),
);
}
}

View file

@ -1,7 +1,9 @@
import 'package:cake_wallet/entities/exchange_api_mode.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_choices_cell.dart'; import 'package:cake_wallet/src/screens/settings/widgets/settings_choices_cell.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart'; import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/utils/device_info.dart';
@ -84,6 +86,10 @@ class PrivacyPage extends BasePage {
onValueChange: (BuildContext _, bool value) { onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setUseEtherscan(value); _privacySettingsViewModel.setUseEtherscan(value);
}), }),
SettingsCellWithArrow(
title: 'S.current.manage_nodes',
handler: (context) => Navigator.of(context).pushNamed(Routes.domainLookupsPage),
),
], ],
); );
}), }),

View file

@ -82,6 +82,9 @@ abstract class SettingsStoreBase with Store {
required this.sortBalanceBy, required this.sortBalanceBy,
required this.pinNativeTokenAtTop, required this.pinNativeTokenAtTop,
required this.useEtherscan, required this.useEtherscan,
required this.looksUpTwitter,
required this.looksUpMastodon,
required this.looksUpENS,
TransactionPriority? initialBitcoinTransactionPriority, TransactionPriority? initialBitcoinTransactionPriority,
TransactionPriority? initialMoneroTransactionPriority, TransactionPriority? initialMoneroTransactionPriority,
TransactionPriority? initialHavenTransactionPriority, TransactionPriority? initialHavenTransactionPriority,
@ -353,6 +356,21 @@ abstract class SettingsStoreBase with Store {
(bool useEtherscan) => (bool useEtherscan) =>
_sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan)); _sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan));
reaction(
(_) => looksUpTwitter,
(bool looksUpTwitter) =>
_sharedPreferences.setBool(PreferencesKey.looksUpTwitter, looksUpTwitter));
reaction(
(_) => looksUpMastodon,
(bool looksUpMastodon) =>
_sharedPreferences.setBool(PreferencesKey.looksUpMastodon, looksUpMastodon));
reaction(
(_) => looksUpENS,
(bool looksUpENS) =>
_sharedPreferences.setBool(PreferencesKey.looksUpENS, looksUpENS));
this.nodes.observe((change) { this.nodes.observe((change) {
if (change.newValue != null && change.key != null) { if (change.newValue != null && change.key != null) {
_saveCurrentNode(change.newValue!, change.key!); _saveCurrentNode(change.newValue!, change.key!);
@ -476,6 +494,15 @@ abstract class SettingsStoreBase with Store {
@observable @observable
bool useEtherscan; bool useEtherscan;
@observable
bool looksUpTwitter;
@observable
bool looksUpMastodon;
@observable
bool looksUpENS;
@observable @observable
SyncMode currentSyncMode; SyncMode currentSyncMode;
@ -632,6 +659,9 @@ abstract class SettingsStoreBase with Store {
final pinNativeTokenAtTop = final pinNativeTokenAtTop =
sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true; sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
final useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true; final useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
final looksUpTwitter = sharedPreferences.getBool(PreferencesKey.looksUpTwitter) ?? true;
final looksUpMastodon = sharedPreferences.getBool(PreferencesKey.looksUpMastodon) ?? true;
final looksUpENS = sharedPreferences.getBool(PreferencesKey.looksUpENS) ?? true;
// If no value // If no value
if (pinLength == null || pinLength == 0) { if (pinLength == null || pinLength == 0) {
@ -739,6 +769,9 @@ abstract class SettingsStoreBase with Store {
sortBalanceBy: sortBalanceBy, sortBalanceBy: sortBalanceBy,
pinNativeTokenAtTop: pinNativeTokenAtTop, pinNativeTokenAtTop: pinNativeTokenAtTop,
useEtherscan: useEtherscan, useEtherscan: useEtherscan,
looksUpTwitter: looksUpTwitter,
looksUpMastodon: looksUpMastodon,
looksUpENS: looksUpENS,
initialMoneroTransactionPriority: moneroTransactionPriority, initialMoneroTransactionPriority: moneroTransactionPriority,
initialBitcoinTransactionPriority: bitcoinTransactionPriority, initialBitcoinTransactionPriority: bitcoinTransactionPriority,
initialHavenTransactionPriority: havenTransactionPriority, initialHavenTransactionPriority: havenTransactionPriority,
@ -874,6 +907,9 @@ abstract class SettingsStoreBase with Store {
.values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index]; .values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index];
pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true; pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true; useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
looksUpTwitter = sharedPreferences.getBool(PreferencesKey.looksUpTwitter) ?? true;
looksUpMastodon = sharedPreferences.getBool(PreferencesKey.looksUpMastodon) ?? true;
looksUpENS = sharedPreferences.getBool(PreferencesKey.looksUpENS) ?? true;
final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey); final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
final bitcoinElectrumServerId = final bitcoinElectrumServerId =

View file

@ -12,7 +12,8 @@ import 'package:cake_wallet/entities/fiat_api_mode.dart';
part 'privacy_settings_view_model.g.dart'; part 'privacy_settings_view_model.g.dart';
class PrivacySettingsViewModel = PrivacySettingsViewModelBase with _$PrivacySettingsViewModel; class
PrivacySettingsViewModel = PrivacySettingsViewModelBase with _$PrivacySettingsViewModel;
abstract class PrivacySettingsViewModelBase with Store { abstract class PrivacySettingsViewModelBase with Store {
PrivacySettingsViewModelBase(this._settingsStore, this._wallet); PrivacySettingsViewModelBase(this._settingsStore, this._wallet);
@ -57,6 +58,15 @@ abstract class PrivacySettingsViewModelBase with Store {
@computed @computed
bool get useEtherscan => _settingsStore.useEtherscan; bool get useEtherscan => _settingsStore.useEtherscan;
@computed
bool get lookupTwitter => _settingsStore.looksUpTwitter;
@computed
bool get looksUpMastodon => _settingsStore.looksUpMastodon;
@computed
bool get looksUpENS => _settingsStore.looksUpENS;
bool get canUseEtherscan => _wallet.type == WalletType.ethereum; bool get canUseEtherscan => _wallet.type == WalletType.ethereum;
@action @action
@ -78,6 +88,15 @@ abstract class PrivacySettingsViewModelBase with Store {
@action @action
void setDisableSell(bool value) => _settingsStore.disableSell = value; void setDisableSell(bool value) => _settingsStore.disableSell = value;
@action
void setLookupTwitter(bool value) => _settingsStore.looksUpTwitter = value;
@action
void setLooksUpMastodon(bool value) => _settingsStore.looksUpMastodon = value;
@action
void setLooksUpENS(bool value) => _settingsStore.looksUpENS = value;
@action @action
void setUseEtherscan(bool value) { void setUseEtherscan(bool value) {
_settingsStore.useEtherscan = value; _settingsStore.useEtherscan = value;