Skip to content

Commit

Permalink
feat(app): use Text instead of RichText on error page
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Mar 1, 2024
1 parent c6a9cad commit b3272de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
14 changes: 8 additions & 6 deletions app/lib/common/widgets/hyperlink.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import '../module.dart';

class Hyperlink extends StatelessWidget {
const Hyperlink({ required this.text, required this.onTap });
const Hyperlink({ required this.text, required this.onTap, this.style });
final String text;
final void Function() onTap;
final TextStyle? style;

@override
Widget build(BuildContext context) {
final linkStyle = TextStyle(
color: PharMeTheme.secondaryColor,
decoration: TextDecoration.underline,
decorationColor: PharMeTheme.secondaryColor,
);
return GestureDetector(
onTap: onTap,
child: Text(
text,
style: TextStyle(
color: PharMeTheme.secondaryColor,
decoration: TextDecoration.underline,
decorationColor: PharMeTheme.secondaryColor,
),
style: style != null ? style!.merge(linkStyle) : linkStyle,
),
);
}
Expand Down
40 changes: 18 additions & 22 deletions app/lib/error/pages/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class ErrorPage extends StatelessWidget {

final String error;

Text _errorText(String text, { TextStyle? style }) => Text(
text,
textAlign: TextAlign.center,
style: style != null
? PharMeTheme.textTheme.bodyLarge!.merge(style)
: PharMeTheme.textTheme.bodyLarge,
);

@override
Widget build(BuildContext context) {
return PopScope(
Expand All @@ -17,35 +25,23 @@ class ErrorPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_errorText(
context.l10n.error_title,
style: PharMeTheme.textTheme.headlineMedium,
textAlign: TextAlign.center,
),
SizedBox(height: PharMeTheme.mediumSpace),
RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: PharMeTheme.textTheme.bodyLarge,
children: [
TextSpan(
text: context.l10n.error_uncaught_message_first_part,
),
TextSpan(
text: context.l10n.error_uncaught_message_bold_part,
style: TextStyle(fontWeight: FontWeight.bold),
)
],
),
),
SizedBox(height: PharMeTheme.mediumSpace),
Text(
context.l10n.error_uncaught_message_contact,
style: PharMeTheme.textTheme.bodyLarge,
textAlign: TextAlign.center,
_errorText(context.l10n.error_uncaught_message_first_part),
SizedBox(height: PharMeTheme.smallSpace),
_errorText(
context.l10n.error_uncaught_message_bold_part,
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(height: PharMeTheme.smallSpace),
_errorText(context.l10n.error_uncaught_message_contact),
SizedBox(height: PharMeTheme.smallSpace),
Hyperlink(
text: contactEmailAddress,
style: PharMeTheme.textTheme.bodyLarge,
onTap: () => sendEmail(
subject: context.l10n.error_mail_subject,
body: context.l10n.error_mail_body(error),
Expand Down

0 comments on commit b3272de

Please sign in to comment.