Skip to content

Commit

Permalink
feat(#662): only show message on report page if active inhibitors pre…
Browse files Browse the repository at this point in the history
…sent
  • Loading branch information
tamslo committed Oct 16, 2023
1 parent 22a43f3 commit dc0f32a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/lib/common/models/drug/drug_inhibitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ bool isModerateInhibitor(String drugName) {
return _isInhibitorOfType(drugName, moderateDrugInhibitors);
}

bool isInhibitor(Drug drug) {
bool isInhibitor(String drugName) {
final influencingDrugs = _drugInhibitorsPerGene.keys.flatMap(
(gene) => _drugInhibitorsPerGene[gene]!);
return influencingDrugs.contains(drug.name);
return influencingDrugs.contains(drugName);
}

List<String> inhibitedGenes(Drug drug) {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/common/pages/drug/widgets/annotation_cards/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DrugAnnotationCard extends StatelessWidget {
]
]),
SizedBox(height: 4),
if (isInhibitor(drug)) ...[
if (isInhibitor(drug.name)) ...[
SizedBox(height: 8),
Text(context.l10n.drugs_page_is_inhibitor(
drug.name,
Expand All @@ -51,7 +51,7 @@ class DrugAnnotationCard extends StatelessWidget {
title: Text(context.l10n.drugs_page_active),
value: isActive,
onChanged: disabled ? null : (newValue) => {
if (isInhibitor(drug)) {
if (isInhibitor(drug.name)) {
showCupertinoModalPopup(
context: context,
builder: (context) => CupertinoAlertDialog(
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/widgets/drug_list/drug_items/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ String formatDrugName(
bool showDrugInteractionIndicator,
) {
var drugName = drug.name.capitalize();
if (showDrugInteractionIndicator && isInhibitor(drug)) {
if (showDrugInteractionIndicator && isInhibitor(drug.name)) {
drugName = '$drugName$drugInteractionIndicator';
}
return drugName;
Expand Down
4 changes: 3 additions & 1 deletion app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import '../../common/module.dart';
class ReportPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final hasActiveInhibitors = UserData.instance.activeDrugNames != null &&
UserData.instance.activeDrugNames!.any(isInhibitor);
return unscrollablePageScaffold(
title: context.l10n.tab_report,
body: Column(
Expand All @@ -14,7 +16,7 @@ class ReportPage extends StatelessWidget {
SizedBox(height: 8)
])
).toList()),
drugInteractionExplanation(context),
if (hasActiveInhibitors) drugInteractionExplanation(context),
]
)
);
Expand Down

0 comments on commit dc0f32a

Please sign in to comment.