diff --git a/app/lib/common/widgets/drug_list/builder.dart b/app/lib/common/widgets/drug_list/builder.dart index 2bc5a27ee..52102340e 100644 --- a/app/lib/common/widgets/drug_list/builder.dart +++ b/app/lib/common/widgets/drug_list/builder.dart @@ -1,18 +1,31 @@ import '../../module.dart'; -List buildDrugList(BuildContext context, DrugListState state) => +List buildDrugList( + BuildContext context, + DrugListState state, { + String? noDrugsMessage, +}) => state.when( initial: () => [Container()], error: () => [errorIndicator(context.l10n.err_generic)], - loaded: (drugs, filter) => _buildDrugCards(context, drugs, filter), + loaded: (drugs, filter) => _buildDrugCards( + context, + drugs, + filter, + noDrugsMessage: noDrugsMessage, + ), loading: () => [loadingIndicator()], ); List _buildDrugCards( - BuildContext context, List drugs, FilterState filter) { + BuildContext context, + List drugs, + FilterState filter, { + String? noDrugsMessage, +}) { final filteredDrugs = filter.filter(drugs); - if (filteredDrugs.isEmpty) { - return [errorIndicator(context.l10n.err_no_drugs)]; + if (filteredDrugs.isEmpty && noDrugsMessage != null) { + return [errorIndicator(noDrugsMessage)]; } return [ SizedBox(height: 8), diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index f38e97b1d..2c346009c 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -100,6 +100,7 @@ "gene_page_phenotype_tooltip": "The phenotype describes the effect that your personal variant of this gene has on the enzyme it encodes.", "gene_page_affected_drugs": "Affected drugs", "gene_page_affected_drugs_tooltip": "The drugs listed here are affected by your variant of this gene.", + "gene_page_no_affected_drugs": "Your variant of this gene has no known effect on any drug.", "nav_report": "Report", "tab_report": "Gene report", diff --git a/app/lib/report/pages/gene.dart b/app/lib/report/pages/gene.dart index ee48f364e..825dc0ce8 100644 --- a/app/lib/report/pages/gene.dart +++ b/app/lib/report/pages/gene.dart @@ -49,7 +49,8 @@ class GenePage extends HookWidget { SizedBox(height: 12), SubHeader(context.l10n.gene_page_affected_drugs, tooltip: context.l10n.gene_page_affected_drugs_tooltip), - ...buildDrugList(context, state) + ...buildDrugList(context, state, + noDrugsMessage: context.l10n.gene_page_no_affected_drugs) ], ), ), diff --git a/app/lib/search/pages/search.dart b/app/lib/search/pages/search.dart index baa8bad36..7813f07e7 100644 --- a/app/lib/search/pages/search.dart +++ b/app/lib/search/pages/search.dart @@ -39,7 +39,8 @@ class SearchPage extends HookWidget { TooltipIcon(context.l10n.search_page_tooltip_search), buildFilter(context), ]), - body: buildDrugList(context, state), + body: buildDrugList(context, state, + noDrugsMessage: context.l10n.err_no_drugs), ); })); }