show xpub qr code in dialog

This commit is contained in:
sneurlax 2023-04-06 11:08:32 -05:00
parent 0c77537316
commit c396d97d85
3 changed files with 27 additions and 6 deletions

View file

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
@ -8,10 +10,10 @@ import 'package:stackwallet/widgets/desktop/primary_button.dart';
class DesktopShowXpubDialog extends ConsumerStatefulWidget {
const DesktopShowXpubDialog({
Key? key,
required this.walletId,
required this.xpub,
}) : super(key: key);
final String walletId;
final String xpub;
static const String routeName = "/desktopShowXpubDialog";
@ -50,7 +52,7 @@ class _DesktopShowXpubDialog extends ConsumerState<DesktopShowXpubDialog> {
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 26),
padding: const EdgeInsets.fromLTRB(32, 0, 32, 26),
child: Column(
children: [
const SizedBox(height: 16),
@ -58,7 +60,14 @@ class _DesktopShowXpubDialog extends ConsumerState<DesktopShowXpubDialog> {
"Wallet Xpub",
style: STextStyles.desktopH2(context),
),
const SizedBox(height: 50),
const SizedBox(height: 14),
QrImage(
data: widget.xpub,
size: 300,
foregroundColor: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [

View file

@ -1,11 +1,14 @@
import 'dart:async';
import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip39;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_show_xpub_dialog.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
@ -118,6 +121,15 @@ class _WalletOptionsButtonState extends ConsumerState<WalletOptionsButton> {
}
break;
case _WalletOptions.showXpub:
final List<String> mnemonic = await ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.mnemonic;
final seed = bip39.mnemonicToSeed(mnemonic.join(' '));
final node = bip32.BIP32.fromSeed(seed);
final xpub = node.neutered().toBase58();
final result = await showDialog<bool?>(
context: context,
barrierDismissible: false,
@ -129,7 +141,7 @@ class _WalletOptionsButtonState extends ConsumerState<WalletOptionsButton> {
RouteGenerator.generateRoute(
RouteSettings(
name: DesktopShowXpubDialog.routeName,
arguments: walletId,
arguments: xpub,
),
),
];

View file

@ -1531,7 +1531,7 @@ class RouteGenerator {
if (args is String) {
return FadePageRoute(
DesktopShowXpubDialog(
walletId: args,
xpub: args,
),
RouteSettings(
name: settings.name,