From 91ce3b62ebb7707753fa94675b6f9a44c4616a39 Mon Sep 17 00:00:00 2001 From: tamslo Date: Fri, 6 Dec 2024 14:44:59 +0100 Subject: [PATCH] feat(app): show indicator explanation on bottom of drug page --- .../widgets/page_indicator_explanation.dart | 19 +++++--- app/lib/drug/pages/drug.dart | 48 ++++++++++++------- .../drug/widgets/annotation_cards/drug.dart | 36 ++++---------- app/lib/l10n/app_en.arb | 20 ++++---- 4 files changed, 64 insertions(+), 59 deletions(-) diff --git a/app/lib/common/widgets/page_indicator_explanation.dart b/app/lib/common/widgets/page_indicator_explanation.dart index 99646956..bf944bbf 100644 --- a/app/lib/common/widgets/page_indicator_explanation.dart +++ b/app/lib/common/widgets/page_indicator_explanation.dart @@ -1,20 +1,25 @@ import '../module.dart'; class PageIndicatorExplanation extends StatelessWidget { - const PageIndicatorExplanation(this.text); + const PageIndicatorExplanation(this.text, {this.indicator}); + final String? indicator; final String text; @override Widget build(BuildContext context) { + final textStyle = PharMeTheme.textTheme.labelMedium!.copyWith( + fontStyle: FontStyle.italic, + ); return Padding( padding: EdgeInsets.all(PharMeTheme.smallSpace), - child: Text( - text, - style: PharMeTheme.textTheme.labelMedium!.copyWith( - fontStyle: FontStyle.italic, - ), - ), + child: indicator.isNotNullOrBlank + ? buildTable( + [TableRowDefinition(indicator!, text)], + boldHeader: false, + style: textStyle, + ) + : Text(text, style: textStyle), ); } } \ No newline at end of file diff --git a/app/lib/drug/pages/drug.dart b/app/lib/drug/pages/drug.dart index 69a87474..5cc9cc95 100644 --- a/app/lib/drug/pages/drug.dart +++ b/app/lib/drug/pages/drug.dart @@ -32,7 +32,7 @@ class DrugPage extends StatelessWidget { } Widget _buildDrugsPage(BuildContext context, { required bool loading }) { - return pageScaffold( + return unscrollablePageScaffold( title: isInhibitor(drug.name) ? '${drug.name.capitalize()}$drugInteractionIndicator' : drug.name.capitalize(), @@ -47,24 +47,38 @@ class DrugPage extends StatelessWidget { ), ) ], - body: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - DrugAnnotationCards( - drug, - isActive: drug.isActive, - setActivity: context.read().setActivity, - disabled: loading, + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DrugAnnotationCards( + drug, + isActive: drug.isActive, + setActivity: context.read().setActivity, + disabled: loading, + ), + SizedBox(height: PharMeTheme.mediumSpace), + GuidelineAnnotationCard(drug), + ], + ), ), - SizedBox(height: PharMeTheme.mediumSpace), - GuidelineAnnotationCard(drug), - ], + ), ), - ), - ], + if (isInhibitor(drug.name)) PageIndicatorExplanation( + context.l10n.drugs_page_is_inhibitor( + inhibitedGenes(drug).length, + drug.name, + inhibitedGenes(drug).join(', '), + ), + indicator: drugInteractionIndicator, + ), + ], + ), ); } } diff --git a/app/lib/drug/widgets/annotation_cards/drug.dart b/app/lib/drug/widgets/annotation_cards/drug.dart index fba8f035..6494bd6e 100644 --- a/app/lib/drug/widgets/annotation_cards/drug.dart +++ b/app/lib/drug/widgets/annotation_cards/drug.dart @@ -20,33 +20,15 @@ class DrugAnnotationCards extends StatelessWidget { children: [ RoundedCard( innerPadding: EdgeInsets.symmetric(horizontal: PharMeTheme.mediumSpace), - child: Column( - children: [ - buildDrugActivitySelection( - context: context, - drug: drug, - setActivity: setActivity, - title: context.l10n.drugs_page_text_active, - isActive: isActive, - disabled: disabled, - contentPadding: EdgeInsets.zero, - ), - if (isInhibitor(drug.name)) ...[ - SizedBox(height: PharMeTheme.smallSpace), - buildTable( - [TableRowDefinition( - drugInteractionIndicator, - context.l10n.drugs_page_is_inhibitor( - drug.name, - inhibitedGenes(drug).join(', '), - ), - )], - boldHeader: false, - ), - SizedBox(height: PharMeTheme.mediumSpace), - ], - ], - ) + child: buildDrugActivitySelection( + context: context, + drug: drug, + setActivity: setActivity, + title: context.l10n.drugs_page_text_active, + isActive: isActive, + disabled: disabled, + contentPadding: EdgeInsets.zero, + ), ), SizedBox(height: PharMeTheme.smallSpace), PrettyExpansionTile( diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index c7b82228..f35d6708 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -133,17 +133,21 @@ "@drugs_page_disclaimer_description": {}, "drugs_page_disclaimer_text_part_0": "Never stop taking or change the dose of your medications without consulting your pharmacist or doctor.", "@drugs_page_disclaimer_text_part_0": {}, - "drugs_page_is_inhibitor": "Taking {drugName} can interact with your results for the following gene(s): {genes}", + "drugs_page_is_inhibitor": "{geneNumber, plural, =1{Taking {drugName} can interact with your results for the following gene: {genes}} other{Taking {drugName} can interact with your results for the following genes: {genes}}}", "@drugs_page_is_inhibitor": { "placeholders": { - "drugName": { - "type": "String", - "example": "bupropion" - }, - "genes": { + "geneNumber": { + "type": "int", + "example": "1" + }, + "drugName": { "type": "String", - "example": "CYP2D6, CYP2C19" - } + "example": "bupropion" + }, + "genes": { + "type": "String", + "example": "CYP2D6, CYP2C19" + } } },