Skip to content

Commit

Permalink
feat(app): move inclusion descriptions inside lists
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 23, 2025
1 parent c1f3e5e commit 87ef981
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
27 changes: 26 additions & 1 deletion app/lib/common/widgets/drug_list/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ class DrugList extends HookWidget {
searchForDrugClass: searchForDrugClass,
).sortedBy((drug) => drug.name);
if (filteredDrugs.isEmpty && noDrugsMessage != null) {
return buildContainer(noDrugsMessage: errorIndicator(noDrugsMessage!));
return buildContainer(
noDrugsMessage: Column(
children: [
_buildIncludedMedicationsDescription(
context,
addRightPadding: PharMeTheme.mediumSpace,
),
errorIndicator(noDrugsMessage!),
],
),
);
}
List<Widget>? activeDrugsList;
// Do not show repeated active drugs when searching in medication selection
Expand Down Expand Up @@ -91,6 +101,7 @@ class DrugList extends HookWidget {
final currentlyExpanded = otherDrugsExpanded.value ?? false;
final currentlyEnabled = !drugActivityChangeable && filter.query.isBlank;
final drugLists = [
_buildIncludedMedicationsDescription(context),
if (activeDrugsList != null) ...[
ListDescription(
key: Key('header-active'),
Expand Down Expand Up @@ -148,6 +159,20 @@ class DrugList extends HookWidget {
);
}

Widget _buildIncludedMedicationsDescription(
BuildContext context,
{ double addRightPadding = 0.0 }
) =>
ListPageInclusionDescription(
key: Key('inclusion-description'),
type: ListPageInclusionDescriptionType.medications,
customPadding: EdgeInsets.only(
left: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace + addRightPadding,
top: PharMeTheme.smallSpace * 1.5,
),
);

@override
Widget build(BuildContext context) {
final otherDrugsExpanded = useState<bool?>(null);
Expand Down
9 changes: 0 additions & 9 deletions app/lib/common/widgets/drug_search/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ class DrugSearch extends HookWidget {
),
),
),
ListPageInclusionDescription(
type: ListPageInclusionDescriptionType.medications,
customPadding: EdgeInsets.only(
left: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace,
top: PharMeTheme.smallSpace * 1.5,
bottom: PharMeTheme.smallSpace,
),
),
if (children != null) scrollList(
keepPosition: keepPosition,
children,
Expand Down
5 changes: 0 additions & 5 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ class GenePage extends HookWidget {
genotypeResult.geneDisplayString
),
),
SizedBox(height: PharMeTheme.mediumSpace),
ListPageInclusionDescription(
type: ListPageInclusionDescriptionType.medications,
customPadding: EdgeInsets.zero,
),
],
),
),
Expand Down
16 changes: 12 additions & 4 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ class ReportPage extends HookWidget {
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListPageInclusionDescription(
text: context.l10n.report_content_explanation,
type: ListPageInclusionDescriptionType.genes,
),
PageDescription.fromText(context.l10n.report_content_explanation),
scrollList(
_buildReportLists(
context,
Expand Down Expand Up @@ -249,13 +246,24 @@ class ReportPage extends HookWidget {
drugsToFilterBy: null,
onlyCurrentMedications: false,
);
final inclusionDescription = ListPageInclusionDescription(
key: Key('included-gene-explanation'),
type: ListPageInclusionDescriptionType.genes,
customPadding: EdgeInsets.only(
left: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace,
top: PharMeTheme.smallSpace * 1.5,
),
);
if (currentMedicationGenes.isEmpty) {
return [
inclusionDescription,
allMedicationGenesHeader,
...allMedicationGenes,
];
}
return [
inclusionDescription,
_listDescription(
context,
context.l10n.report_current_medications,
Expand Down

0 comments on commit 87ef981

Please sign in to comment.