Skip to content

Commit

Permalink
feat(#567): show affected drugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Apr 14, 2023
1 parent 89afd2f commit f3811c3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 32 deletions.
2 changes: 2 additions & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
"gene_page_genotype_tooltip": "The genotype describes your personal variant of this gene.",
"gene_page_phenotype": "Phenotype",
"gene_page_phenotype_tooltip": "The phenotype describes the effect that your personal variant of this gene has on the enzyme it encodes.",
"gene_page_affected_drugs": "Affected drugs",
"gene_page_affected_drugs_tooltip": "The drugs listed here are affected by your variant of this gene.",

"nav_report": "Report",
"tab_report": "Gene report",
Expand Down
2 changes: 2 additions & 0 deletions app/lib/report/module.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../common/module.dart';
import '../search/module.dart';
import 'pages/gene.dart';
import 'pages/report.dart';

Expand All @@ -12,5 +13,6 @@ const reportRoutes = AutoRoute(
children: [
AutoRoute(path: '', page: ReportPage),
AutoRoute(page: GenePage),
AutoRoute(page: DrugPage)
],
);
82 changes: 50 additions & 32 deletions app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,61 @@ import '../../common/module.dart';
import '../../common/pages/drug/widgets/sub_header.dart';
import '../../common/pages/drug/widgets/tooltip_icon.dart';

class GenePage extends StatelessWidget {
const GenePage(this.phenotype);
class GenePage extends HookWidget {
GenePage(this.phenotype)
: cubit = DrugListCubit(
initialFilter: FilterState.forGene(phenotype.geneSymbol),
);

final CpicPhenotype phenotype;
final DrugListCubit cubit;

@override
Widget build(BuildContext context) {
return pageScaffold(
title: context.l10n.gene_page_headline(phenotype.geneSymbol),
body: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 16),
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
SubHeader(
context.l10n.gene_page_your_variant(phenotype.geneSymbol),
tooltip:
context.l10n.gene_page_name_tooltip(phenotype.geneSymbol),
),
SizedBox(height: 12),
RoundedCard(
child: Table(
columnWidths: Map.from({
0: IntrinsicColumnWidth(),
1: IntrinsicColumnWidth(flex: 1),
}),
children: [
_buildRow(
context.l10n.gene_page_genotype, phenotype.genotype,
tooltip: context.l10n.gene_page_genotype_tooltip),
_buildRow(context.l10n.gene_page_phenotype,
UserData.phenotypeFor(phenotype.geneSymbol)!,
tooltip: context.l10n.gene_page_phenotype_tooltip),
]),
return BlocProvider(
create: (context) => cubit,
child: BlocBuilder<DrugListCubit, DrugListState>(
builder: (context, state) => pageScaffold(
title: context.l10n.gene_page_headline(phenotype.geneSymbol),
body: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SubHeader(
context.l10n.gene_page_your_variant(phenotype.geneSymbol),
tooltip: context.l10n
.gene_page_name_tooltip(phenotype.geneSymbol),
),
SizedBox(height: 12),
RoundedCard(
child: Table(
columnWidths: Map.from({
0: IntrinsicColumnWidth(),
1: IntrinsicColumnWidth(flex: 1),
}),
children: [
_buildRow(
context.l10n.gene_page_genotype, phenotype.genotype,
tooltip: context.l10n.gene_page_genotype_tooltip),
_buildRow(context.l10n.gene_page_phenotype,
UserData.phenotypeFor(phenotype.geneSymbol)!,
tooltip: context.l10n.gene_page_phenotype_tooltip),
],
),
),
SizedBox(height: 12),
SubHeader(context.l10n.gene_page_affected_drugs,
tooltip: context.l10n.gene_page_affected_drugs_tooltip),
...buildDrugList(context, state)
],
),
]),
),
]);
),
],
),
),
);
}

TableRow _buildRow(String key, String value, {String? tooltip}) =>
Expand Down

0 comments on commit f3811c3

Please sign in to comment.