diff --git a/app/lib/common/constants.dart b/app/lib/common/constants.dart index 0d849293..440446e6 100644 --- a/app/lib/common/constants.dart +++ b/app/lib/common/constants.dart @@ -1,6 +1,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'module.dart'; + const medicationsIcon = FontAwesomeIcons.pills; const genesIcon = FontAwesomeIcons.dna; @@ -32,6 +34,11 @@ enum SpecialLookup { noResult, } +List unknownPhenotypes(BuildContext context) => [ + 'Indeterminate', + context.l10n.general_not_tested, +]; + extension SpecialLookupValue on SpecialLookup { String get value { final valueMap = { diff --git a/app/lib/common/widgets/annotation_table.dart b/app/lib/common/widgets/annotation_table.dart index c2baa9a9..5faa120e 100644 --- a/app/lib/common/widgets/annotation_table.dart +++ b/app/lib/common/widgets/annotation_table.dart @@ -8,6 +8,7 @@ class TableRowDefinition { { this.keyTooltip, this.valueTooltip, + this.italicValue = false, } ); @@ -15,6 +16,7 @@ class TableRowDefinition { final String value; final String? keyTooltip; final String? valueTooltip; + final bool italicValue; } Widget buildTable( @@ -22,7 +24,6 @@ Widget buildTable( { TextStyle? style, bool boldKey = true, - bool italicValue = false, } ) { return Column( @@ -32,13 +33,10 @@ Widget buildTable( defaultColumnWidth: IntrinsicColumnWidth(), children: [ _buildRow( - rowDefinition.key, - rowDefinition.value, + rowDefinition, style ?? PharMeTheme.textTheme.bodyMedium!, boldKey: boldKey, isLast: index == rowDefinitions.length - 1, - keyTooltip: rowDefinition.keyTooltip, - valueTooltip: rowDefinition.valueTooltip, ), ], ), @@ -47,14 +45,11 @@ Widget buildTable( } TableRow _buildRow( - String key, - String value, + TableRowDefinition rowDefinition, TextStyle textStyle, { required bool boldKey, required bool isLast, - String? keyTooltip, - String? valueTooltip, } ) { return TableRow( @@ -67,8 +62,8 @@ TableRow _buildRow( child: Text.rich( TextSpan( children: [ - TextSpan(text: key), - ..._maybeBuildTooltip(keyTooltip), + TextSpan(text: rowDefinition.key), + ..._maybeBuildTooltip(rowDefinition.keyTooltip), ], style: boldKey ? textStyle.copyWith(fontWeight: FontWeight.bold) @@ -79,8 +74,13 @@ TableRow _buildRow( Text.rich( TextSpan( children: [ - TextSpan(text: value), - ..._maybeBuildTooltip(valueTooltip), + TextSpan( + text: rowDefinition.value, + style: rowDefinition.italicValue + ? textStyle.copyWith(fontStyle: FontStyle.italic) + : textStyle, + ), + ..._maybeBuildTooltip(rowDefinition.valueTooltip), ], style: textStyle, ), @@ -100,4 +100,38 @@ List _maybeBuildTooltip(String? tooltip) { WidgetSpan(child: SizedBox(height: tooltipSize)), ] : []; +} + +bool testResultIsUnknown(BuildContext context, String phenotype) => + unknownPhenotypes(context).contains(phenotype); + +TableRowDefinition testResultTableRow( + BuildContext context, + { + required String key, + required String value, + String? keyTooltip, + } +) => TableRowDefinition( + key, + value, + keyTooltip: keyTooltip, + italicValue: testResultIsUnknown(context, value), +); + +TableRowDefinition phenotypeTableRow( + BuildContext context, + { + required String key, + required GenotypeResult genotypeResult, + required String? drug, + String? keyTooltip, + } +) { + return testResultTableRow( + context, + key: key, + value: possiblyAdaptedPhenotype(context, genotypeResult, drug: drug), + keyTooltip: keyTooltip, + ); } \ No newline at end of file diff --git a/app/lib/drug/widgets/annotation_cards/guideline.dart b/app/lib/drug/widgets/annotation_cards/guideline.dart index 2232f63f..6d16c68a 100644 --- a/app/lib/drug/widgets/annotation_cards/guideline.dart +++ b/app/lib/drug/widgets/annotation_cards/guideline.dart @@ -135,14 +135,12 @@ class GuidelineAnnotationCard extends StatelessWidget { } return buildTable( genotypeResults.map((genotypeResult) => - TableRowDefinition( - genotypeResult.geneDisplayString, - possiblyAdaptedPhenotype( - context, - genotypeResult, - drug: drug.name, - ), - ) + phenotypeTableRow( + context, + key: genotypeResult.geneDisplayString, + genotypeResult: genotypeResult, + drug: drug.name, + ), ).toList(), ); } diff --git a/app/lib/report/pages/gene.dart b/app/lib/report/pages/gene.dart index 38e1d139..6d6420ad 100644 --- a/app/lib/report/pages/gene.dart +++ b/app/lib/report/pages/gene.dart @@ -96,14 +96,17 @@ class GenePage extends HookWidget { } Widget _buildGeneResults(BuildContext context) => buildTable([ - TableRowDefinition( - context.l10n.gene_page_genotype, - genotypeResult.variantDisplayString(context), + testResultTableRow( + context, + key: context.l10n.gene_page_genotype, + value: genotypeResult.variantDisplayString(context), keyTooltip: context.l10n.gene_page_genotype_tooltip, ), - TableRowDefinition( - context.l10n.gene_page_phenotype, - possiblyAdaptedPhenotype(context, genotypeResult, drug: null), + phenotypeTableRow( + context, + key: context.l10n.gene_page_phenotype, + genotypeResult: genotypeResult, + drug: null, keyTooltip: context.l10n.gene_page_phenotype_tooltip, ), ]); diff --git a/app/lib/report/pages/report.dart b/app/lib/report/pages/report.dart index 5d96ce1f..342e4319 100644 --- a/app/lib/report/pages/report.dart +++ b/app/lib/report/pages/report.dart @@ -363,6 +363,11 @@ class GeneCard extends StatelessWidget { ), ) : null; + final phenotype = possiblyAdaptedPhenotype( + context, + genotypeResult, + drug: null, + ); return RoundedCard( onTap: () async { // ignore: use_build_context_synchronously @@ -391,8 +396,12 @@ class GeneCard extends StatelessWidget { runSpacing: PharMeTheme.smallSpace * 0.5, children: [ Text( - possiblyAdaptedPhenotype(context, genotypeResult, drug: null), - style: PharMeTheme.textTheme.titleSmall, + phenotype, + style: testResultIsUnknown(context, phenotype) + ? PharMeTheme.textTheme.titleSmall!.copyWith( + fontStyle: FontStyle.italic, + ) + : PharMeTheme.textTheme.titleSmall, ), SizedBox(width: PharMeTheme.smallSpace), medicationIndicators ?? SizedBox.shrink(),