diff --git a/lib/pages/coin_control/utxo_card.dart b/lib/pages/coin_control/utxo_card.dart index f9277cb7f..1f7412db1 100644 --- a/lib/pages/coin_control/utxo_card.dart +++ b/lib/pages/coin_control/utxo_card.dart @@ -53,6 +53,10 @@ class _UtxoCardState extends ConsumerState { .addressStringWalletIdEqualTo(utxo.address!, widget.walletId) .findFirstSync() ?.value; + + if (label != null && label.isEmpty) { + label = null; + } } return RoundedWhiteContainer( diff --git a/lib/pages/receive_view/addresses/receiving_addresses_view.dart b/lib/pages/receive_view/addresses/receiving_addresses_view.dart index ac817bedf..50dbd6d21 100644 --- a/lib/pages/receive_view/addresses/receiving_addresses_view.dart +++ b/lib/pages/receive_view/addresses/receiving_addresses_view.dart @@ -5,32 +5,40 @@ import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/pages/receive_view/addresses/address_card.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; +import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/toggle.dart'; -class ReceivingAddressesView extends ConsumerWidget { - const ReceivingAddressesView({ +class WalletAddressesView extends ConsumerStatefulWidget { + const WalletAddressesView({ Key? key, required this.walletId, - required this.isDesktop, - this.clipboard = const ClipboardWrapper(), }) : super(key: key); - static const String routeName = "/receivingAddressesView"; + static const String routeName = "/walletAddressesView"; final String walletId; - final bool isDesktop; - final ClipboardInterface clipboard; @override - Widget build(BuildContext context, WidgetRef ref) { + ConsumerState createState() => + _WalletAddressesViewState(); +} + +class _WalletAddressesViewState extends ConsumerState { + final bool isDesktop = Util.isDesktop; + + bool _showChange = false; + + @override + Widget build(BuildContext context) { final coin = ref.watch(walletsChangeNotifierProvider - .select((value) => value.getManager(walletId).coin)); + .select((value) => value.getManager(widget.walletId).coin)); return ConditionalParent( condition: !isDesktop, builder: (child) => Background( @@ -45,8 +53,9 @@ class ReceivingAddressesView extends ConsumerWidget { Navigator.of(context).pop(); }, ), + titleSpacing: 0, title: Text( - "Receiving addresses", + "Wallet addresses", style: STextStyles.navBarTitle(context), ), ), @@ -56,40 +65,81 @@ class ReceivingAddressesView extends ConsumerWidget { ), ), ), - child: FutureBuilder( - future: MainDB.instance - .getAddresses(walletId) - .filter() - .subTypeEqualTo(AddressSubType.receiving) - .and() - .not() - .typeEqualTo(AddressType.nonWallet) - .sortByDerivationIndex() - .findAll(), - builder: (context, AsyncSnapshot> snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.data != null) { - // listview - return ListView.separated( - itemCount: snapshot.data!.length, - separatorBuilder: (_, __) => Container( - height: 10, + child: Column( + children: [ + SizedBox( + height: isDesktop ? 56 : 48, + width: isDesktop ? 490 : null, + child: Toggle( + key: UniqueKey(), + onColor: Theme.of(context).extension()!.popupBG, + onText: "Receiving", + offColor: Theme.of(context) + .extension()! + .textFieldDefaultBG, + offText: "Change", + isOn: _showChange, + onValueChanged: (value) { + setState(() { + _showChange = value; + }); + }, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), ), - itemBuilder: (_, index) => AddressCard( - walletId: walletId, - address: snapshot.data![index], - coin: coin, - ), - ); - } else { - return const Center( - child: LoadingIndicator( - height: 200, - width: 200, - ), - ); - } - }, + ), + ), + SizedBox( + height: isDesktop ? 20 : 16, + ), + Expanded( + child: FutureBuilder( + future: MainDB.instance + .getAddresses(widget.walletId) + .filter() + .group( + (q) => _showChange + ? q.subTypeEqualTo(AddressSubType.change) + : q + .subTypeEqualTo(AddressSubType.receiving) + .or() + .subTypeEqualTo(AddressSubType.paynymReceive), + ) + .and() + .not() + .typeEqualTo(AddressType.nonWallet) + .sortByDerivationIndex() + .findAll(), + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.data != null) { + // listview + return ListView.separated( + itemCount: snapshot.data!.length, + separatorBuilder: (_, __) => Container( + height: 10, + ), + itemBuilder: (_, index) => AddressCard( + walletId: widget.walletId, + address: snapshot.data![index], + coin: coin, + ), + ); + } else { + return const Center( + child: LoadingIndicator( + height: 200, + width: 200, + ), + ); + } + }, + ), + ), + ], ), ); } diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index 52283111c..4b44659a9 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -21,7 +21,6 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:tuple/tuple.dart'; class ReceiveView extends ConsumerStatefulWidget { const ReceiveView({ @@ -182,8 +181,8 @@ class _ReceiveViewState extends ConsumerState { onTap: () { Navigator.of(context).pop(); Navigator.of(context).pushNamed( - ReceivingAddressesView.routeName, - arguments: Tuple2(walletId, false), + WalletAddressesView.routeName, + arguments: walletId, ); }, child: RoundedWhiteContainer( diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 43a968e3e..3a7968e05 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -849,13 +849,12 @@ class RouteGenerator { } return _routeError("${settings.name} invalid args: ${args.toString()}"); - case ReceivingAddressesView.routeName: - if (args is Tuple2) { + case WalletAddressesView.routeName: + if (args is String) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => ReceivingAddressesView( - walletId: args.item1, - isDesktop: args.item2, + builder: (_) => WalletAddressesView( + walletId: args, ), settings: RouteSettings( name: settings.name,