From 66b057d208a0310ff1961f7a6e9e526783ccf061 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Mon, 23 Sep 2024 19:28:31 +0200 Subject: [PATCH] refactor(app): adapt variant display string --- .../common/models/userdata/genotype_result.dart | 17 +++++++++++------ app/lib/report/pages/gene.dart | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/lib/common/models/userdata/genotype_result.dart b/app/lib/common/models/userdata/genotype_result.dart index f40489cd..2ff2e1b6 100644 --- a/app/lib/common/models/userdata/genotype_result.dart +++ b/app/lib/common/models/userdata/genotype_result.dart @@ -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); } diff --git a/app/lib/report/pages/gene.dart b/app/lib/report/pages/gene.dart index 69487bbe..823a6a7b 100644 --- a/app/lib/report/pages/gene.dart +++ b/app/lib/report/pages/gene.dart @@ -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),