Skip to content

Commit

Permalink
feat(app): automatically expand further medications for further repor…
Browse files Browse the repository at this point in the history
…t gene card
  • Loading branch information
tamara-slosarek authored and tamslo committed Jan 14, 2025
1 parent e6eb4a8 commit 1cb5e5f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion app/lib/common/widgets/drug_list/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DrugList extends HookWidget {
this.noDrugsMessage,
this.buildDrugItems = buildDrugCards,
this.showDrugInteractionIndicator = false,
this.initiallyExpandFurtherMedications = false,
this.searchForDrugClass = true,
this.drugActivityChangeable = false,
required this.buildContainer,
Expand All @@ -27,6 +28,7 @@ class DrugList extends HookWidget {
final String? noDrugsMessage;
final DrugItemBuilder buildDrugItems;
final bool showDrugInteractionIndicator;
final bool initiallyExpandFurtherMedications;
final bool searchForDrugClass;
// if drugActivityChangeable, active medications are not filtered and repeated
// in the "All medications" list to make searching and toggling a medication's
Expand Down Expand Up @@ -153,7 +155,8 @@ class DrugList extends HookWidget {
initial: SizedBox.shrink,
error: () => errorIndicator(context.l10n.err_generic),
loaded: (allDrugs, filter) {
otherDrugsExpanded.value ??= drugActivityChangeable;
otherDrugsExpanded.value ??=
drugActivityChangeable || initiallyExpandFurtherMedications;
return _buildDrugList(context, allDrugs, filter, otherDrugsExpanded);
},
loading: loadingIndicator,
Expand Down
4 changes: 3 additions & 1 deletion app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import '../../drug/widgets/module.dart';

@RoutePage()
class GenePage extends HookWidget {
GenePage(this.genotypeResult)
GenePage(this.genotypeResult, {this.initiallyExpandFurtherMedications = false})
: cubit = DrugListCubit(
initialFilter:
FilterState.forGenotypeKey(genotypeResult.key.value),
);

final GenotypeResult genotypeResult;
final DrugListCubit cubit;
final bool initiallyExpandFurtherMedications;

@override
Widget build(BuildContext context) {
Expand All @@ -27,6 +28,7 @@ class GenePage extends HookWidget {
state: state,
activeDrugs: activeDrugs,
noDrugsMessage: context.l10n.gene_page_no_relevant_drugs,
initiallyExpandFurtherMedications: initiallyExpandFurtherMedications,
buildContainer: ({
children,
indicator,
Expand Down
22 changes: 16 additions & 6 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ class ReportPage extends HookWidget {
List<Widget> _buildGeneCards({
required SortOption currentSortOption,
List<String>? drugsToFilterBy,
required String keyPostfix,
required bool onlyCurrentMedications,
}) {
final keyPostfix = onlyCurrentMedications
? 'current-medications'
: 'all-medications';
final userGenotypes = _getRelevantGenotypes(
drugsToFilterBy,
);
Expand Down Expand Up @@ -114,6 +117,7 @@ class ReportPage extends HookWidget {
warningLevelCounts[genotypeResult.key.value]!,
key: Key('gene-card-${genotypeResult.key.value}-$keyPostfix'),
useColors: false,
onlyCurrentMedications: onlyCurrentMedications,
)
).toList();
}
Expand Down Expand Up @@ -239,7 +243,7 @@ class ReportPage extends HookWidget {
final currentMedicationGenes = _buildGeneCards(
currentSortOption: currentSortOption.value,
drugsToFilterBy: activeDrugs.names,
keyPostfix: 'current-medications',
onlyCurrentMedications: true,
);
final allMedicationGenesHeader = _listDescription(
context,
Expand All @@ -249,7 +253,7 @@ class ReportPage extends HookWidget {
final allMedicationGenes = _buildGeneCards(
currentSortOption: currentSortOption.value,
drugsToFilterBy: null,
keyPostfix: 'all-medications',
onlyCurrentMedications: false,
);
if (currentMedicationGenes.isEmpty) {
return [
Expand Down Expand Up @@ -296,11 +300,13 @@ class GeneCard extends StatelessWidget {
this.warningLevelCounts, {
super.key,
this.useColors = true,
this.onlyCurrentMedications = false,
});

final GenotypeResult genotypeResult;
final WarningLevelCounts warningLevelCounts;
final bool useColors;
final bool onlyCurrentMedications;

@visibleForTesting
Color? get color => !useColors || _hasNoResult(genotypeResult)
Expand Down Expand Up @@ -355,9 +361,13 @@ class GeneCard extends StatelessWidget {
)
: null;
return RoundedCard(
onTap: () => context.router.push(
GeneRoute(genotypeResult: genotypeResult)
),
onTap: () async {
// ignore: use_build_context_synchronously
await context.router.push(GeneRoute(
genotypeResult: genotypeResult,
initiallyExpandFurtherMedications: !onlyCurrentMedications,
));
},
radius: 16,
color: color,
child: Row(
Expand Down

0 comments on commit 1cb5e5f

Please sign in to comment.