Skip to content

Commit

Permalink
Do not allow popping the CoopCloseChannelsDialog via back button
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed May 8, 2024
1 parent 4854ef0 commit 166737f
Showing 1 changed file with 100 additions and 95 deletions.
195 changes: 100 additions & 95 deletions lib/routes/close_channels/coop_close_channels_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,108 +55,113 @@ class _CoopCloseChannelsDialogState extends State<CoopCloseChannelsDialog> {
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<Color>((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<Color>((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,
),
);
}

Expand Down

0 comments on commit 166737f

Please sign in to comment.