Skip to content

Commit

Permalink
refactor(app): adapt variant display string
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 23, 2024
1 parent c98d97f commit 66b057d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 11 additions & 6 deletions app/lib/common/models/userdata/genotype_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,28 @@ class GenotypeResult implements Genotype {

String get geneDisplayString => key.value;

String? get variantDisplayString => key.allele;

String _removeAlleleOrNull(String textWithAllele) =>
key.allele != null
? textWithAllele.removePrefix(key.allele!).trim().capitalize()
: textWithAllele;

String _getDisplayString(BuildContext context, String? text) {
String _displayStringOrMissing(
BuildContext context,
String? text, {
bool removeAllele = false,
}) {
final displayString = text ?? context.l10n.general_not_tested;
return key.isGeneUnique
return !removeAllele || key.isGeneUnique
? displayString
: _removeAlleleOrNull(displayString);
}

String variantDisplayString(BuildContext context) =>
_displayStringOrMissing(context, key.allele);

String phenotypeDisplayString(BuildContext context) =>
_getDisplayString(context, phenotype);
_displayStringOrMissing(context, phenotype, removeAllele: true);

String genotypeDisplayString(BuildContext context) =>
_getDisplayString(context, variant);
_displayStringOrMissing(context, variant, removeAllele: true);
}
3 changes: 1 addition & 2 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class GenePage extends HookWidget {
children: [
_buildRow(
context.l10n.gene_page_genotype,
genotypeResult.variantDisplayString ??
context.l10n.general_not_tested,
genotypeResult.variantDisplayString(context),
tooltip: context.l10n.gene_page_genotype_tooltip
),
_buildPhenotypeRow(context),
Expand Down

0 comments on commit 66b057d

Please sign in to comment.