diff --git a/app/lib/common/constants.dart b/app/lib/common/constants.dart index bb02482d..b78f906d 100644 --- a/app/lib/common/constants.dart +++ b/app/lib/common/constants.dart @@ -9,7 +9,7 @@ Uri keycloakUrl([String slug = '']) => // Note that sending emails will not work on the iPhone Simulator since it does // not have any email application installed. -String _mailContact = 'ehivepgx@mssm.edu'; +String contactEmailAddress = 'ehivepgx@mssm.edu'; // Workaround according to https://pub.dev/packages/url_launcher#encoding-urls String? _encodeQueryParameters(Map params) { return params.entries @@ -24,7 +24,7 @@ Future sendEmail({ await launchUrl( Uri( scheme: 'mailto', - path: _mailContact, + path: contactEmailAddress, query: _encodeQueryParameters({ 'subject': subject, 'body': body, @@ -33,8 +33,13 @@ Future sendEmail({ ); } +final geneticInformationUrl = Uri.https( + 'medlineplus.gov', + '/genetics/understanding/', +); + Future openFurtherGeneticInformation() async => - launchUrl(Uri.https('medlineplus.gov', '/genetics/understanding/')); + launchUrl(geneticInformationUrl); final cpicMaxCacheTime = Duration(days: 90); const maxCachedDrugs = 10; diff --git a/app/lib/common/widgets/hyperlink.dart b/app/lib/common/widgets/hyperlink.dart new file mode 100644 index 00000000..d8bfa09d --- /dev/null +++ b/app/lib/common/widgets/hyperlink.dart @@ -0,0 +1,22 @@ +import '../module.dart'; + +class Hyperlink extends StatelessWidget { + const Hyperlink({ required this.text, required this.onTap }); + final String text; + final void Function() onTap; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Text( + text, + style: TextStyle( + color: PharMeTheme.secondaryColor, + decoration: TextDecoration.underline, + decorationColor: PharMeTheme.secondaryColor, + ), + ), + ); + } +} diff --git a/app/lib/common/widgets/link_text_span.dart b/app/lib/common/widgets/link_text_span.dart deleted file mode 100644 index e66ebe9e..00000000 --- a/app/lib/common/widgets/link_text_span.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter/gestures.dart'; - -import '../module.dart'; - -TextSpan linkTextSpan({required String text, required void Function() onTap}) => - TextSpan( - text: text, - style: TextStyle( - color: PharMeTheme.secondaryColor, - decoration: TextDecoration.underline, - ), - recognizer: TapGestureRecognizer()..onTap = onTap, - ); \ No newline at end of file diff --git a/app/lib/common/widgets/module.dart b/app/lib/common/widgets/module.dart index adf2c0b8..17af1bd6 100644 --- a/app/lib/common/widgets/module.dart +++ b/app/lib/common/widgets/module.dart @@ -14,9 +14,9 @@ export 'drug_search/filter_menu.dart'; export 'error_handler.dart'; export 'full_width_button.dart'; export 'headings.dart'; +export 'hyperlink.dart'; export 'indicators.dart'; export 'lifecycle_observer.dart'; -export 'link_text_span.dart'; export 'page_description.dart'; export 'page_indicator_explanation.dart'; export 'page_scaffold.dart'; diff --git a/app/lib/error/pages/error.dart b/app/lib/error/pages/error.dart index df976e64..12040f18 100644 --- a/app/lib/error/pages/error.dart +++ b/app/lib/error/pages/error.dart @@ -15,10 +15,12 @@ class ErrorPage extends StatelessWidget { child: PharMeLogoPage( greyscale: true, child: Column( + crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( context.l10n.error_title, style: PharMeTheme.textTheme.headlineMedium, + textAlign: TextAlign.center, ), SizedBox(height: PharMeTheme.mediumSpace), RichText( @@ -37,23 +39,16 @@ class ErrorPage extends StatelessWidget { ), ), SizedBox(height: PharMeTheme.mediumSpace), - RichText( + Text( + context.l10n.error_uncaught_message_contact, + style: PharMeTheme.textTheme.bodyLarge, textAlign: TextAlign.center, - text: TextSpan( - style: PharMeTheme.textTheme.bodyLarge, - children: [ - TextSpan(text: context.l10n.error_uncaught_message_contact), - linkTextSpan( - text: context.l10n.error_contact_link_text, - onTap: () => sendEmail( - subject: context.l10n.error_mail_subject, - body: context.l10n.error_mail_body(error), - ), - ), - TextSpan( - text: context.l10n.error_uncaught_message_after_link, - ), - ], + ), + Hyperlink( + text: contactEmailAddress, + onTap: () => sendEmail( + subject: context.l10n.error_mail_subject, + body: context.l10n.error_mail_body(error), ), ), SizedBox(height: PharMeTheme.mediumSpace), diff --git a/app/lib/faq/constants.dart b/app/lib/faq/constants.dart index b56cd59d..e8c1cb3c 100644 --- a/app/lib/faq/constants.dart +++ b/app/lib/faq/constants.dart @@ -38,21 +38,20 @@ final Map> faqList = { ), WidgetAnswerQuestion( question: 'Where can I find out more about genetics in general?', - answer: RichText(text: TextSpan( - // context.l10n.genetic_information_text_part_1 - text: 'If you would like to learn more about genetics, we recommend ', - style: PharMeTheme.textTheme.titleMedium, + answer: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - linkTextSpan( - text: 'MedlinePlus', // context.l10n.genetic_information_source - onTap: openFurtherGeneticInformation, + Text( + 'To learn more about genetics, we recommend MedlinePlus,' + ' a service of the National Library of Medicine:' ), - TextSpan( - // context.l10n.genetic_information_text_part_2 - text: ', a service of the National Library of Medicine.', + SizedBox(height: PharMeTheme.smallSpace * 0.5), + Hyperlink( + text: geneticInformationUrl.toString(), + onTap: openFurtherGeneticInformation, ), ], - )), + ), ), TextAnswerQuestion( question: 'Which drugs are affected?', diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 1a529a36..af82cb58 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -7,9 +7,7 @@ "error_title": "Something went wrong", "error_uncaught_message_first_part": "PharMe has encountered an unknown error. ", "error_uncaught_message_bold_part": "Please close the app and open it again.", - "error_uncaught_message_contact": "The error has been logged for our technical staff; however, please ", - "error_contact_link_text": "contact us", - "error_uncaught_message_after_link": " if this problem persists.", + "error_uncaught_message_contact": "The error has been logged for our technical staff; however, if this problem persists, please contact us:", "error_close_app": "Close app", "error_mail_subject": "[ACTION REQUIRED] Unknown Error Report", "error_mail_body": "Please describe what happened right before the error occurred: \n\n--- Please keep the following information, it will help us to pin down the error ---\n\n{error}", @@ -27,10 +25,6 @@ "auth_sign_in": "Get data", "auth_success": "Successfully imported data", - "genetic_information_text_part_1": "If you would like to learn more about genetics, we recommend ", - "genetic_information_text_part_2": ", a service of the National Library of Medicine.", - "genetic_information_source": "MedlinePlus", - "drug_selection_header": "Currently taken drugs", "drug_selection_onboarding_description": "Please update which drugs you are currently taking below. You can always change the status for a drug later on a drug page or in the settings.", "drug_selection_settings_description": "Review your currently taken drugs below.", @@ -46,7 +40,6 @@ "update_warning_title": "Updated guidelines", "update_warning_body": "The guidelines for gene-drug interactions were updated. Please review your information, especially for drugs you are currently taking.", - "faq_contact_us": "Do you have unanswered questions or feedback? Contact us", "general_continue": "Continue", diff --git a/app/lib/report/pages/report.dart b/app/lib/report/pages/report.dart index 3a31030e..61041e4b 100644 --- a/app/lib/report/pages/report.dart +++ b/app/lib/report/pages/report.dart @@ -173,7 +173,7 @@ List _buildWarningLevelIndicator( child: Icon( warningLevel.icon, color: warningLevel.textColor, - size: pageDescriptionTextStyle!.fontSize, + size: PharMeTheme.textTheme.bodyMedium!.fontSize, ), ), WidgetSpan( @@ -182,7 +182,7 @@ List _buildWarningLevelIndicator( ), TextSpan( text: text, - style: pageDescriptionTextStyle!.copyWith(color: warningLevel.textColor) + style: PharMeTheme.textTheme.bodyMedium!.copyWith(color: warningLevel.textColor) ), ]; }