Skip to content

Commit

Permalink
feat(app): improve report sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 25, 2024
1 parent 050e0b2 commit 80cfdce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
}
}
},
"report_no_result_genes": "Genes with no result",

"gene_page_headline": "{gene} report",
"@gene_page_headline": {
Expand Down
25 changes: 23 additions & 2 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class ReportPage extends StatelessWidget {
),
);
}
final sortedGenotypesWithResults = sortedGenotypes.filter(
(genotypeResult) => !_hasNoResult(genotypeResult)
);
final sortedGenotypesWithoutResults = sortedGenotypes.filter(_hasNoResult);
final hasActiveInhibitors = activeDrugs.names.any(isInhibitor);
return PopScope(
canPop: false,
Expand All @@ -74,11 +78,25 @@ class ReportPage extends StatelessWidget {
]
),
),
...sortedGenotypes.map((genotypeResult) => GeneCard(
...sortedGenotypesWithResults.map((genotypeResult) => GeneCard(
genotypeResult,
warningLevelCounts[genotypeResult.key.value]!,
key: Key('gene-card-${genotypeResult.key.value}')
)),
if (sortedGenotypesWithoutResults.isNotEmpty) ...[
SubheaderDivider(
text: context.l10n.report_no_result_genes,
key: Key('header-no-result'),
useLine: false,
),
...sortedGenotypesWithoutResults.map((genotypeResult) =>
GeneCard(
genotypeResult,
warningLevelCounts[genotypeResult.key.value]!,
key: Key('gene-card-${genotypeResult.key.value}')
)
),
],
],
),
if (hasActiveInhibitors) PageIndicatorExplanation(
Expand All @@ -94,6 +112,9 @@ class ReportPage extends StatelessWidget {
}
}

bool _hasNoResult(GenotypeResult genotypeResult) =>
UserData.lookupFor(genotypeResult.key.value) == SpecialLookup.noResult.value;

class GeneCard extends StatelessWidget {
const GeneCard(this.genotypeResult, this.warningLevelCounts, { super.key });

Expand All @@ -117,7 +138,7 @@ class GeneCard extends StatelessWidget {
GeneRoute(genotypeResult: genotypeResult)
),
radius: 16,
color: _getHighestSeverityColor(warningLevelCounts),
color: _hasNoResult(genotypeResult) ? PharMeTheme.onSurfaceColor : _getHighestSeverityColor(warningLevelCounts),
child: IntrinsicHeight(child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expand Down

0 comments on commit 80cfdce

Please sign in to comment.