From 396227ad186b7be67f77d075cd7a3a5d69d9dfd5 Mon Sep 17 00:00:00 2001 From: redDwarf03 Date: Mon, 13 Jan 2025 22:22:01 +0100 Subject: [PATCH] fix: :construction: Fix accounts dialog usage --- lib/ui/util/accounts_dialog.dart | 25 ++- lib/ui/util/formatters.dart | 58 ------ .../util/transfer_recipient_formatters.dart | 2 +- .../layouts/components/account_list_item.dart | 2 +- .../components/add_account_confirm_sheet.dart | 2 +- ...idity_add_settings_slippage_tolerance.dart | 3 +- .../swap_settings_slippage_tolerance.dart | 3 +- .../nft_search/layouts/nft_search_bar.dart | 50 +++-- .../token_selection_common_bases.dart | 3 +- lib/ui/views/transfer/bloc/provider.dart | 55 +++--- .../transfer_textfield_address.dart | 83 ++++++--- .../components/transfer_token_detail.dart | 4 +- .../transfer/layouts/transfer_sheet.dart | 2 +- lib/ui/widgets/dialogs/accounts_dialog.dart | 172 ------------------ lib/util/account_formatters.dart | 5 +- pubspec.lock | 32 ++-- pubspec.yaml | 7 +- 17 files changed, 157 insertions(+), 351 deletions(-) delete mode 100644 lib/ui/widgets/dialogs/accounts_dialog.dart diff --git a/lib/ui/util/accounts_dialog.dart b/lib/ui/util/accounts_dialog.dart index 2ac1f84b8..30ad8dc3d 100644 --- a/lib/ui/util/accounts_dialog.dart +++ b/lib/ui/util/accounts_dialog.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'dart:ui'; -import 'package:aewallet/application/account/accounts_notifier.dart'; import 'package:aewallet/model/data/account.dart'; import 'package:aewallet/ui/themes/archethic_theme.dart'; import 'package:aewallet/ui/themes/styles.dart'; @@ -16,31 +15,27 @@ import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutte import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/localizations.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; class AccountsDialog { static Future selectSingleAccount({ required BuildContext context, - required WidgetRef ref, required List accounts, String? dialogTitle, Widget? header, bool? isModal = false, + double? heightFactor = 1, }) async { - final selection = await _showAccountsDialog( + return await _showAccountsDialog( context: context, accounts: accounts, multipleSelectionsAllowed: false, dialogTitle: dialogTitle, header: header, isModal: isModal, + heightFactor: heightFactor, ) as Account?; - if (selection != null) { - await ref - .read(accountsNotifierProvider.notifier) - .selectAccount(selection); - } - return selection; } static Future?> selectMultipleAccounts({ @@ -50,6 +45,7 @@ class AccountsDialog { String? dialogTitle, Widget? header, bool? isModal = false, + double? heightFactor = 1, }) async { return await _showAccountsDialog( context: context, @@ -59,6 +55,7 @@ class AccountsDialog { dialogTitle: dialogTitle, header: header, isModal: isModal, + heightFactor: heightFactor, ) as List?; } @@ -70,6 +67,7 @@ class AccountsDialog { String? dialogTitle, Widget? header, bool? isModal = false, + double? heightFactor = 1, }) async { final pickerItemsList = >[]; @@ -116,7 +114,7 @@ class AccountsDialog { context: context, builder: (BuildContext context) { return FractionallySizedBox( - heightFactor: 1, + heightFactor: heightFactor, child: Scaffold( backgroundColor: aedappfm.AppThemeBase.sheetBackground.withOpacity(0.2), @@ -204,7 +202,7 @@ class AccountsDialogContentState extends ConsumerState { scrollable: true, onSelected: (pickerItem) { if (!widget.multipleSelectionsAllowed) { - Navigator.of(context).pop(pickerItem.value); + context.pop(pickerItem.value); } }, onUnselected: (selectedIndexes) { @@ -255,8 +253,7 @@ class AccountsDialogContentState extends ConsumerState { final _accountsList = pickerItemsListSelected .map((item) => item.value) .toList(); - - Navigator.of(context).pop(_accountsList); + context.pop(_accountsList); }, disabled: pickerItemsListSelected.isEmpty, ), @@ -268,7 +265,7 @@ class AccountsDialogContentState extends ConsumerState { localizations.cancel, Dimens.buttonBottomDimens, onPressed: () { - Navigator.of(context).pop(); + context.pop(); }, ), ], diff --git a/lib/ui/util/formatters.dart b/lib/ui/util/formatters.dart index 5d8ce9263..63f097b13 100644 --- a/lib/ui/util/formatters.dart +++ b/lib/ui/util/formatters.dart @@ -4,64 +4,6 @@ import 'dart:math'; import 'package:flutter/services.dart'; -/// Input formatter that ensures text starts with @ -class ContactInputFormatter extends TextInputFormatter { - @override - TextEditingValue formatEditUpdate( - TextEditingValue oldValue, - TextEditingValue newValue, - ) { - if (newValue.selection.baseOffset == 0) { - return newValue; - } - - var workingText = newValue.text; - if (!workingText.startsWith('@')) { - workingText = '@$workingText'; - } - - final splitStr = workingText.split('@'); - // If this string contains more than 1 @, remove all but the first one - if (splitStr.length > 2) { - workingText = '@${workingText.replaceAll('@', '')}'; - } - - // If nothing changed, return original - if (workingText == newValue.text) { - return newValue; - } - - return newValue.copyWith( - text: workingText, - selection: TextSelection.collapsed(offset: workingText.length), - ); - } -} - -/// Input formatter that ensures only one space between words -class SingleSpaceInputFormatter extends TextInputFormatter { - @override - TextEditingValue formatEditUpdate( - TextEditingValue oldValue, - TextEditingValue newValue, - ) { - if (newValue.selection.baseOffset == 0) { - return newValue; - } - - // Don't allow first character to be a space - if (newValue.text.length < oldValue.text.length) { - return newValue; - } else if (oldValue.text.isEmpty && newValue.text == ' ') { - return oldValue; - } else if (oldValue.text.endsWith(' ') && newValue.text.endsWith(' ')) { - return oldValue; - } - - return newValue; - } -} - /// Ensures input is always uppercase class UpperCaseTextFormatter extends TextInputFormatter { @override diff --git a/lib/ui/util/transfer_recipient_formatters.dart b/lib/ui/util/transfer_recipient_formatters.dart index 7f99a8b1b..2909d5e84 100644 --- a/lib/ui/util/transfer_recipient_formatters.dart +++ b/lib/ui/util/transfer_recipient_formatters.dart @@ -10,6 +10,6 @@ extension TransferRecipientFormatters on TransferRecipient { ? localizations.burnAddressLbl : AddressFormatters(address.address!).getShortString(), account: (account) => account.format, - unknownContact: (name) => name.replaceFirst('@', ''), + unknownContact: (name) => name, ); } diff --git a/lib/ui/views/accounts/layouts/components/account_list_item.dart b/lib/ui/views/accounts/layouts/components/account_list_item.dart index 248e87747..5bf721e8c 100644 --- a/lib/ui/views/accounts/layouts/components/account_list_item.dart +++ b/lib/ui/views/accounts/layouts/components/account_list_item.dart @@ -165,7 +165,7 @@ class _AccountListItemState extends ConsumerState if (widget.selectedAccount?.nameDisplayed == widget.account.nameDisplayed) { - Navigator.of(context).pop(); + context.pop(); return; } context.loadingOverlay.show(); diff --git a/lib/ui/views/add_account/layouts/components/add_account_confirm_sheet.dart b/lib/ui/views/add_account/layouts/components/add_account_confirm_sheet.dart index d9b5e06dd..af1441ca1 100755 --- a/lib/ui/views/add_account/layouts/components/add_account_confirm_sheet.dart +++ b/lib/ui/views/add_account/layouts/components/add_account_confirm_sheet.dart @@ -67,7 +67,7 @@ class _AddAccountConfirmState extends ConsumerState icon: Symbols.info, ); context.loadingOverlay.hide(); - Navigator.of(context).pop(); + context.pop(); } Future _showSendSucceed( diff --git a/lib/ui/views/aeswap_liquidity_add/layouts/components/liquidity_add_settings_slippage_tolerance.dart b/lib/ui/views/aeswap_liquidity_add/layouts/components/liquidity_add_settings_slippage_tolerance.dart index c625a0386..aca26c27d 100644 --- a/lib/ui/views/aeswap_liquidity_add/layouts/components/liquidity_add_settings_slippage_tolerance.dart +++ b/lib/ui/views/aeswap_liquidity_add/layouts/components/liquidity_add_settings_slippage_tolerance.dart @@ -11,6 +11,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/localizations.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; class LiquiditySettingsSlippageTolerance extends ConsumerStatefulWidget { const LiquiditySettingsSlippageTolerance({ @@ -155,7 +156,7 @@ class LiquiditySettingsSlippageToleranceState double.tryParse(slippageToleranceController.text) ?? 0, ); if (!context.mounted) return; - Navigator.of(context).pop(); + context.pop(); }, isConnected: true, displayWalletConnectOnPressed: () {}, diff --git a/lib/ui/views/aeswap_swap/layouts/components/swap_settings_slippage_tolerance.dart b/lib/ui/views/aeswap_swap/layouts/components/swap_settings_slippage_tolerance.dart index 57160dffd..d9ff3cac8 100644 --- a/lib/ui/views/aeswap_swap/layouts/components/swap_settings_slippage_tolerance.dart +++ b/lib/ui/views/aeswap_swap/layouts/components/swap_settings_slippage_tolerance.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/localizations.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; class SwapSettingsSlippageTolerance extends ConsumerStatefulWidget { const SwapSettingsSlippageTolerance({ @@ -155,7 +156,7 @@ class SwapSettingsSlippageToleranceState ); if (!context.mounted) return; - Navigator.of(context).pop(); + context.pop(); }, isConnected: true, displayWalletConnectOnPressed: () {}, diff --git a/lib/ui/views/nft_search/layouts/nft_search_bar.dart b/lib/ui/views/nft_search/layouts/nft_search_bar.dart index 826658e9f..9026d18bb 100644 --- a/lib/ui/views/nft_search/layouts/nft_search_bar.dart +++ b/lib/ui/views/nft_search/layouts/nft_search_bar.dart @@ -55,14 +55,10 @@ class _NFTSearchBarState extends ConsumerState { @override Widget build(BuildContext context) { final hasQRCode = ref.watch(DeviceAbilities.hasQRCodeProvider); - final session = ref.watch(sessionNotifierProvider).loggedIn!; final localizations = AppLocalizations.of(context)!; final nftSearchBar = ref.watch( NftSearchBarFormProvider.nftSearchBar, ); - final nftSearchBarNotifier = ref.watch( - NftSearchBarFormProvider.nftSearchBar.notifier, - ); final connectivityStatusProvider = ref.watch(connectivityStatusProviders); ref.listen( NftSearchBarFormProvider.nftSearchBar, @@ -83,7 +79,11 @@ class _NFTSearchBarState extends ConsumerState { }, ); - nftSearchBarNotifier.reset(); + ref + .read( + NftSearchBarFormProvider.nftSearchBar.notifier, + ) + .reset(); return; } @@ -98,7 +98,11 @@ class _NFTSearchBarState extends ConsumerState { duration: const Duration(seconds: 5), ); - nftSearchBarNotifier.setError(''); + ref + .read( + NftSearchBarFormProvider.nftSearchBar.notifier, + ) + .setError(''); }, ); @@ -151,7 +155,11 @@ class _NFTSearchBarState extends ConsumerState { return; } else { final address = Address(address: scanResult); - nftSearchBarNotifier + ref + .read( + NftSearchBarFormProvider + .nftSearchBar.notifier, + ) .setSearchCriteria(address.address!); _updateAdressTextController(); } @@ -167,7 +175,11 @@ class _NFTSearchBarState extends ConsumerState { ), suffixIcon: PasteIcon( onPaste: (String value) { - nftSearchBarNotifier.setSearchCriteria(value); + ref + .read( + NftSearchBarFormProvider.nftSearchBar.notifier, + ) + .setSearchCriteria(value); _updateAdressTextController(); }, ), @@ -205,15 +217,25 @@ class _NFTSearchBarState extends ConsumerState { ConnectivityStatus.isConnected ? null : () async { + final session = + ref.read(sessionNotifierProvider).loggedIn!; final selectedAccount = await session .wallet.appKeychain .getAccountSelected(); - await nftSearchBarNotifier.searchNFT( - searchController.text, - context, - session.wallet.keychainSecuredInfos - .services[selectedAccount!.name]!.keyPair!, - ); + await ref + .read( + NftSearchBarFormProvider + .nftSearchBar.notifier, + ) + .searchNFT( + searchController.text, + context, + session + .wallet + .keychainSecuredInfos + .services[selectedAccount!.name]! + .keyPair!, + ); }, child: Container( height: 30, diff --git a/lib/ui/views/token_selection/layouts/components/token_selection_common_bases.dart b/lib/ui/views/token_selection/layouts/components/token_selection_common_bases.dart index 7c345a3ba..1163fc8c5 100644 --- a/lib/ui/views/token_selection/layouts/components/token_selection_common_bases.dart +++ b/lib/ui/views/token_selection/layouts/components/token_selection_common_bases.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/localizations.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:go_router/go_router.dart'; import 'package:gradient_borders/gradient_borders.dart'; class TokenSelectionCommonBases extends ConsumerWidget { @@ -76,7 +77,7 @@ class _TokenSelector extends StatelessWidget { ), child: InkWell( onTap: () { - Navigator.pop(context, token); + context.pop(token); }, child: Row( children: [ diff --git a/lib/ui/views/transfer/bloc/provider.dart b/lib/ui/views/transfer/bloc/provider.dart index 00cf11c3d..6025b7a2c 100644 --- a/lib/ui/views/transfer/bloc/provider.dart +++ b/lib/ui/views/transfer/bloc/provider.dart @@ -203,18 +203,28 @@ class TransferFormNotifier extends AutoDisposeNotifier { required String text, required archethic.ApiService apiService, }) async { - if (!text.startsWith('@')) { - if (!archethic.Address(address: text).isValid()) { + if (archethic.Address(address: text).isValid()) { + final account = await ref.read( + accountWithGenesisAddressProvider(text).future, + ); + if (account != null) { _setRecipient( - recipient: TransferRecipient.unknownContact( - name: text, + recipient: TransferRecipient.account( + account: account, ), ); - return; + } else { + _setRecipient( + recipient: TransferRecipient.address( + address: archethic.Address(address: text), + ), + ); + await _checkAddressType(context); } - - final account = - await ref.read(accountWithGenesisAddressProvider(text).future); + } else { + final account = await ref.read( + accountWithNameProvider(text).future, + ); if (account != null) { _setRecipient( recipient: TransferRecipient.account( @@ -223,38 +233,15 @@ class TransferFormNotifier extends AutoDisposeNotifier { ); } else { _setRecipient( - recipient: TransferRecipient.address( - address: archethic.Address(address: text), + recipient: TransferRecipient.unknownContact( + name: text, ), ); } - - if (await _checkAddressType(context) == false) { - return; - } - unawaited(_updateFees(context)); - return; } - try { - final account = await ref.read(accountWithNameProvider(text).future); - - _setRecipient( - recipient: TransferRecipient.account( - account: account!, - ), - ); - } catch (e) { - _setRecipient( - recipient: TransferRecipient.unknownContact( - name: text, - ), - ); - } - if (await _checkAddressType(context) == false) { - return; - } unawaited(_updateFees(context)); + return; } void setRecipient({ diff --git a/lib/ui/views/transfer/layouts/components/transfer_textfield_address.dart b/lib/ui/views/transfer/layouts/components/transfer_textfield_address.dart index fb312c984..0e2c57693 100644 --- a/lib/ui/views/transfer/layouts/components/transfer_textfield_address.dart +++ b/lib/ui/views/transfer/layouts/components/transfer_textfield_address.dart @@ -41,11 +41,15 @@ class _TransferTextFieldAddressState void _updateAdressTextController() { final recipient = ref.read(TransferFormProvider.transferForm).recipient; - sendAddressController.text = recipient.when( + final newText = recipient.when( address: (address) => address.address!, - account: (account) => account.format, + account: (account) => account.nameDisplayed, unknownContact: (name) => name, ); + + if (sendAddressController.text != newText) { + sendAddressController.text = newText; + } } @override @@ -53,10 +57,9 @@ class _TransferTextFieldAddressState BuildContext context, ) { final transfer = ref.watch(TransferFormProvider.transferForm); - final transferNotifier = - ref.watch(TransferFormProvider.transferForm.notifier); final hasQRCode = ref.watch(DeviceAbilities.hasQRCodeProvider); - final apiService = ref.watch(apiServiceProvider); + + final localizations = AppLocalizations.of(context)!; if (sendAddressController.text.isNotEmpty) { _updateAdressTextController(); @@ -114,12 +117,17 @@ class _TransferTextFieldAddressState autocorrect: false, controller: sendAddressController, onChanged: (text) async { - await transferNotifier + await ref + .read( + TransferFormProvider + .transferForm.notifier, + ) .setRecipientNameOrAddress( - context: context, - text: text, - apiService: apiService, - ); + context: context, + text: text, + apiService: + ref.read(apiServiceProvider), + ); }, focusNode: sendAddressFocusNode, textInputAction: TextInputAction.next, @@ -177,11 +185,13 @@ class _TransferTextFieldAddressState } else { // Is a URI final address = Address(address: scanResult); - await transferNotifier.setContactAddress( - context: context, - address: address, - apiService: apiService, - ); + await ref + .read(TransferFormProvider.transferForm.notifier) + .setContactAddress( + context: context, + address: address, + apiService: ref.read(apiServiceProvider), + ); _updateAdressTextController(); } }, @@ -189,26 +199,47 @@ class _TransferTextFieldAddressState PasteIcon( onPaste: (String value) { sendAddressController.text = value; - transferNotifier.setRecipientNameOrAddress( - context: context, - text: value, - apiService: apiService, - ); + ref + .read(TransferFormProvider.transferForm.notifier) + .setRecipientNameOrAddress( + context: context, + text: value, + apiService: ref.read(apiServiceProvider), + ); }, ), TextFieldButton( icon: Symbols.contacts, onPressed: () async { - final account = - await AccountsDialog.getDialog(context, ref); - if (account == null) return; + final accounts = + await ref.read(accountsNotifierProvider.future); + final accountSelected = await ref + .read(accountsNotifierProvider.future) + .selectedAccount; + final filteredAccounts = accounts + ..removeWhere( + (element) => + element.format.toUpperCase() == + accountSelected?.format.toUpperCase(), + ); - transferNotifier.setRecipient( + final account = await AccountsDialog.selectSingleAccount( context: context, - contact: TransferRecipient.account(account: account), + accounts: filteredAccounts, + dialogTitle: localizations.accountsHeader, + isModal: true, + heightFactor: 0.5, ); - _updateAdressTextController(); + if (account == null) return; + sendAddressController.text = account.nameDisplayed; + ref + .read(TransferFormProvider.transferForm.notifier) + .setRecipient( + context: context, + contact: + TransferRecipient.account(account: account), + ); }, ), ], diff --git a/lib/ui/views/transfer/layouts/components/transfer_token_detail.dart b/lib/ui/views/transfer/layouts/components/transfer_token_detail.dart index 24c1c2ae8..38dac70d4 100644 --- a/lib/ui/views/transfer/layouts/components/transfer_token_detail.dart +++ b/lib/ui/views/transfer/layouts/components/transfer_token_detail.dart @@ -10,7 +10,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; - +import 'package:go_router/go_router.dart'; import 'package:material_symbols_icons/symbols.dart'; class TransferTokenDetail extends ConsumerStatefulWidget { @@ -45,7 +45,7 @@ class _TransferTokenDetailState extends ConsumerState { padding: const EdgeInsets.only(bottom: 8), child: InkWell( onTap: () async { - Navigator.pop(context, widget.aeToken); + context.pop(widget.aeToken); }, child: aedappfm.BlockInfo( width: MediaQuery.of(context).size.width, diff --git a/lib/ui/views/transfer/layouts/transfer_sheet.dart b/lib/ui/views/transfer/layouts/transfer_sheet.dart index b2d03b472..07d466ef0 100755 --- a/lib/ui/views/transfer/layouts/transfer_sheet.dart +++ b/lib/ui/views/transfer/layouts/transfer_sheet.dart @@ -8,6 +8,7 @@ import 'package:aewallet/model/primary_currency.dart'; import 'package:aewallet/modules/aeswap/domain/models/dex_token.dart'; import 'package:aewallet/ui/themes/archethic_theme.dart'; import 'package:aewallet/ui/themes/styles.dart'; +import 'package:aewallet/ui/util/accounts_dialog.dart'; import 'package:aewallet/ui/util/amount_formatters.dart'; import 'package:aewallet/ui/util/formatters.dart'; import 'package:aewallet/ui/util/ui_util.dart'; @@ -18,7 +19,6 @@ import 'package:aewallet/ui/views/transfer/layouts/components/transfer_form_shee import 'package:aewallet/ui/views/transfer/layouts/components/transfer_token_selection.dart'; import 'package:aewallet/ui/widgets/components/app_text_field.dart'; import 'package:aewallet/ui/widgets/components/paste_icon.dart'; -import 'package:aewallet/ui/widgets/dialogs/accounts_dialog.dart'; import 'package:aewallet/ui/widgets/tokens/verified_token_icon.dart'; import 'package:aewallet/util/account_formatters.dart'; import 'package:aewallet/util/currency_util.dart'; diff --git a/lib/ui/widgets/dialogs/accounts_dialog.dart b/lib/ui/widgets/dialogs/accounts_dialog.dart deleted file mode 100644 index dfd7a4b66..000000000 --- a/lib/ui/widgets/dialogs/accounts_dialog.dart +++ /dev/null @@ -1,172 +0,0 @@ -/// SPDX-License-Identifier: AGPL-3.0-or-later - -import 'dart:ui'; - -import 'package:aewallet/application/account/accounts_notifier.dart'; -import 'package:aewallet/model/data/account.dart'; -import 'package:aewallet/ui/themes/archethic_theme.dart'; -import 'package:aewallet/ui/themes/styles.dart'; -import 'package:aewallet/ui/util/formatters.dart'; -import 'package:aewallet/ui/widgets/components/app_text_field.dart'; -import 'package:aewallet/ui/widgets/components/picker_item.dart'; -import 'package:aewallet/util/account_formatters.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_gen/gen_l10n/localizations.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:go_router/go_router.dart'; - -class AccountsDialog { - static Future getDialog( - BuildContext context, - WidgetRef ref, - ) async { - return showDialog( - context: context, - useRootNavigator: false, - builder: (BuildContext context) { - return AccountsDialogWidget(ref: ref); - }, - ); - } -} - -class AccountsDialogWidget extends StatefulWidget { - const AccountsDialogWidget({super.key, required this.ref}); - final WidgetRef ref; - - @override - AccountsDialogWidgetState createState() => AccountsDialogWidgetState(); -} - -class AccountsDialogWidgetState extends State { - late final FocusNode _searchNameFocusNode; - late final TextEditingController _searchNameController; - - List pickerItemsList = []; - late List accounts; - Account? accountSelected; - - @override - void initState() { - super.initState(); - _searchNameFocusNode = FocusNode(); - _searchNameController = TextEditingController(); - _initializeAccounts(); - } - - Future _initializeAccounts() async { - accounts = await widget.ref.read(accountsNotifierProvider.future); - accountSelected = - await widget.ref.read(accountsNotifierProvider.future).selectedAccount; - _filterAccounts('', accounts, accountSelected); - } - - @override - void dispose() { - _searchNameFocusNode.dispose(); - _searchNameController.dispose(); - super.dispose(); - } - - void _filterAccounts( - String text, - List accounts, - Account? accountSelected, - ) { - final filteredAccounts = accounts - ..removeWhere( - (element) => - element.format.toUpperCase() == - accountSelected?.nameDisplayed.toUpperCase(), - ); - - setState(() { - final matchingAccounts = filteredAccounts.where((account) { - return account.format.toUpperCase().contains(text.toUpperCase()); - }).toList(); - - pickerItemsList - ..clear() - ..addAll( - matchingAccounts.map( - (account) => PickerItem( - account.format, - null, - null, - null, - account, - true, - ), - ), - ); - }); - } - - @override - Widget build(BuildContext context) { - final localizations = AppLocalizations.of(context)!; - - return AlertDialog( - backgroundColor: Colors.transparent, - elevation: 0, - insetPadding: const EdgeInsets.only( - top: 100, - bottom: 100, - ), - alignment: Alignment.topCenter, - content: ClipRRect( - borderRadius: BorderRadius.circular(16), - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), - child: Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: ArchethicTheme.sheetBackground.withOpacity(0.2), - border: Border.all( - color: ArchethicTheme.sheetBorder, - ), - ), - child: Column( - children: [ - Text( - localizations.accountsHeader, - style: ArchethicThemeStyles.textStyleSize24W700Primary, - ), - AppTextField( - focusNode: _searchNameFocusNode, - controller: _searchNameController, - autofocus: true, - autocorrect: false, - labelText: localizations.searchField, - keyboardType: TextInputType.text, - style: ArchethicThemeStyles.textStyleSize16W600Primary, - inputFormatters: [ - UpperCaseTextFormatter(), - LengthLimitingTextInputFormatter(20), - ], - onChanged: (text) { - _filterAccounts(text, accounts, accountSelected); - }, - ), - const SizedBox( - height: 20, - ), - Expanded( - child: SingleChildScrollView( - child: PickerWidget( - pickerItems: pickerItemsList, - onSelected: (value) { - context.pop(value.value); - }, - ), - ), - ), - ], - ), - ), - ), - ), - ); - } -} diff --git a/lib/util/account_formatters.dart b/lib/util/account_formatters.dart index 3827c1e5b..b8c2b9dab 100644 --- a/lib/util/account_formatters.dart +++ b/lib/util/account_formatters.dart @@ -3,10 +3,7 @@ import 'package:aewallet/model/data/account_token.dart'; extension AccountFormatters on Account { String get format { - final decodedName = Uri.decodeFull(name); - return decodedName.length > 1 && decodedName.startsWith('@') - ? decodedName.replaceFirst('@', '') - : decodedName; + return Uri.decodeFull(name); } String get nameDisplayed { diff --git a/pubspec.lock b/pubspec.lock index 6f5ea8f27..cad2d0d91 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -58,26 +58,26 @@ packages: dependency: "direct main" description: name: archethic_dapp_framework_flutter - sha256: "08d8d65ef4ff93ff911187a3afb7208c3a090d5fa711ad859ffe49145db02289" + sha256: "3444edd8a468772bd16f7a079fd72d07c183e40a4f32f837f4dcf482ed56b903" url: "https://pub.dev" source: hosted - version: "3.2.6" + version: "3.2.7" archethic_lib_dart: dependency: transitive description: name: archethic_lib_dart - sha256: "4265dd9010122891a52f3dbdae0bc5b18e9a0fa844c985f706085269a0837e1e" + sha256: "3b00033e9aa6c69f323ca68b044be2d7b7ad5f38063572cace069ff9ded032b1" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "7.1.0" archethic_wallet_client: dependency: "direct main" description: name: archethic_wallet_client - sha256: "9e3471f1b613b56bde7cf7c222a6f8ccc156611f70e8c40525ba5749a874afcc" + sha256: ccf5c210985621b440bee3c3a7f28ed0d9bb0311c999f775e35f529cdffeba09 url: "https://pub.dev" source: hosted - version: "2.1.8" + version: "2.1.9" archive: dependency: transitive description: @@ -692,10 +692,10 @@ packages: dependency: "direct main" description: name: flutter_secure_storage - sha256: "1913841ac4c7bf57cd2e05b717e1fbff7841b542962feff827b16525a781b3e4" + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" url: "https://pub.dev" source: hosted - version: "9.2.3" + version: "9.2.4" flutter_secure_storage_linux: dependency: transitive description: @@ -748,10 +748,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123" + sha256: c200fd79c918a40c5cd50ea0877fa13f81bdaf6f0a5d3dbcc2a13e3285d6aa1b url: "https://pub.dev" source: hosted - version: "2.0.16" + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter @@ -806,10 +806,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: "2fd11229f59e23e967b0775df8d5948a519cd7e1e8b6e849729e010587b46539" + sha256: "7c2d40b59890a929824f30d442e810116caf5088482629c894b9e4478c67472d" url: "https://pub.dev" source: hosted - version: "14.6.2" + version: "14.6.3" gql: dependency: transitive description: @@ -1883,10 +1883,10 @@ packages: dependency: transitive description: name: url_launcher_windows - sha256: "44cf3aabcedde30f2dba119a9dea3b0f2672fbe6fa96e85536251d678216b3c4" + sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "3.1.4" uuid: dependency: "direct main" description: @@ -1915,10 +1915,10 @@ packages: dependency: transitive description: name: vector_graphics_codec - sha256: "2430b973a4ca3c4dbc9999b62b8c719a160100dcbae5c819bae0cacce32c9cdb" + sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" url: "https://pub.dev" source: hosted - version: "1.1.12" + version: "1.1.13" vector_graphics_compiler: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2616757b7..ca6f1d710 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: # Retrieve version and url for local app update against store app Android and iOS app_version_update: ^5.0.2 - archethic_dapp_framework_flutter: ^3.2.6 + archethic_dapp_framework_flutter: ^3.2.7 #archethic_dapp_framework_flutter: ^3.2.6-beta.3 #archethic_dapp_framework_flutter: # git: @@ -22,9 +22,8 @@ dependencies: #archethic_dapp_framework_flutter: # path: ../archethic-dapp-framework-flutter - # RPC datastructures. - archethic_wallet_client: ^2.1.8 - #archethic_wallet_client: ^2.1.8-beta.1 + # AWC + archethic_wallet_client: ^2.1.9 #archethic_wallet_client: # git: # url: https://github.com/archethic-foundation/archethic-wallet-client-dart.git