From fdb30f4d1bfbad89cb0dc9c132ad34e7f2824343 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Thu, 19 Sep 2024 13:14:41 +0200 Subject: [PATCH] feat(#730): only show one drug list when searching, not scrolling up in either case --- app/lib/common/widgets/drug_list/builder.dart | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/lib/common/widgets/drug_list/builder.dart b/app/lib/common/widgets/drug_list/builder.dart index 8b788ccc..82c4e6be 100644 --- a/app/lib/common/widgets/drug_list/builder.dart +++ b/app/lib/common/widgets/drug_list/builder.dart @@ -47,16 +47,22 @@ class DrugList extends StatelessWidget { if (filteredDrugs.isEmpty && noDrugsMessage != null) { return errorIndicator(noDrugsMessage!); } - final activeFilteredDrugs = + List? activeDrugsList; + // Do not show repeated active drugs when searching + if (drugActivityChangeable && filteredDrugs.length != drugs.length) { + activeDrugsList = null; + } else { + final activeFilteredDrugs = filteredDrugs.filter((drug) => drug.isActive).toList(); - final activeDrugsList = activeFilteredDrugs.isNotEmpty - ? buildDrugItems( - context, - activeFilteredDrugs, - showDrugInteractionIndicator: showDrugInteractionIndicator, - keyPrefix: 'active-', - ) - : null; + activeDrugsList = activeFilteredDrugs.isNotEmpty + ? buildDrugItems( + context, + activeFilteredDrugs, + showDrugInteractionIndicator: showDrugInteractionIndicator, + keyPrefix: 'active-', + ) + : null; + } final otherDrugs = drugActivityChangeable ? filteredDrugs : filteredDrugs.filter((drug) => !drug.isActive).toList();