mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
Cw 744 improve address book (#1771)
* add sort function to contact list * fix UI * prevent duplicate contact names * dispose contact source subscription * fix custom order issue * update the address book UI * fix saving custom order * fix merge conflict issue * fix the address book filter by the selected currency * add dropdown for wallets with multiple address types * minor fixes * add dropdown for wallets with multiple address types * Update lib/entities/contact.dart [skip ci] * Update lib/src/screens/contact/contact_list_page.dart [skip ci] * Update lib/src/screens/contact/contact_list_page.dart [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
@@ -28,7 +28,8 @@ abstract class ContactListViewModelBase with Store {
|
||||
isAutoGenerateEnabled =
|
||||
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled {
|
||||
walletInfoSource.values.forEach((info) {
|
||||
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) && info.addressInfos != null) {
|
||||
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) &&
|
||||
info.addressInfos != null) {
|
||||
for (var key in info.addressInfos!.keys) {
|
||||
final value = info.addressInfos![key];
|
||||
final address = value?.first;
|
||||
@@ -60,15 +61,19 @@ abstract class ContactListViewModelBase with Store {
|
||||
address,
|
||||
name,
|
||||
walletTypeToCryptoCurrency(info.type,
|
||||
isTestnet:
|
||||
info.network == null ? false : info.network!.toLowerCase().contains("testnet")),
|
||||
isTestnet: info.network == null
|
||||
? false
|
||||
: info.network!.toLowerCase().contains("testnet")),
|
||||
));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
walletContacts.add(WalletContact(
|
||||
info.address,
|
||||
_createName(info.name, "", key: [WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) ? 0 : null),
|
||||
_createName(info.name, "",
|
||||
key: [WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type)
|
||||
? 0
|
||||
: null),
|
||||
walletTypeToCryptoCurrency(info.type),
|
||||
));
|
||||
}
|
||||
@@ -82,8 +87,11 @@ abstract class ContactListViewModelBase with Store {
|
||||
}
|
||||
|
||||
String _createName(String walletName, String label, {int? key = null}) {
|
||||
final actualLabel = label.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active).replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments);
|
||||
return '$walletName${key == null ? "" : " [#${key}]"} ${actualLabel.isNotEmpty ? "($actualLabel)" : ""}'.trim();
|
||||
final actualLabel = label
|
||||
.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active)
|
||||
.replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments);
|
||||
return '$walletName${key == null ? "" : " [#${key}]"} ${actualLabel.isNotEmpty ? "($actualLabel)" : ""}'
|
||||
.trim();
|
||||
}
|
||||
|
||||
final bool isAutoGenerateEnabled;
|
||||
@@ -108,18 +116,19 @@ abstract class ContactListViewModelBase with Store {
|
||||
Future<void> delete(ContactRecord contact) async => contact.original.delete();
|
||||
|
||||
ObservableList<ContactRecord> get contactsToShow =>
|
||||
ObservableList.of(contacts.where((element) => _isValidForCurrency(element)));
|
||||
ObservableList.of(contacts.where((element) => _isValidForCurrency(element, false)));
|
||||
|
||||
@computed
|
||||
List<WalletContact> get walletContactsToShow =>
|
||||
walletContacts.where((element) => _isValidForCurrency(element)).toList();
|
||||
walletContacts.where((element) => _isValidForCurrency(element, true)).toList();
|
||||
|
||||
bool _isValidForCurrency(ContactBase element) {
|
||||
if (element.name.contains('Silent Payments')) return false;
|
||||
if (element.name.contains('MWEB')) return false;
|
||||
bool _isValidForCurrency(ContactBase element, bool isWalletContact) {
|
||||
if (_currency == null) return true;
|
||||
if (!element.name.contains('Active') &&
|
||||
isWalletContact &&
|
||||
(element.type == CryptoCurrency.btc || element.type == CryptoCurrency.ltc)) return false;
|
||||
|
||||
return _currency == null ||
|
||||
element.type == _currency ||
|
||||
return element.type == _currency ||
|
||||
(element.type.tag != null &&
|
||||
_currency?.tag != null &&
|
||||
element.type.tag == _currency?.tag) ||
|
||||
|
||||
Reference in New Issue
Block a user