diff --git a/lib/routes/close_channels/coop_close_channels_dialog.dart b/lib/routes/close_channels/coop_close_channels_dialog.dart index 277551d0a..5b941dbf7 100644 --- a/lib/routes/close_channels/coop_close_channels_dialog.dart +++ b/lib/routes/close_channels/coop_close_channels_dialog.dart @@ -55,108 +55,113 @@ class _CoopCloseChannelsDialogState extends State { final themeData = Theme.of(context); final loaderThemeData = theme.customData[theme.themeId]; - return AlertDialog( - title: (dialogMessage.isEmpty && hasFailed == false) - ? LoadingAnimatedText( - texts.close_channels_dialog_title, - textStyle: themeData.dialogTheme.titleTextStyle, - textAlign: TextAlign.center, - ) - : Text( - texts.close_channels_dialog_title, - style: themeData.dialogTheme.titleTextStyle, - textAlign: TextAlign.center, - ), - content: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - dialogMessage.isEmpty && hasFailed == false - ? LoadingAnimatedText( - texts.close_channels_dialog_message, - textStyle: themeData.dialogTheme.contentTextStyle, - textAlign: TextAlign.center, - ) - : Text( - dialogMessage, + return WillPopScope( + onWillPop: () { + return Future.value(!(dialogMessage.isNotEmpty || hasFailed == true)); + }, + child: AlertDialog( + title: (dialogMessage.isEmpty && hasFailed == false) + ? LoadingAnimatedText( + texts.close_channels_dialog_title, + textStyle: themeData.dialogTheme.titleTextStyle, + textAlign: TextAlign.center, + ) + : Text( + texts.close_channels_dialog_title, + style: themeData.dialogTheme.titleTextStyle, + textAlign: TextAlign.center, + ), + content: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + dialogMessage.isEmpty && hasFailed == false + ? LoadingAnimatedText( + texts.close_channels_dialog_message, + textStyle: themeData.dialogTheme.contentTextStyle, + textAlign: TextAlign.center, + ) + : Text( + dialogMessage, + style: themeData.dialogTheme.contentTextStyle, + textAlign: TextAlign.center, + ), + if (dialogMessage.isEmpty && hasFailed == false) ...[ + Padding( + padding: const EdgeInsets.only(bottom: 24.0), + child: Image.asset( + loaderThemeData.loaderAssetPath, + height: 64.0, + colorBlendMode: + loaderThemeData.loaderColorBlendMode ?? BlendMode.srcIn, + gaplessPlayback: true, + ), + ), + ], + if (hasFailed) ...[ + RichText( + text: TextSpan( style: themeData.dialogTheme.contentTextStyle, - textAlign: TextAlign.center, + text: texts.close_channels_dialog_failure_message_start, + children: [ + TextSpan( + text: texts.close_channels_dialog_failure_message_middle, + style: const TextStyle(color: Colors.blue), + recognizer: TapGestureRecognizer() + ..onTap = () async { + // If device can't handle mailto: link, share the e-mail + try { + await launchLinkOnExternalBrowser( + "mailto:contact@breez.technology", + ); + } catch (e) { + final RenderBox box = context.findRenderObject(); + final offset = + box.localToGlobal(Offset.zero) & box.size; + final rect = Rect.fromPoints( + offset.topLeft, + offset.bottomRight, + ); + Share.share( + "contact@breez.technology", + subject: texts + .close_channels_dialog_failure_message_middle, + sharePositionOrigin: rect, + ); + } + }, + ), + TextSpan( + text: texts.close_channels_dialog_failure_message_end, + ), + ], ), - if (dialogMessage.isEmpty && hasFailed == false) ...[ - Padding( - padding: const EdgeInsets.only(bottom: 24.0), - child: Image.asset( - loaderThemeData.loaderAssetPath, - height: 64.0, - colorBlendMode: - loaderThemeData.loaderColorBlendMode ?? BlendMode.srcIn, - gaplessPlayback: true, ), - ), + ], ], - if (hasFailed) ...[ - RichText( - text: TextSpan( - style: themeData.dialogTheme.contentTextStyle, - text: texts.close_channels_dialog_failure_message_start, - children: [ - TextSpan( - text: texts.close_channels_dialog_failure_message_middle, - style: const TextStyle(color: Colors.blue), - recognizer: TapGestureRecognizer() - ..onTap = () async { - // If device can't handle mailto: link, share the e-mail - try { - await launchLinkOnExternalBrowser( - "mailto:contact@breez.technology", - ); - } catch (e) { - final RenderBox box = context.findRenderObject(); - final offset = - box.localToGlobal(Offset.zero) & box.size; - final rect = Rect.fromPoints( - offset.topLeft, - offset.bottomRight, - ); - Share.share( - "contact@breez.technology", - subject: texts - .close_channels_dialog_failure_message_middle, - sharePositionOrigin: rect, - ); - } - }, + ), + actions: (dialogMessage.isNotEmpty || hasFailed == true) + ? [ + TextButton( + style: ButtonStyle( + overlayColor: + MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.pressed)) { + return Colors.transparent; + } + return null; // Defer to the widget's default. + }), ), - TextSpan( - text: texts.close_channels_dialog_failure_message_end, + child: Text( + texts.close_channels_dialog_action_close, + style: themeData.primaryTextTheme.labelLarge, ), - ], - ), - ), - ], - ], - ), - actions: (dialogMessage.isNotEmpty || hasFailed == true) - ? [ - TextButton( - style: ButtonStyle( - overlayColor: - MaterialStateProperty.resolveWith((states) { - if (states.contains(MaterialState.pressed)) { - return Colors.transparent; - } - return null; // Defer to the widget's default. - }), - ), - child: Text( - texts.close_channels_dialog_action_close, - style: themeData.primaryTextTheme.labelLarge, + onPressed: () => + Navigator.of(context).removeRoute(_currentRoute), ), - onPressed: () => - Navigator.of(context).removeRoute(_currentRoute), - ), - ] - : null, + ] + : null, + ), ); }