Skip to content

Commit

Permalink
feat(#706): improve indictor on drug page
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 4, 2024
1 parent 3e4209b commit 073cfa8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 52 deletions.
13 changes: 10 additions & 3 deletions app/lib/common/widgets/annotation_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}
Expand All @@ -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
Expand Down
103 changes: 54 additions & 49 deletions app/lib/drug/widgets/annotation_cards/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
),
],
],
),
),
Expand Down

0 comments on commit 073cfa8

Please sign in to comment.