Skip to content

Commit

Permalink
feat(#691): add filter for missing guidelines
Browse files Browse the repository at this point in the history
* Add own file for FilterButton
* Make lookup fetching even better debuggable (not sure why this
  is making problems the whole time)
  • Loading branch information
tamslo committed Feb 23, 2024
1 parent 118e239 commit 0d9c07f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
3 changes: 2 additions & 1 deletion app/lib/common/utilities/genome_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Future<void> _saveDiplotypeAndActiveDrugsResponse(
}

Future<void> updateGenotypeResults() async {
if (!shouldUpdateGenotypeResults()) return;
final skipUpdate = !shouldUpdateGenotypeResults();
if (skipUpdate) return;
// fetch lookups
final response = await get(Uri.parse(cpicLookupUrl));
if (response.statusCode != 200) throw Exception();
Expand Down
8 changes: 1 addition & 7 deletions app/lib/common/widgets/drug_list/cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,7 @@ class FilterState {
bool isAccepted(Drug drug, ActiveDrugs activeDrugs, {
required bool useDrugClass,
}) {
var warningLevelMatches = showWarningLevel[drug.warningLevel] ?? true;
// WarningLevel.none is also shown in green in app; therefore, it should
// also be filtered with green option
if (drug.warningLevel == WarningLevel.none) {
warningLevelMatches = warningLevelMatches &&
showWarningLevel[WarningLevel.green]!;
}
final warningLevelMatches = showWarningLevel[drug.warningLevel] ?? true;
final isDrugAccepted =
drug.matches(query: query, useClass: useDrugClass) &&
(activeDrugs.contains(drug.name) || showInactive) &&
Expand Down
12 changes: 12 additions & 0 deletions app/lib/common/widgets/drug_search/filter_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '../../module.dart';

class FilterButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return IconButton(
icon: Icon(Icons.filter_list),
color: PharMeTheme.iconColor,
onPressed: Scaffold.of(context).openDrawer,
);
}
}
13 changes: 1 addition & 12 deletions app/lib/common/widgets/drug_search/filter_menu.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import '../../module.dart';

class FilterButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return IconButton(
icon: Icon(Icons.filter_list),
color: PharMeTheme.iconColor,
onPressed: Scaffold.of(context).openDrawer,
);
}
}

class FilterMenuItem {
FilterMenuItem({
required bool initialValue,
Expand All @@ -29,6 +18,7 @@ class FilterMenuItem {
set value(newValue) => _value = newValue;
bool get value => _value;
}

class FilterMenu extends HookWidget {
const FilterMenu(this.cubit, this.state, this.activeDrugs, {
required this.useDrugClass
Expand Down Expand Up @@ -125,7 +115,6 @@ class FilterMenu extends HookWidget {
return [
buildDrugStatusItem(),
...WarningLevel.values
.filter((warningLevel) => warningLevel != WarningLevel.none)
.map(buildWarningLevelItem),
];
}
Expand Down
1 change: 1 addition & 0 deletions app/lib/common/widgets/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export 'drug_list/builder.dart';
export 'drug_list/cubit.dart';
export 'drug_list/drug_items/drug_cards.dart';
export 'drug_search/builder.dart';
export 'drug_search/filter_button.dart';
export 'drug_search/filter_data_wrapper.dart';
export 'drug_search/filter_menu.dart';
export 'error_handler.dart';
Expand Down

0 comments on commit 0d9c07f

Please sign in to comment.