From 219b42dc615fbaec443e79087c9493729fe4cd66 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Sun, 1 Mar 2026 19:36:01 -0600 Subject: [PATCH 1/2] feat: address label editing to receive page closes #374 --- lib/pages/receive_view/receive_view.dart | 54 ++++++++++++++ .../sub_widgets/desktop_receive.dart | 72 +++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index 61f8ae5fb..c34305337 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -17,6 +17,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar_community/isar.dart'; +import '../../db/isar/main_db.dart'; import '../../models/isar/models/isar_models.dart'; import '../../models/keys/view_only_wallet_data.dart'; import '../../notifications/show_flush_bar.dart'; @@ -46,6 +47,7 @@ import '../../widgets/background.dart'; import '../../widgets/conditional_parent.dart'; import '../../widgets/custom_buttons/app_bar_icon_button.dart'; import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/custom_buttons/simple_edit_button.dart'; import '../../widgets/custom_loading_overlay.dart'; import '../../widgets/desktop/primary_button.dart'; import '../../widgets/desktop/secondary_button.dart'; @@ -792,6 +794,58 @@ class _ReceiveViewState extends ConsumerState { ), ), const SizedBox(height: 12), + Builder( + builder: (context) { + final label = MainDB.instance.getAddressLabelSync( + walletId, + address, + ); + final labelValue = label?.value ?? ""; + return RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + labelValue.isNotEmpty + ? labelValue + : "No label", + style: STextStyles.itemSubtitle(context), + ), + ), + SimpleEditButton( + editValue: labelValue, + editLabel: "label", + overrideTitle: "Edit label", + onValueChanged: (value) { + final existingLabel = + MainDB.instance.getAddressLabelSync( + walletId, + address, + ); + if (existingLabel != null) { + MainDB.instance.putAddressLabel( + existingLabel.copyWith(label: value), + ); + } else { + MainDB.instance.putAddressLabel( + AddressLabel( + walletId: walletId, + addressString: address, + value: value, + tags: null, + ), + ); + } + setState(() {}); + }, + ), + ], + ), + ); + }, + ), + const SizedBox(height: 12), PrimaryButton( label: "Copy address", onPressed: () { diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart index eb354eb1e..285c4ec15 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart @@ -18,6 +18,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar_community/isar.dart'; import 'package:tuple/tuple.dart'; +import '../../../../db/isar/main_db.dart'; import '../../../../models/isar/models/isar_models.dart'; import '../../../../models/keys/view_only_wallet_data.dart'; import '../../../../notifications/show_flush_bar.dart'; @@ -51,6 +52,7 @@ import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart' import '../../../../wallets/wallet/wallet_mixin_interfaces/view_only_option_interface.dart'; import '../../../../widgets/conditional_parent.dart'; import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/simple_edit_button.dart'; import '../../../../widgets/custom_loading_overlay.dart'; import '../../../../widgets/desktop/desktop_dialog.dart'; import '../../../../widgets/desktop/primary_button.dart'; @@ -762,6 +764,76 @@ class _DesktopReceiveState extends ConsumerState { ), ), + const SizedBox(height: 12), + Builder( + builder: (context) { + final label = MainDB.instance.getAddressLabelSync( + walletId, + address, + ); + final labelValue = label?.value ?? ""; + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Theme.of( + context, + ).extension()!.backgroundAppBar, + width: 1, + ), + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + child: RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + labelValue.isNotEmpty ? labelValue : "No label", + style: STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ).extension()!.textDark, + ), + ), + ), + SimpleEditButton( + editValue: labelValue, + editLabel: "label", + overrideTitle: "Edit label", + onValueChanged: (value) { + final existingLabel = + MainDB.instance.getAddressLabelSync( + walletId, + address, + ); + if (existingLabel != null) { + MainDB.instance.putAddressLabel( + existingLabel.copyWith(label: value), + ); + } else { + MainDB.instance.putAddressLabel( + AddressLabel( + walletId: walletId, + addressString: address, + value: value, + tags: null, + ), + ); + } + setState(() {}); + }, + ), + ], + ), + ), + ); + }, + ), + if (canGen) const SizedBox(height: 20), if (canGen) From 6596a01c80a14da2a2cab0e152bc04b38ac8efcf Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 28 May 2026 11:49:58 -0500 Subject: [PATCH 2/2] chore: dart format --- lib/pages/receive_view/receive_view.dart | 10 ++--- .../sub_widgets/desktop_receive.dart | 39 ++++++++++--------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index c34305337..26ce3a193 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -163,8 +163,7 @@ class _ReceiveViewState extends ConsumerState { if (slatepackString == null) return; if (mounted) { - final wallet = - ref.read(pWallets).getWallet(walletId) as EpiccashWallet; + final wallet = ref.read(pWallets).getWallet(walletId) as EpiccashWallet; Exception? ex; final result = await showLoading( @@ -818,11 +817,8 @@ class _ReceiveViewState extends ConsumerState { editLabel: "label", overrideTitle: "Edit label", onValueChanged: (value) { - final existingLabel = - MainDB.instance.getAddressLabelSync( - walletId, - address, - ); + final existingLabel = MainDB.instance + .getAddressLabelSync(walletId, address); if (existingLabel != null) { MainDB.instance.putAddressLabel( existingLabel.copyWith(label: value), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart index 285c4ec15..5b47ea47f 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart @@ -176,8 +176,7 @@ class _DesktopReceiveState extends ConsumerState { } Future _onEpicReceiveSlatePressed() async { - final wallet = - ref.read(pWallets).getWallet(walletId) as EpiccashWallet; + final wallet = ref.read(pWallets).getWallet(walletId) as EpiccashWallet; Exception? ex; final result = await showLoading( @@ -607,9 +606,11 @@ class _DesktopReceiveState extends ConsumerState { ), ), ), - if (!((isMimblewimblecoin || isEpiccash) && ref.watch(pIsSlatepack(widget.walletId)))) + if (!((isMimblewimblecoin || isEpiccash) && + ref.watch(pIsSlatepack(widget.walletId)))) const SizedBox(height: 20), - if (!((isMimblewimblecoin || isEpiccash) && ref.watch(pIsSlatepack(widget.walletId)))) + if (!((isMimblewimblecoin || isEpiccash) && + ref.watch(pIsSlatepack(widget.walletId)))) ConditionalParent( condition: showMultiType, builder: (child) => Column( @@ -791,13 +792,12 @@ class _DesktopReceiveState extends ConsumerState { Expanded( child: Text( labelValue.isNotEmpty ? labelValue : "No label", - style: STextStyles.desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of( - context, - ).extension()!.textDark, - ), + style: STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of( + context, + ).extension()!.textDark, + ), ), ), SimpleEditButton( @@ -805,11 +805,8 @@ class _DesktopReceiveState extends ConsumerState { editLabel: "label", overrideTitle: "Edit label", onValueChanged: (value) { - final existingLabel = - MainDB.instance.getAddressLabelSync( - walletId, - address, - ); + final existingLabel = MainDB.instance + .getAddressLabelSync(walletId, address); if (existingLabel != null) { MainDB.instance.putAddressLabel( existingLabel.copyWith(label: value), @@ -850,7 +847,8 @@ class _DesktopReceiveState extends ConsumerState { label: "Generate new address", ), const SizedBox(height: 20), - if ((isMimblewimblecoin || isEpiccash) && ref.watch(pIsSlatepack(widget.walletId))) + if ((isMimblewimblecoin || isEpiccash) && + ref.watch(pIsSlatepack(widget.walletId))) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -981,7 +979,8 @@ class _DesktopReceiveState extends ConsumerState { // TODO: create transparent button class to account for hover // Conditional logic for 'Submit' button or QR code - if ((isMimblewimblecoin || isEpiccash) && ref.watch(pIsSlatepack(widget.walletId))) + if ((isMimblewimblecoin || isEpiccash) && + ref.watch(pIsSlatepack(widget.walletId))) Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: PrimaryButton( @@ -989,7 +988,9 @@ class _DesktopReceiveState extends ConsumerState { label: "Receive Slatepack", enabled: _slateToggleFlag, onPressed: _slateToggleFlag - ? (isEpiccash ? _onEpicReceiveSlatePressed : _onReceiveSlatePressed) + ? (isEpiccash + ? _onEpicReceiveSlatePressed + : _onReceiveSlatePressed) : null, ), )