Skip to content

Commit

Permalink
feat(app): show indicator explanation on bottom of drug page
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Dec 6, 2024
1 parent 9baafa3 commit 91ce3b6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 59 deletions.
19 changes: 12 additions & 7 deletions app/lib/common/widgets/page_indicator_explanation.dart
Original file line number Diff line number Diff line change
@@ -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),
);
}
}
48 changes: 31 additions & 17 deletions app/lib/drug/pages/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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<DrugCubit>().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<DrugCubit>().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,
),
],
),
);
}
}
36 changes: 9 additions & 27 deletions app/lib/drug/widgets/annotation_cards/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 12 additions & 8 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},

Expand Down

0 comments on commit 91ce3b6

Please sign in to comment.