From ef9e30b2e0fb6f52958ae50ad51b392564ddf436 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Thu, 29 Feb 2024 12:57:20 -0800 Subject: [PATCH] hopefully final fixes --- .../receive/lightning_invoice_page.dart | 63 ++++++++++--------- ...ert_with_two_actions_content_override.dart | 48 ++++++++++++++ 2 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 lib/src/widgets/alert_with_two_actions_content_override.dart diff --git a/lib/src/screens/receive/lightning_invoice_page.dart b/lib/src/screens/receive/lightning_invoice_page.dart index bb11aeba0..4cb11b847 100644 --- a/lib/src/screens/receive/lightning_invoice_page.dart +++ b/lib/src/screens/receive/lightning_invoice_page.dart @@ -2,6 +2,7 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/src/screens/receive/widgets/lightning_input_form.dart'; import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; +import 'package:cake_wallet/src/widgets/alert_with_two_actions_content_override.dart'; import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart'; import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart'; import 'package:cake_wallet/themes/extensions/keyboard_theme.dart'; @@ -29,6 +30,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:mobx/mobx.dart'; +import 'package:qr_flutter/qr_flutter.dart' as qr; class LightningInvoicePage extends BasePage { LightningInvoicePage({ @@ -72,7 +74,6 @@ class LightningInvoicePage extends BasePage { caption: S.of(context).clear, onPressed: () { _formKey.currentState?.reset(); - // lightningViewModel.reset(); }); Future _onNavigateBack(BuildContext context) async { @@ -235,39 +236,41 @@ class LightningInvoicePage extends BasePage { showPopUp( context: context, builder: (BuildContext context) { - // return AlertWithTwoActions( - // alertTitle: S.of(context).invoice_created, - // alertContent: state.payload as String, - // rightButtonText: S.of(context).ok, - // actionRightButton: () => Navigator.of(context).pop(), - // actionLeftButton: () async { - // Clipboard.setData(ClipboardData(text: state.payload as String)); - // showBar(context, S.of(context).copied_to_clipboard); - // }, - // leftButtonText: S.of(context).copy, - // ); - - return Center( - child: AspectRatio( - aspectRatio: 1.0, - child: Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - border: Border.all( - width: 3, - color: Theme.of(context).extension()!.textColor, - ), - ), + return AlertWithTwoActionsContentOverride( + alertTitle: S.of(context).invoice_created, + alertContent: Center( + child: AspectRatio( + aspectRatio: 1.0, child: Container( - decoration: BoxDecoration( - border: Border.all( - width: 3, - color: Colors.white, - ), + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + border: Border.all( + width: 3, + color: Theme.of(context).extension()!.textColor, ), - child: QrImage(data: state.payload as String)), + ), + child: Container( + decoration: BoxDecoration( + border: Border.all( + width: 3, + color: Colors.white, + ), + ), + child: QrImage( + data: state.payload as String, + version: 14, + errorCorrectionLevel: qr.QrErrorCorrectLevel.L, + )), + ), ), ), + rightButtonText: S.of(context).ok, + actionRightButton: () => Navigator.of(context).pop(), + actionLeftButton: () async { + Clipboard.setData(ClipboardData(text: state.payload as String)); + showBar(context, S.of(context).copied_to_clipboard); + }, + leftButtonText: S.of(context).copy, ); }); } diff --git a/lib/src/widgets/alert_with_two_actions_content_override.dart b/lib/src/widgets/alert_with_two_actions_content_override.dart new file mode 100644 index 000000000..33a2e4727 --- /dev/null +++ b/lib/src/widgets/alert_with_two_actions_content_override.dart @@ -0,0 +1,48 @@ +import 'dart:ui'; +import 'package:cake_wallet/src/widgets/base_alert_dialog.dart'; +import 'package:flutter/cupertino.dart'; + +class AlertWithTwoActionsContentOverride extends BaseAlertDialog { + AlertWithTwoActionsContentOverride({ + required this.alertTitle, + required this.alertContent, + required this.leftButtonText, + required this.rightButtonText, + required this.actionLeftButton, + required this.actionRightButton, + this.alertBarrierDismissible = true, + this.isDividerExist = false, + }); + + final String alertTitle; + final Widget alertContent; + final String leftButtonText; + final String rightButtonText; + final VoidCallback actionLeftButton; + final VoidCallback actionRightButton; + final bool alertBarrierDismissible; + // final Color leftActionColor; + // final Color rightActionColor; + final bool isDividerExist; + + @override + String get titleText => alertTitle; + @override + String get leftActionButtonText => leftButtonText; + @override + String get rightActionButtonText => rightButtonText; + @override + VoidCallback get actionLeft => actionLeftButton; + @override + VoidCallback get actionRight => actionRightButton; + @override + bool get barrierDismissible => alertBarrierDismissible; + + @override + Widget content(BuildContext context) { + return alertContent; + } + + @override + bool get isDividerExists => isDividerExist; +}