mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
show receiving and change addresses
This commit is contained in:
parent
c70a8f415c
commit
5f4e8a6e58
4 changed files with 104 additions and 52 deletions
|
@ -53,6 +53,10 @@ class _UtxoCardState extends ConsumerState<UtxoCard> {
|
|||
.addressStringWalletIdEqualTo(utxo.address!, widget.walletId)
|
||||
.findFirstSync()
|
||||
?.value;
|
||||
|
||||
if (label != null && label.isEmpty) {
|
||||
label = null;
|
||||
}
|
||||
}
|
||||
|
||||
return RoundedWhiteContainer(
|
||||
|
|
|
@ -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<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
|
||||
.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,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(
|
||||
future: MainDB.instance
|
||||
.getAddresses(walletId)
|
||||
.getAddresses(widget.walletId)
|
||||
.filter()
|
||||
.group(
|
||||
(q) => _showChange
|
||||
? q.subTypeEqualTo(AddressSubType.change)
|
||||
: q
|
||||
.subTypeEqualTo(AddressSubType.receiving)
|
||||
.or()
|
||||
.subTypeEqualTo(AddressSubType.paynymReceive),
|
||||
)
|
||||
.and()
|
||||
.not()
|
||||
.typeEqualTo(AddressType.nonWallet)
|
||||
|
@ -76,7 +123,7 @@ class ReceivingAddressesView extends ConsumerWidget {
|
|||
height: 10,
|
||||
),
|
||||
itemBuilder: (_, index) => AddressCard(
|
||||
walletId: walletId,
|
||||
walletId: widget.walletId,
|
||||
address: snapshot.data![index],
|
||||
coin: coin,
|
||||
),
|
||||
|
@ -91,6 +138,9 @@ class ReceivingAddressesView extends ConsumerWidget {
|
|||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ReceiveView> {
|
|||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed(
|
||||
ReceivingAddressesView.routeName,
|
||||
arguments: Tuple2(walletId, false),
|
||||
WalletAddressesView.routeName,
|
||||
arguments: walletId,
|
||||
);
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
|
|
|
@ -849,13 +849,12 @@ class RouteGenerator {
|
|||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case ReceivingAddressesView.routeName:
|
||||
if (args is Tuple2<String, bool>) {
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue