diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 61107e143..0f1c9c667 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -57,6 +57,7 @@ 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/loading_indicator.dart'; +import 'package:stackwallet/widgets/qr_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart'; import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart'; @@ -950,9 +951,10 @@ class _WalletViewState extends ConsumerState { showDialog( barrierDismissible: true, context: context, - builder: (_) => StackDialog( + builder: (_) => QrDialog( title: "Wallet xPub", - message: xpub, + // message: xpub, + qr: xpub, leftButton: TextButton( style: Theme.of(context) .extension()! @@ -961,7 +963,7 @@ class _WalletViewState extends ConsumerState { await _copy(xpub); }, child: Text( - "Copy to clipboard", + "Copy", style: STextStyles.button(context).copyWith( color: Theme.of(context) .extension()! diff --git a/lib/widgets/qr_dialog.dart b/lib/widgets/qr_dialog.dart new file mode 100644 index 000000000..6144c70a1 --- /dev/null +++ b/lib/widgets/qr_dialog.dart @@ -0,0 +1,134 @@ +import 'package:flutter/material.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/utilities/util.dart'; + +class QrDialogBase extends StatelessWidget { + const QrDialogBase({ + Key? key, + this.child, + this.padding = const EdgeInsets.all(24), + }) : super(key: key); + + final EdgeInsets padding; + final Widget? child; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisAlignment: + !Util.isDesktop ? MainAxisAlignment.end : MainAxisAlignment.center, + children: [ + Flexible( + child: SingleChildScrollView( + child: Material( + borderRadius: BorderRadius.circular( + 20, + ), + child: Container( + decoration: BoxDecoration( + color: Theme.of(context).extension()!.popupBG, + borderRadius: BorderRadius.circular( + 20, + ), + ), + child: Padding( + padding: padding, + child: child, + ), + ), + ), + ), + ), + ], + ), + ); + } +} + +class QrDialog extends StatelessWidget { + const QrDialog({ + Key? key, + this.leftButton, + this.rightButton, + this.icon, + required this.title, + this.message, + this.qr, + }) : super(key: key); + + final Widget? leftButton; + final Widget? rightButton; + + final Widget? icon; + + final String title; + final String? message; + + final String? qr; + + @override + Widget build(BuildContext context) { + return QrDialogBase( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Text( + title, + style: STextStyles.pageTitleH2(context), + ), + ), + icon != null ? icon! : Container(), + ], + ), + if (message != null) + const SizedBox( + height: 8, + ), + if (message != null) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + message!, + style: STextStyles.smallMed14(context), + ), + ], + ), + if (qr != null) + QrImage( + data: qr!, + size: 300, + foregroundColor: + Theme.of(context).extension()!.accentColorDark, + ), + if (leftButton != null || rightButton != null) + const SizedBox( + height: 20, + ), + if (leftButton != null || rightButton != null) + Row( + children: [ + leftButton == null + ? const Spacer() + : Expanded(child: leftButton!), + const SizedBox( + width: 8, + ), + rightButton == null + ? const Spacer() + : Expanded(child: rightButton!), + ], + ) + ], + ), + ); + } +}