show receiving and change addresses

This commit is contained in:
julian 2023-03-06 15:09:32 -06:00
parent c70a8f415c
commit 5f4e8a6e58
4 changed files with 104 additions and 52 deletions

View file

@ -53,6 +53,10 @@ class _UtxoCardState extends ConsumerState<UtxoCard> {
.addressStringWalletIdEqualTo(utxo.address!, widget.walletId) .addressStringWalletIdEqualTo(utxo.address!, widget.walletId)
.findFirstSync() .findFirstSync()
?.value; ?.value;
if (label != null && label.isEmpty) {
label = null;
}
} }
return RoundedWhiteContainer( return RoundedWhiteContainer(

View file

@ -5,32 +5,40 @@ import 'package:stackwallet/db/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/pages/receive_view/addresses/address_card.dart'; import 'package:stackwallet/pages/receive_view/addresses/address_card.dart';
import 'package:stackwallet/providers/global/wallets_provider.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/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.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/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/loading_indicator.dart';
import 'package:stackwallet/widgets/toggle.dart';
class ReceivingAddressesView extends ConsumerWidget { class WalletAddressesView extends ConsumerStatefulWidget {
const ReceivingAddressesView({ const WalletAddressesView({
Key? key, Key? key,
required this.walletId, required this.walletId,
required this.isDesktop,
this.clipboard = const ClipboardWrapper(),
}) : super(key: key); }) : super(key: key);
static const String routeName = "/receivingAddressesView"; static const String routeName = "/walletAddressesView";
final String walletId; final String walletId;
final bool isDesktop;
final ClipboardInterface clipboard;
@override @override
Widget build(BuildContext context, WidgetRef ref) { ConsumerState<WalletAddressesView> createState() =>
_WalletAddressesViewState();
}
class _WalletAddressesViewState extends ConsumerState<WalletAddressesView> {
final bool isDesktop = Util.isDesktop;
bool _showChange = false;
@override
Widget build(BuildContext context) {
final coin = ref.watch(walletsChangeNotifierProvider final coin = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(walletId).coin)); .select((value) => value.getManager(widget.walletId).coin));
return ConditionalParent( return ConditionalParent(
condition: !isDesktop, condition: !isDesktop,
builder: (child) => Background( builder: (child) => Background(
@ -45,8 +53,9 @@ class ReceivingAddressesView extends ConsumerWidget {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
titleSpacing: 0,
title: Text( title: Text(
"Receiving addresses", "Wallet addresses",
style: STextStyles.navBarTitle(context), style: STextStyles.navBarTitle(context),
), ),
), ),
@ -56,11 +65,49 @@ class ReceivingAddressesView extends ConsumerWidget {
), ),
), ),
), ),
child: Column(
children: [
SizedBox(
height: isDesktop ? 56 : 48,
width: isDesktop ? 490 : null,
child: Toggle(
key: UniqueKey(),
onColor: Theme.of(context).extension<StackColors>()!.popupBG,
onText: "Receiving",
offColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
offText: "Change",
isOn: _showChange,
onValueChanged: (value) {
setState(() {
_showChange = value;
});
},
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
),
),
SizedBox(
height: isDesktop ? 20 : 16,
),
Expanded(
child: FutureBuilder( child: FutureBuilder(
future: MainDB.instance future: MainDB.instance
.getAddresses(walletId) .getAddresses(widget.walletId)
.filter() .filter()
.group(
(q) => _showChange
? q.subTypeEqualTo(AddressSubType.change)
: q
.subTypeEqualTo(AddressSubType.receiving) .subTypeEqualTo(AddressSubType.receiving)
.or()
.subTypeEqualTo(AddressSubType.paynymReceive),
)
.and() .and()
.not() .not()
.typeEqualTo(AddressType.nonWallet) .typeEqualTo(AddressType.nonWallet)
@ -76,7 +123,7 @@ class ReceivingAddressesView extends ConsumerWidget {
height: 10, height: 10,
), ),
itemBuilder: (_, index) => AddressCard( itemBuilder: (_, index) => AddressCard(
walletId: walletId, walletId: widget.walletId,
address: snapshot.data![index], address: snapshot.data![index],
coin: coin, coin: coin,
), ),
@ -91,6 +138,9 @@ class ReceivingAddressesView extends ConsumerWidget {
} }
}, },
), ),
),
],
),
); );
} }
} }

View file

@ -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_buttons/blue_text_button.dart';
import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:tuple/tuple.dart';
class ReceiveView extends ConsumerStatefulWidget { class ReceiveView extends ConsumerStatefulWidget {
const ReceiveView({ const ReceiveView({
@ -182,8 +181,8 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
ReceivingAddressesView.routeName, WalletAddressesView.routeName,
arguments: Tuple2(walletId, false), arguments: walletId,
); );
}, },
child: RoundedWhiteContainer( child: RoundedWhiteContainer(

View file

@ -849,13 +849,12 @@ class RouteGenerator {
} }
return _routeError("${settings.name} invalid args: ${args.toString()}"); return _routeError("${settings.name} invalid args: ${args.toString()}");
case ReceivingAddressesView.routeName: case WalletAddressesView.routeName:
if (args is Tuple2<String, bool>) { if (args is String) {
return getRoute( return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute, shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => ReceivingAddressesView( builder: (_) => WalletAddressesView(
walletId: args.item1, walletId: args,
isDesktop: args.item2,
), ),
settings: RouteSettings( settings: RouteSettings(
name: settings.name, name: settings.name,