-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open mail or share support mail when clicked
Minor UI revision, Dialog -> AlertDialog
- Loading branch information
1 parent
fb98c54
commit 4457360
Showing
3 changed files
with
101 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,10 @@ import 'package:breez/widgets/flushbar.dart'; | |
import 'package:breez/widgets/loader.dart'; | ||
import 'package:breez/widgets/loading_animated_text.dart'; | ||
import 'package:breez_translations/breez_translations_locales.dart'; | ||
import 'package:flutter/gestures.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:share_plus/share_plus.dart'; | ||
|
||
final _log = Logger("CoopCloseChannelsDialog"); | ||
|
||
|
@@ -28,7 +30,7 @@ class _CoopCloseChannelsDialogState extends State<CoopCloseChannelsDialog> { | |
ModalRoute _currentRoute; | ||
|
||
String dialogMessage = ""; | ||
String failureMessage = ""; | ||
bool hasFailed = false; | ||
|
||
@override | ||
void initState() { | ||
|
@@ -48,121 +50,110 @@ class _CoopCloseChannelsDialogState extends State<CoopCloseChannelsDialog> { | |
Widget build(BuildContext context) { | ||
final texts = context.texts(); | ||
final themeData = Theme.of(context); | ||
final queryData = MediaQuery.of(context); | ||
final loaderThemeData = theme.customData[theme.themeId]; | ||
|
||
return Dialog( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Container( | ||
height: 64.0, | ||
padding: const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 8.0), | ||
child: LoadingAnimatedText( | ||
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, | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 0.0), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
dialogMessage.isEmpty | ||
? Padding( | ||
padding: const EdgeInsets.symmetric( | ||
vertical: 0.0, | ||
horizontal: 16.0, | ||
), | ||
child: SizedBox( | ||
width: queryData.size.width, | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
LoadingAnimatedText( | ||
texts.close_channels_dialog_message, | ||
textStyle: | ||
themeData.dialogTheme.contentTextStyle, | ||
textAlign: TextAlign.center, | ||
), | ||
], | ||
), | ||
), | ||
) | ||
: Text( | ||
dialogMessage, | ||
style: themeData.dialogTheme.contentTextStyle, | ||
textAlign: TextAlign.center, | ||
), | ||
if (failureMessage.isNotEmpty) ...[ | ||
Padding( | ||
padding: EdgeInsets.zero, | ||
child: GestureDetector( | ||
onTap: () => launchLinkOnExternalBrowser( | ||
"mailto:[email protected]"), | ||
child: Text( | ||
failureMessage, | ||
textAlign: TextAlign.left, | ||
overflow: TextOverflow.clip, | ||
maxLines: 4, | ||
style: DefaultTextStyle.of(context).style.copyWith( | ||
fontSize: 12, | ||
color: Colors.blue, | ||
), | ||
), | ||
), | ||
) | ||
] | ||
], | ||
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, | ||
), | ||
), | ||
), | ||
dialogMessage.isEmpty && failureMessage.isEmpty | ||
? 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:[email protected]", | ||
); | ||
} 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( | ||
"[email protected]", | ||
subject: texts | ||
.close_channels_dialog_failure_message_middle, | ||
sharePositionOrigin: rect, | ||
); | ||
} | ||
}, | ||
), | ||
) | ||
: SizedBox( | ||
height: 64.0, | ||
child: Padding( | ||
padding: const EdgeInsets.only(bottom: 16.0, right: 8.0), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.max, | ||
mainAxisAlignment: MainAxisAlignment.end, | ||
children: [ | ||
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), | ||
), | ||
], | ||
), | ||
TextSpan( | ||
text: texts.close_channels_dialog_failure_message_end, | ||
), | ||
) | ||
], | ||
), | ||
), | ||
], | ||
], | ||
), | ||
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), | ||
), | ||
] | ||
: null, | ||
); | ||
} | ||
|
||
|
@@ -184,13 +175,13 @@ class _CoopCloseChannelsDialogState extends State<CoopCloseChannelsDialog> { | |
); | ||
setState(() { | ||
dialogMessage = texts.close_channels_dialog_success_message; | ||
failureMessage = ""; | ||
hasFailed = false; | ||
}); | ||
return; | ||
} else { | ||
setState(() { | ||
dialogMessage = ""; | ||
failureMessage = texts.close_channels_dialog_failure_message; | ||
hasFailed = true; | ||
}); | ||
|
||
_log.warning("Failed to close all channels."); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters