From f54c9dc82206d18f0c38088fd3d57850a2886c00 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Fri, 20 Sep 2024 09:45:57 +0200 Subject: [PATCH 1/2] feat(style): redesign receive tx screen --- lib/l10n/app_en.arb | 7 +- lib/l10n/app_es.arb | 7 +- lib/screens/login/view/init_screen.dart | 2 +- .../address_list_view.dart | 56 ++++++ .../receive_tx_screen.dart | 189 +++++++++++------- lib/util/storage/database/wallet.dart | 2 +- lib/widgets/PaddedButton.dart | 3 +- lib/widgets/address_item.dart | 151 ++++++++++++++ lib/widgets/address_list.dart | 174 +--------------- lib/widgets/speed_up_tx.dart | 2 +- .../modals/new_address_modal.dart | 42 ++++ 11 files changed, 393 insertions(+), 242 deletions(-) create mode 100644 lib/screens/receive_transaction/address_list_view.dart create mode 100644 lib/widgets/address_item.dart create mode 100644 lib/widgets/witnet/transactions/value_transfer/modals/new_address_modal.dart diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 094aef896..18ac8b846 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -89,6 +89,7 @@ }, "addTimelockLabel": "Add Timelock (Optional)", "address": "Address", + "addressList": "Address list", "addressCopied": "Address copied!", "advancedSettings": "Advanced Settings", "amount": "Amount", @@ -179,6 +180,8 @@ "feesPayed": "Fees payed", "forgetPassword": "Did you forget your password?, You can delete your wallet and configure a new one!", "from": "from", + "generateAddressWarning": "You are about to generate a new address", + "generateAddressWarningMessage": "A new address will be generated and ready to be used. The main address displayed in the navigation will be updated to the new one.", "genNewAddressLabel": "Generate new Address", "generateMnemonic01": "These {mnemonicLength} apparently random words are your secret recovery phrase. They will allow you to recover your Wit coins if you uninstall this app or forget your wallet lock password.", "generateMnemonic02": "You must write down your secret recovery phrase on a piece of paper and store it somewhere safe. Do not store it in a file in your device or anywhere else electronically. If you lose your secret recovery phrase, you may permanently lose access to your wallet and your Wit coins.", @@ -338,5 +341,7 @@ "withdrawalAddress": "Withdrawal address", "xprvInputHint": "Your Xprv key (starts with xprv...)", "xprvOrigin": "Xprv Origin", - "yourMessage": "Your message..." + "yourMessage": "Your message...", + "addressBalanceDescription": "Received payments totalling", + "loading": "Loading" } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 940e64fa4..df26a6897 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -89,6 +89,7 @@ }, "addTimelockLabel": "Añadir Timelock (Opcional)", "address": "Dirección", + "addressList": "Lista de direcciones", "addressCopied": "¡Dirección copiada!", "advancedSettings": "Configuración avanzada", "amount": "Cantidad", @@ -179,6 +180,8 @@ "feesPayed": "Comisiones pagadas", "forgetPassword": "¿Has olvidado tu contraseña?, ¡Puedes borrar tu monedero y configurar uno nuevo!", "from": "de", + "generateAddressWarning": "Estás a punto de generar una nueva dirección", + "generateAddressWarningMessage": "Una nueva dirección estará disponible para su uso. La dirección mostrada en la barra de navegación se actualizará a la nueva dirección generada.", "genNewAddressLabel": "Generar nueva dirección", "generateMnemonic01": "Estas {mnemonicLength} palabras aparentemente aleatorias son tu frase de recuperación secreta. Te permitirán recuperar tus monedas Wit si desinstalas esta aplicación o olvidas la contraseña de bloqueo de tu cartera.", "generateMnemonic02": "Debes escribir tu frase de recuperación secreta en un papel y almacenarla en un lugar seguro. No la almacenes en un archivo en tu dispositivo ni en ningún otro lugar electrónico. Si pierdes tu frase de recuperación secreta, podrías perder permanentemente el acceso a tu cartera y tus monedas Wit.", @@ -338,5 +341,7 @@ "withdrawalAddress": "Withdrawal address", "xprvInputHint": "Tu clave Xprv (comienza con xprv...)", "xprvOrigin": "Origen de Xprv", - "yourMessage": "Tu mensaje..." + "yourMessage": "Tu mensaje...", + "addressBalanceDescription": "Recibió pagos por un total de", + "loading": "Cargando" } \ No newline at end of file diff --git a/lib/screens/login/view/init_screen.dart b/lib/screens/login/view/init_screen.dart index 56fccf4a5..cae530276 100644 --- a/lib/screens/login/view/init_screen.dart +++ b/lib/screens/login/view/init_screen.dart @@ -84,7 +84,7 @@ class InitScreenState extends State with TickerProviderStateMixin { color: extendedTheme.spinnerColor, strokeWidth: 2, value: null, - semanticsLabel: 'Circular progress indicator', + semanticsLabel: localization.loading, )) ], actions: [], diff --git a/lib/screens/receive_transaction/address_list_view.dart b/lib/screens/receive_transaction/address_list_view.dart new file mode 100644 index 000000000..642fed4ef --- /dev/null +++ b/lib/screens/receive_transaction/address_list_view.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:my_wit_wallet/util/get_localization.dart'; +import 'package:my_wit_wallet/screens/dashboard/bloc/dashboard_bloc.dart'; +import 'package:my_wit_wallet/util/storage/database/wallet.dart'; +import 'package:my_wit_wallet/widgets/address_list.dart'; +import 'package:my_wit_wallet/widgets/closable_view.dart'; + +typedef void VoidCallback(); + +class AddressListView extends StatefulWidget { + final ScrollController scrollController; + final VoidCallback close; + final Wallet currentWallet; + + AddressListView( + {Key? key, + required this.scrollController, + required this.close, + required this.currentWallet}) + : super(key: key); + @override + State createState() => AddressListViewState(); +} + +class AddressListViewState extends State { + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return BlocBuilder( + builder: (previous, current) { + return ClosableView(closeSetting: widget.close, children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + localization.generatedAddresses, + style: theme.textTheme.displaySmall, + textAlign: TextAlign.start, + ), + ], + ), + SizedBox(height: 16), + AddressList( + currentWallet: widget.currentWallet, + ), + ]); + }, + ); + } +} diff --git a/lib/screens/receive_transaction/receive_tx_screen.dart b/lib/screens/receive_transaction/receive_tx_screen.dart index 5578d72f2..4aaa90e75 100644 --- a/lib/screens/receive_transaction/receive_tx_screen.dart +++ b/lib/screens/receive_transaction/receive_tx_screen.dart @@ -2,12 +2,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:my_wit_wallet/theme/extended_theme.dart'; +import 'package:my_wit_wallet/screens/receive_transaction/address_list_view.dart'; import 'package:my_wit_wallet/util/get_localization.dart'; import 'package:my_wit_wallet/bloc/explorer/explorer_bloc.dart'; import 'package:my_wit_wallet/shared/api_database.dart'; import 'package:my_wit_wallet/theme/colors.dart'; import 'package:my_wit_wallet/widgets/PaddedButton.dart'; -import 'package:my_wit_wallet/widgets/address_list.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:my_wit_wallet/widgets/dashed_rect.dart'; import 'package:my_wit_wallet/widgets/qr/qr_address_generator.dart'; import 'package:my_wit_wallet/util/storage/database/wallet.dart'; @@ -19,6 +20,7 @@ import 'package:my_wit_wallet/shared/locator.dart'; import 'package:my_wit_wallet/util/preferences.dart'; import 'package:my_wit_wallet/util/storage/database/account.dart'; import 'package:my_wit_wallet/widgets/snack_bars.dart'; +import 'package:my_wit_wallet/widgets/witnet/transactions/value_transfer/modals/new_address_modal.dart'; class ReceiveTransactionScreen extends StatefulWidget { static final route = '/receive-transaction'; @@ -33,6 +35,11 @@ class ReceiveTransactionScreenState extends State late AnimationController _loadingController; bool isLoading = false; bool enableButton = true; + bool showAddressList = false; + ScrollController scrollController = ScrollController(keepScrollOffset: false); + ApiDatabase db = Locator.instance.get(); + Wallet get currentWallet => db.walletStorage.currentWallet; + bool get isHdWallet => currentWallet.walletType == WalletType.hd; @override void initState() { @@ -53,6 +60,18 @@ class ReceiveTransactionScreenState extends State super.dispose(); } + void _showAddressList() { + setState(() { + showAddressList = true; + }); + } + + void _hideAddressList() { + setState(() { + showAddressList = false; + }); + } + List _actions() { final theme = Theme.of(context); return [ @@ -71,57 +90,87 @@ class ReceiveTransactionScreenState extends State theme, localization.copyAddressConfirmed)); } }), - BlocListener( - listener: (BuildContext context, ExplorerState state) {}, - child: - BlocBuilder(builder: (context, state) { - ApiDatabase db = Locator.instance.get(); - Wallet currentWallet = db.walletStorage.currentWallet; - bool isHdWallet = currentWallet.walletType == WalletType.hd; - if (isHdWallet) { - return PaddedButton( - onPressed: () async { - ApiDatabase db = Locator.instance.get(); - - Wallet currentWallet = db.walletStorage.currentWallet; - int extAccountsLength = currentWallet.externalAccounts.length; - Account ac = - await Locator.instance.get().generateAccount( - currentWallet, - KeyType.external, - extAccountsLength, - ); - setState(() { - currentWallet.externalAccounts[extAccountsLength] = ac; - }); - await db.addAccount(ac); - await db.loadWalletsDatabase(); - await ApiPreferences.setCurrentAddress(AddressEntry( - walletId: ac.walletId, - addressIdx: int.parse(ac.path.split('/').last), - keyType: '0', - )); - BlocProvider.of(context) - .add(DashboardUpdateWalletEvent( - currentWallet: currentWallet, - currentAddress: ac.address, - )); - BlocProvider.of(context) - .add(SyncSingleAccountEvent(ExplorerStatus.singleSync, ac)); - }, - padding: EdgeInsets.only(top: 8), - text: localization.genNewAddressLabel, + SizedBox(height: 8), + isHdWallet + ? PaddedButton( + padding: EdgeInsets.zero, + text: localization.addressList, type: ButtonType.secondary, - enabled: state.status != ExplorerStatus.singleSync, - ); - } else { - return Container(); - } - }), - ), + enabled: enableButton, + isLoading: isLoading, + onPressed: _showAddressList) + : Container(), ]; } + void _generateNewAddress() async { + ApiDatabase db = Locator.instance.get(); + Wallet currentWallet = db.walletStorage.currentWallet; + int extAccountsLength = currentWallet.externalAccounts.length; + Account ac = await Locator.instance.get().generateAccount( + currentWallet, + KeyType.external, + extAccountsLength, + ); + setState(() { + currentWallet.externalAccounts[extAccountsLength] = ac; + }); + await db.addAccount(ac); + await db.loadWalletsDatabase(); + await ApiPreferences.setCurrentAddress(AddressEntry( + walletId: ac.walletId, + addressIdx: int.parse(ac.path.split('/').last), + keyType: '0', + )); + BlocProvider.of(context).add(DashboardUpdateWalletEvent( + currentWallet: currentWallet, + currentAddress: ac.address, + )); + BlocProvider.of(context) + .add(SyncSingleAccountEvent(ExplorerStatus.singleSync, ac)); + } + + void _showNewAddressModal() { + final theme = Theme.of(context); + buildNewAddressModal( + theme: theme, + onAction: () => { + _generateNewAddress(), + Navigator.popUntil( + context, ModalRoute.withName(ReceiveTransactionScreen.route)), + ScaffoldMessenger.of(context).clearSnackBars(), + }, + context: context, + originRouteName: ReceiveTransactionScreen.route, + originRoute: ReceiveTransactionScreen()); + } + + Widget _buildGenerateNewAddressBtn() { + return BlocListener( + listener: (BuildContext context, ExplorerState state) {}, + child: + BlocBuilder(builder: (context, state) { + if (isHdWallet) { + return PaddedButton( + onPressed: _showNewAddressModal, + padding: EdgeInsets.only(top: 8), + text: localization.genNewAddressLabel, + label: localization.genNewAddressLabel, + type: ButtonType.iconButton, + iconSize: 20, + icon: Icon( + FontAwesomeIcons.arrowsRotate, + size: 20, + ), + enabled: state.status != ExplorerStatus.singleSync, + ); + } else { + return Container(); + } + }), + ); + } + _setCurrentWallet(Wallet? currentWallet, Account currentAccount) { setState(() { selectedAccount = currentAccount; @@ -130,17 +179,23 @@ class ReceiveTransactionScreenState extends State Widget _buildReceiveTransactionScreen() { final theme = Theme.of(context); - ApiDatabase db = Locator.instance.get(); final extendedTheme = theme.extension()!; return Padding( padding: EdgeInsets.only(left: 8, right: 8), child: Column( children: [ - QrAddressGenerator( - data: selectedAccount!.address, - ), - SizedBox(height: 24), + Stack(children: [ + Padding( + padding: EdgeInsets.only(top: 24, right: 40, left: 40), + child: QrAddressGenerator( + data: selectedAccount!.address, + ), + ), + Positioned( + right: 0, top: 0, child: _buildGenerateNewAddressBtn()), + ]), + SizedBox(height: 16), DashedRect( color: WitnetPallet.brightCyan, textStyle: extendedTheme.monoLargeText, @@ -150,25 +205,19 @@ class ReceiveTransactionScreenState extends State ), SizedBox(height: 24), ..._actions(), - SizedBox(height: 16), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - localization.generatedAddresses, - style: theme.textTheme.titleLarge, - textAlign: TextAlign.start, - ), - ], - ), - SizedBox(height: 8), - AddressList( - currentWallet: db.walletStorage.currentWallet, - ), + SizedBox(height: 24), ], )); } + Widget _buildAddressList() { + ApiDatabase db = Locator.instance.get(); + return AddressListView( + scrollController: scrollController, + currentWallet: db.walletStorage.currentWallet, + close: _hideAddressList); + } + BlocListener _dashboardBlocListener() { return BlocListener( listener: (BuildContext context, DashboardState state) { @@ -185,7 +234,9 @@ class ReceiveTransactionScreenState extends State return BlocBuilder( builder: (BuildContext context, DashboardState state) { return DashboardLayout( - dashboardChild: _buildReceiveTransactionScreen(), + dashboardChild: showAddressList + ? _buildAddressList() + : _buildReceiveTransactionScreen(), actions: [], ); }, diff --git a/lib/util/storage/database/wallet.dart b/lib/util/storage/database/wallet.dart index adb858243..5e2ecd215 100644 --- a/lib/util/storage/database/wallet.dart +++ b/lib/util/storage/database/wallet.dart @@ -118,7 +118,7 @@ class Wallet { Map orderAccountsByIndex(Map accountMap) { return Map.fromEntries(accountMap.entries.toList() - ..sort((e1, e2) => e1.key.compareTo(e2.key))); + ..sort((e1, e2) => e2.key.compareTo(e1.key))); } List addressList(KeyType keyType) { diff --git a/lib/widgets/PaddedButton.dart b/lib/widgets/PaddedButton.dart index fd65f15ec..b2ceb1766 100644 --- a/lib/widgets/PaddedButton.dart +++ b/lib/widgets/PaddedButton.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:my_wit_wallet/theme/colors.dart'; import 'package:my_wit_wallet/theme/extended_theme.dart'; +import 'package:my_wit_wallet/util/get_localization.dart'; const defaultIcon = Icon(null); @@ -27,7 +28,7 @@ Widget buildCircularProgress(context, ThemeData theme) { color: theme.colorScheme.surface, strokeWidth: 2, value: null, - semanticsLabel: 'Circular progress indicator', + semanticsLabel: localization.loading, )); } diff --git a/lib/widgets/address_item.dart b/lib/widgets/address_item.dart new file mode 100644 index 000000000..ed5f7a814 --- /dev/null +++ b/lib/widgets/address_item.dart @@ -0,0 +1,151 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:my_wit_wallet/bloc/explorer/explorer_bloc.dart'; +import 'package:my_wit_wallet/constants.dart'; +import 'package:my_wit_wallet/theme/colors.dart'; +import 'package:my_wit_wallet/theme/extended_theme.dart'; +import 'package:my_wit_wallet/util/get_localization.dart'; +import 'package:my_wit_wallet/util/storage/database/account.dart'; +import 'package:my_wit_wallet/widgets/PaddedButton.dart'; +import 'package:my_wit_wallet/util/extensions/string_extensions.dart'; +import 'package:my_wit_wallet/widgets/snack_bars.dart'; +import 'package:my_wit_wallet/util/extensions/num_extensions.dart'; + +class AddreessItem extends StatefulWidget { + final bool isLastItem; + final Account account; + final String? currentAddress; + const AddreessItem( + {Key? key, + required this.isLastItem, + required this.account, + required this.currentAddress}) + : super(key: key); + + @override + State createState() => AddreessItemState(); +} + +class AddreessItemState extends State + with WidgetsBindingObserver { + bool isAddressCopied = false; + bool isAddressSelected = false; + + @override + void initState() { + super.initState(); + isAddressSelected = widget.account.address == widget.currentAddress; + } + + _syncSpinnerOrBalanceDisplay(Account account, ThemeData theme) { + return BlocBuilder( + builder: (BuildContext context, ExplorerState state) { + if (state.status == ExplorerStatus.singleSync && + state.data['address'] == account.address) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + height: 16, + width: 16, + child: CircularProgressIndicator( + color: theme.textTheme.labelMedium?.color, + strokeWidth: 2, + value: null, + semanticsLabel: localization.loading, + )) + ], + ); + } else { + return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(localization.addressBalanceDescription, + textAlign: TextAlign.start, style: theme.textTheme.bodySmall), + SizedBox(height: 4), + Text( + '${account.balance.availableNanoWit.standardizeWitUnits().formatWithCommaSeparator()} ${WIT_UNIT[WitUnit.Wit]}', + textAlign: TextAlign.start, + style: theme.textTheme.bodySmall), + ]); + } + }); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + ExtendedTheme extendedTheme = theme.extension()!; + final textStyle = isAddressSelected + ? extendedTheme.monoMediumText + : extendedTheme.monoRegularText; + return Container( + decoration: BoxDecoration( + color: WitnetPallet.transparent, + border: !widget.isLastItem + ? Border( + bottom: BorderSide( + color: extendedTheme.txBorderColor!, + width: 1, + )) + : null, + ), + child: Padding( + padding: EdgeInsets.only(top: 16, bottom: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.account.address.cropMiddle(33), + overflow: TextOverflow.ellipsis, + style: textStyle, + ), + SizedBox(height: 8), + _syncSpinnerOrBalanceDisplay(widget.account, theme), + ])), + PaddedButton( + padding: EdgeInsets.zero, + label: localization.copyAddressToClipboard, + text: localization.copyAddressToClipboard, + type: ButtonType.iconButton, + iconSize: 12, + onPressed: () async { + if (!isAddressCopied) { + await Clipboard.setData( + ClipboardData(text: widget.account.address)); + if (await Clipboard.hasStrings()) { + ScaffoldMessenger.of(context).clearSnackBars(); + ScaffoldMessenger.of(context).showSnackBar( + buildCopiedSnackbar(theme, localization.addressCopied)); + setState(() { + isAddressCopied = true; + }); + if (this.mounted) { + Timer(Duration(milliseconds: 500), () { + setState(() { + isAddressCopied = false; + }); + }); + } + } + } + }, + icon: Icon( + isAddressCopied + ? FontAwesomeIcons.check + : FontAwesomeIcons.copy, + size: 12, + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/widgets/address_list.dart b/lib/widgets/address_list.dart index edfdaaa9b..083052bd2 100644 --- a/lib/widgets/address_list.dart +++ b/lib/widgets/address_list.dart @@ -1,19 +1,11 @@ -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:my_wit_wallet/bloc/explorer/explorer_bloc.dart'; -import 'package:my_wit_wallet/constants.dart'; import 'package:my_wit_wallet/screens/dashboard/bloc/dashboard_bloc.dart'; import 'package:my_wit_wallet/shared/api_database.dart'; -import 'package:my_wit_wallet/theme/colors.dart'; -import 'package:my_wit_wallet/theme/extended_theme.dart'; -import 'package:my_wit_wallet/util/extensions/string_extensions.dart'; -import 'package:my_wit_wallet/util/preferences.dart'; import 'package:my_wit_wallet/util/storage/database/wallet.dart'; -import 'package:my_wit_wallet/util/extensions/num_extensions.dart'; -import 'package:my_wit_wallet/util/get_localization.dart'; import 'package:my_wit_wallet/shared/locator.dart'; import 'package:my_wit_wallet/util/storage/database/account.dart'; +import 'package:my_wit_wallet/widgets/address_item.dart'; class AddressList extends StatefulWidget { final Wallet currentWallet; @@ -41,153 +33,6 @@ class AddressListState extends State { super.dispose(); } - _syncSpinnerOrBalanceDisplay(Account account, ThemeData theme) { - ExtendedTheme extendedTheme = theme.extension()!; - final isAddressSelected = account.address == currentAddress; - final textStyle = isAddressSelected - ? extendedTheme.monoBoldText - : extendedTheme.monoRegularText; - return BlocBuilder( - builder: (BuildContext context, ExplorerState state) { - if (state.status == ExplorerStatus.singleSync && - state.data['address'] == account.address) { - return Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - height: 16, - width: 16, - child: CircularProgressIndicator( - color: extendedTheme.spinnerColor, - strokeWidth: 2, - value: null, - semanticsLabel: 'Circular progress indicator', - )) - ], - ); - } else { - return Text( - '${account.balance.availableNanoWit.standardizeWitUnits().formatWithCommaSeparator()} ${WIT_UNIT[WitUnit.Wit]}', - textAlign: TextAlign.end, - overflow: TextOverflow.ellipsis, - style: textStyle!.copyWith(fontFamily: 'Almarai')); - } - }); - } - - Widget _buildAddressItem( - {required Account account, - required ThemeData theme, - bool isLastItem = false}) { - ExtendedTheme extendedTheme = theme.extension()!; - final isAddressSelected = account.address == currentAddress; - final textStyle = isAddressSelected - ? extendedTheme.monoBoldText - : extendedTheme.monoRegularText; - return Semantics( - button: true, - enabled: true, - label: localization.generatedAddress, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - child: Container( - decoration: BoxDecoration( - color: WitnetPallet.transparent, - border: !isLastItem - ? Border( - bottom: BorderSide( - color: extendedTheme.txBorderColor!, - width: 1, - )) - : null, - ), - child: Padding( - padding: EdgeInsets.all(16), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.only(right: 8), - child: Text( - account.address.cropMiddle(18), - style: textStyle, - ), - ), - Expanded( - child: _syncSpinnerOrBalanceDisplay(account, theme), - ), - ], - ), - ), - ), - onTap: () async { - String _keytype = ''; - if (account.keyType == KeyType.master) { - _keytype = 'm'; - } else { - _keytype = account.keyType == KeyType.internal ? '1' : '0'; - } - await ApiPreferences.setCurrentAddress(AddressEntry( - walletId: widget.currentWallet.id, - addressIdx: account.keyType == KeyType.master - ? null - : account.index, - keyType: _keytype, - )); - BlocProvider.of(context) - .add(DashboardUpdateWalletEvent( - currentWallet: widget.currentWallet, - currentAddress: account.address, - )); - }))); - } - - Widget _internalAccountsBalance(ThemeData theme) { - ExtendedTheme extendedTheme = theme.extension()!; - int internalBalance = 0; - List internalAccounts = - widget.currentWallet.internalAccounts.values.toList(); - internalAccounts.forEach( - (account) => internalBalance += account.balance.availableNanoWit); - return Container( - child: Padding( - padding: EdgeInsets.only(top: 16, left: 16, right: 16, bottom: 80), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - localization.internalBalance, - style: theme.textTheme.titleMedium, - textAlign: TextAlign.start, - ), - SizedBox( - width: 4, - ), - Tooltip( - height: 60, - message: localization.internalBalanceHint, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: Icon(FontAwesomeIcons.circleQuestion, - size: 12, - color: extendedTheme.inputIconColor))), - ]), - Expanded( - child: Text( - '${internalBalance.standardizeWitUnits().formatWithCommaSeparator()} ${WIT_UNIT[WitUnit.Wit]}', - textAlign: TextAlign.end, - style: extendedTheme.monoRegularText! - .copyWith(fontFamily: 'Almarai'), - ), - ), - ]))); - } - BlocListener _dashboardBlocListener() { return BlocListener( listener: (BuildContext context, DashboardState state) { @@ -205,7 +50,6 @@ class AddressListState extends State { } BlocBuilder _dashboardBlocBuilder() { - final theme = Theme.of(context); List externalAccounts = widget.currentWallet.orderedExternalAccounts().values.toList(); return BlocBuilder( @@ -219,20 +63,16 @@ class AddressListState extends State { physics: NeverScrollableScrollPhysics(), itemCount: externalAccounts.length, itemBuilder: (context, index) { - return _buildAddressItem( + return AddreessItem( account: externalAccounts[index], - theme: theme, - isLastItem: (externalAccounts.length - 1) == index); + isLastItem: (externalAccounts.length - 1) == index, + currentAddress: currentAddress); }, ) - : _buildAddressItem( + : AddreessItem( account: widget.currentWallet.masterAccount!, - theme: theme, - isLastItem: true), - SizedBox(height: 16), - widget.currentWallet.walletType == WalletType.hd - ? _internalAccountsBalance(theme) - : Container(), + isLastItem: true, + currentAddress: currentAddress) ], ); }, diff --git a/lib/widgets/speed_up_tx.dart b/lib/widgets/speed_up_tx.dart index 9299ddd09..18ba6b388 100644 --- a/lib/widgets/speed_up_tx.dart +++ b/lib/widgets/speed_up_tx.dart @@ -123,7 +123,7 @@ class SpeedUpVttState extends State { color: extendedTheme.spinnerColor, strokeWidth: 2, value: null, - semanticsLabel: 'Circular progress indicator', + semanticsLabel: localization.loading, )), SizedBox( height: 24, diff --git a/lib/widgets/witnet/transactions/value_transfer/modals/new_address_modal.dart b/lib/widgets/witnet/transactions/value_transfer/modals/new_address_modal.dart new file mode 100644 index 000000000..359bbf7ad --- /dev/null +++ b/lib/widgets/witnet/transactions/value_transfer/modals/new_address_modal.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; +import 'package:my_wit_wallet/util/get_localization.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:my_wit_wallet/widgets/PaddedButton.dart'; +import 'package:my_wit_wallet/widgets/alert_dialog.dart'; + +void buildNewAddressModal({ + required ThemeData theme, + required BuildContext context, + required String originRouteName, + required Widget originRoute, + required VoidCallback onAction, + String iconName = 'general-warning', +}) { + return buildAlertDialog( + context: context, + actions: [ + PaddedButton( + padding: EdgeInsets.all(8), + text: localization.cancel, + type: ButtonType.text, + enabled: true, + onPressed: () => { + Navigator.popUntil( + context, ModalRoute.withName(originRouteName)), + ScaffoldMessenger.of(context).clearSnackBars(), + }), + PaddedButton( + padding: EdgeInsets.all(8), + text: localization.confirm, + type: ButtonType.text, + enabled: true, + onPressed: onAction), + ], + icon: FontAwesomeIcons.circleExclamation, + title: localization.generateAddressWarning, + content: Column(mainAxisSize: MainAxisSize.min, children: [ + Text(localization.generateAddressWarningMessage, + style: theme.textTheme.bodyLarge), + SizedBox(height: 16), + ])); +} From 29b69dbba4481daf077d7bec4d28dcdb16763c45 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Tue, 22 Oct 2024 18:51:06 +0200 Subject: [PATCH 2/2] fix: update fonts --- lib/screens/receive_transaction/address_list_view.dart | 2 +- lib/widgets/address_item.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/screens/receive_transaction/address_list_view.dart b/lib/screens/receive_transaction/address_list_view.dart index 642fed4ef..d8fd6f83e 100644 --- a/lib/screens/receive_transaction/address_list_view.dart +++ b/lib/screens/receive_transaction/address_list_view.dart @@ -40,7 +40,7 @@ class AddressListViewState extends State { children: [ Text( localization.generatedAddresses, - style: theme.textTheme.displaySmall, + style: theme.textTheme.titleLarge, textAlign: TextAlign.start, ), ], diff --git a/lib/widgets/address_item.dart b/lib/widgets/address_item.dart index ed5f7a814..4b072d4dd 100644 --- a/lib/widgets/address_item.dart +++ b/lib/widgets/address_item.dart @@ -79,7 +79,7 @@ class AddreessItemState extends State final theme = Theme.of(context); ExtendedTheme extendedTheme = theme.extension()!; final textStyle = isAddressSelected - ? extendedTheme.monoMediumText + ? extendedTheme.monoBoldText : extendedTheme.monoRegularText; return Container( decoration: BoxDecoration(