From 073cfa82baf74e0329be746568558dccc37787d9 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Wed, 4 Sep 2024 15:36:23 +0200 Subject: [PATCH] feat(#706): improve indictor on drug page --- app/lib/common/widgets/annotation_table.dart | 13 ++- .../drug/widgets/annotation_cards/drug.dart | 103 +++++++++--------- 2 files changed, 64 insertions(+), 52 deletions(-) diff --git a/app/lib/common/widgets/annotation_table.dart b/app/lib/common/widgets/annotation_table.dart index 6121b947..1bfd17c0 100644 --- a/app/lib/common/widgets/annotation_table.dart +++ b/app/lib/common/widgets/annotation_table.dart @@ -15,11 +15,12 @@ Table buildTable( ) { return Table( defaultColumnWidth: IntrinsicColumnWidth(), - children: rowDefinitions.map((rowDefinition) => _buildRow( + children: rowDefinitions.mapIndexed((index, rowDefinition) => _buildRow( rowDefinition.key, rowDefinition.value, style ?? PharMeTheme.textTheme.bodyMedium!, boldHeader: boldHeader, + isLast: index == rowDefinitions.length - 1, )).toList(), ); } @@ -28,12 +29,18 @@ TableRow _buildRow( String key, String value, TextStyle textStyle, - { required bool boldHeader } + { + required bool boldHeader, + required bool isLast, + } ) { return TableRow( children: [ Padding( - padding: EdgeInsets.only(right: PharMeTheme.smallSpace), + padding: EdgeInsets.only( + right: PharMeTheme.smallSpace, + bottom: isLast ? 0 : PharMeTheme.smallSpace, + ), child: Text( key, style: boldHeader diff --git a/app/lib/drug/widgets/annotation_cards/drug.dart b/app/lib/drug/widgets/annotation_cards/drug.dart index 9883e405..7ad8ada5 100644 --- a/app/lib/drug/widgets/annotation_cards/drug.dart +++ b/app/lib/drug/widgets/annotation_cards/drug.dart @@ -20,44 +20,62 @@ class DrugAnnotationCards extends StatelessWidget { children: [ RoundedCard( innerPadding: EdgeInsets.symmetric(horizontal: PharMeTheme.mediumSpace), - child: SwitchListTile.adaptive( - value: isActive, - activeColor: PharMeTheme.primaryColor, - title: Text(context.l10n.drugs_page_text_active), - contentPadding: EdgeInsets.zero, - onChanged: disabled ? null : (newValue) { - if (isInhibitor(drug.name)) { - showAdaptiveDialog( - context: context, - builder: (context) => DialogWrapper( - title: context.l10n.drugs_page_active_warn_header, - content: DialogContentText( - context.l10n.drugs_page_active_warn, - ), - actions: [ - DialogAction( - onPressed: () => Navigator.pop( - context, - 'Cancel', + child: Column( + children: [ + SwitchListTile.adaptive( + value: isActive, + activeColor: PharMeTheme.primaryColor, + title: Text(context.l10n.drugs_page_text_active), + contentPadding: EdgeInsets.zero, + onChanged: disabled ? null : (newValue) { + if (isInhibitor(drug.name)) { + showAdaptiveDialog( + context: context, + builder: (context) => DialogWrapper( + title: context.l10n.drugs_page_active_warn_header, + content: DialogContentText( + context.l10n.drugs_page_active_warn, ), - text: context.l10n.action_cancel, - ), - DialogAction( - onPressed: () { - Navigator.pop(context, 'OK'); - setActivity(value: newValue); - }, - text: context.l10n.action_continue, - isDestructive: true, + actions: [ + DialogAction( + onPressed: () => Navigator.pop( + context, + 'Cancel', + ), + text: context.l10n.action_cancel, + ), + DialogAction( + onPressed: () { + Navigator.pop(context, 'OK'); + setActivity(value: newValue); + }, + text: context.l10n.action_continue, + isDestructive: true, + ), + ], ), - ], - ), - ); - } else { - setActivity(value: newValue); - } - }, - ), + ); + } else { + setActivity(value: newValue); + } + }, + ), + if (isInhibitor(drug.name)) ...[ + SizedBox(height: PharMeTheme.smallSpace), + buildTable( + [TableRowDefinition( + drugInteractionIndicator, + context.l10n.drugs_page_is_inhibitor( + drug.name, + inhibitedGenes(drug).join(', '), + ), + )], + boldHeader: false, + ), + SizedBox(height: PharMeTheme.smallSpace), + ], + ], + ) ), SizedBox(height: PharMeTheme.smallSpace), SubHeader(context.l10n.drugs_page_header_drug), @@ -81,19 +99,6 @@ class DrugAnnotationCards extends StatelessWidget { drug.annotations.brandNames.join(', '), ), ]), - if (isInhibitor(drug.name)) ...[ - SizedBox(height: PharMeTheme.smallSpace), - buildTable( - [TableRowDefinition( - drugInteractionIndicator, - context.l10n.drugs_page_is_inhibitor( - drug.name, - inhibitedGenes(drug).join(', '), - ), - )], - boldHeader: false, - ), - ], ], ), ),