Cw 658 make the addressbook popup can be turned off from the settings (#1856)

* make ‘Add to Addressbook’ popup optional in settings

* localisation

* fix contacts page background color
This commit is contained in:
Serhii
2024-12-09 22:37:06 +02:00
committed by GitHub
parent c78662fbfe
commit 03ff2287db
35 changed files with 67 additions and 4 deletions
+1
View File
@@ -91,6 +91,7 @@ class PreferencesKey {
static const donationLinkWalletName = 'donation_link_wallet_name';
static const lastSeenAppVersion = 'last_seen_app_version';
static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard';
static const showAddressBookPopupEnabled = 'show_address_book_popup_enabled';
static const isNewInstall = 'is_new_install';
static const serviceStatusShaKey = 'service_status_sha_key';
static const walletConnectPairingTopicsList = 'wallet_connect_pairing_topics_list';
@@ -322,6 +322,7 @@ class _ContactListBodyState extends State<ContactListBody> {
? widget.contactListViewModel.contacts
: widget.contactListViewModel.contactsToShow;
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: Container(
child: FilteredList(
list: contacts,
+2 -2
View File
@@ -525,14 +525,14 @@ class SendPage extends BasePage {
? '. ${S.of(_dialogContext).waitFewSecondForTxUpdate}'
: '';
final newContactMessage = newContactAddress != null
final newContactMessage = newContactAddress != null && sendViewModel.showAddressBookPopup
? '\n${S.of(_dialogContext).add_contact_to_address_book}'
: '';
String alertContent =
"$successMessage$waitMessage$newContactMessage";
if (newContactAddress != null) {
if (newContactMessage.isNotEmpty) {
return AlertWithTwoActions(
alertDialogKey: ValueKey('send_page_sent_dialog_key'),
alertTitle: '',
@@ -6,6 +6,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/settings/widgets/setting_priority_picker_cell.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_picker_cell.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_version_cell.dart';
import 'package:cake_wallet/view_model/settings/other_settings_view_model.dart';
import 'package:cw_core/wallet_type.dart';
@@ -62,6 +63,13 @@ class OtherSettingsPage extends BasePage {
handler: (BuildContext context) =>
Navigator.of(context).pushNamed(Routes.readDisclaimer),
),
SettingsSwitcherCell(
title: S.of(context).show_address_book_popup,
value: _otherSettingsViewModel.showAddressBookPopup,
onValueChange: (_, bool value) {
_otherSettingsViewModel.setShowAddressBookPopup(value);
},
),
Spacer(),
SettingsVersionCell(
title: S.of(context).version(_otherSettingsViewModel.currentVersion)),
+16
View File
@@ -54,6 +54,7 @@ abstract class SettingsStoreBase with Store {
required BackgroundTasks backgroundTasks,
required SharedPreferences sharedPreferences,
required bool initialShouldShowMarketPlaceInDashboard,
required bool initialShowAddressBookPopupEnabled,
required FiatCurrency initialFiatCurrency,
required BalanceDisplayMode initialBalanceDisplayMode,
required bool initialSaveRecipientAddress,
@@ -157,6 +158,7 @@ abstract class SettingsStoreBase with Store {
walletListAscending = initialWalletListAscending,
contactListAscending = initialContactListAscending,
shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
showAddressBookPopupEnabled = initialShowAddressBookPopupEnabled,
exchangeStatus = initialExchangeStatus,
currentTheme = initialTheme,
pinCodeLength = initialPinLength,
@@ -354,6 +356,11 @@ abstract class SettingsStoreBase with Store {
(bool value) =>
sharedPreferences.setBool(PreferencesKey.shouldShowMarketPlaceInDashboard, value));
reaction(
(_) => showAddressBookPopupEnabled,
(bool value) =>
sharedPreferences.setBool(PreferencesKey.showAddressBookPopupEnabled, value));
reaction((_) => pinCodeLength,
(int pinLength) => sharedPreferences.setInt(PreferencesKey.currentPinLength, pinLength));
@@ -606,6 +613,9 @@ abstract class SettingsStoreBase with Store {
@observable
bool shouldShowMarketPlaceInDashboard;
@observable
bool showAddressBookPopupEnabled;
@observable
ObservableList<ActionListDisplayMode> actionlistDisplayMode;
@@ -917,6 +927,8 @@ abstract class SettingsStoreBase with Store {
final tokenTrialNumber = sharedPreferences.getInt(PreferencesKey.failedTotpTokenTrials) ?? 0;
final shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true;
final showAddressBookPopupEnabled =
sharedPreferences.getBool(PreferencesKey.showAddressBookPopupEnabled) ?? true;
final exchangeStatus = ExchangeApiMode.deserialize(
raw: sharedPreferences.getInt(PreferencesKey.exchangeStatusKey) ??
ExchangeApiMode.enabled.raw);
@@ -1185,6 +1197,7 @@ abstract class SettingsStoreBase with Store {
secureStorage: secureStorage,
sharedPreferences: sharedPreferences,
initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
initialShowAddressBookPopupEnabled: showAddressBookPopupEnabled,
nodes: nodes,
powNodes: powNodes,
appVersion: packageInfo.version,
@@ -1361,6 +1374,9 @@ abstract class SettingsStoreBase with Store {
shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ??
shouldShowMarketPlaceInDashboard;
showAddressBookPopupEnabled =
sharedPreferences.getBool(PreferencesKey.showAddressBookPopupEnabled) ??
showAddressBookPopupEnabled;
exchangeStatus = ExchangeApiMode.deserialize(
raw: sharedPreferences.getInt(PreferencesKey.exchangeStatusKey) ??
ExchangeApiMode.enabled.raw);
+2
View File
@@ -109,6 +109,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
final UnspentCoinType coinTypeToSpendFrom;
bool get showAddressBookPopup => _settingsStore.showAddressBookPopupEnabled;
@action
void addOutput() {
outputs
@@ -60,6 +60,10 @@ abstract class OtherSettingsViewModelBase with Store {
bool get changeRepresentativeEnabled =>
_wallet.type == WalletType.nano || _wallet.type == WalletType.banano;
@computed
bool get showAddressBookPopup => _settingsStore.showAddressBookPopupEnabled;
@computed
bool get displayTransactionPriority => !(changeRepresentativeEnabled ||
_wallet.type == WalletType.solana ||
@@ -114,6 +118,9 @@ abstract class OtherSettingsViewModelBase with Store {
return customItem != null ? priorities.indexOf(customItem) : null;
}
@action
void setShowAddressBookPopup(bool value) => _settingsStore.showAddressBookPopupEnabled = value;
int? get maxCustomFeeRate {
if (_wallet.type == WalletType.bitcoin) {
return bitcoin!.getMaxCustomFeeRate(_wallet);