Skip to content

Commit

Permalink
refactor(app): clean up list inclusion description
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 23, 2025
1 parent e826865 commit d5899e7
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 72 deletions.
24 changes: 24 additions & 0 deletions app/lib/common/widgets/disclaimer_row.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../module.dart';

class DisclaimerRow extends StatelessWidget {
const DisclaimerRow({super.key, required this.icon, required this.text});

final Widget icon;
final Widget text;

@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
right: PharMeTheme.smallSpace,
),
child: icon,
),
Expanded(child: text),
],
);
}
}
8 changes: 4 additions & 4 deletions app/lib/common/widgets/drug_list/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ class DrugList extends HookWidget {
BuildContext context,
{ double addRightPadding = 0.0 }
) =>
ListPageInclusionDescription(
Padding(
key: Key('inclusion-description'),
type: ListPageInclusionDescriptionType.medications,
customPadding: EdgeInsets.only(
padding: EdgeInsets.only(
left: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace + addRightPadding,
top: PharMeTheme.smallSpace * 1.5,
top: PharMeTheme.mediumSpace,
),
child: ListInclusionDescription.forMedications(),
);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,43 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import '../module.dart';

enum ListPageInclusionDescriptionType {
enum ListInclusionDescriptionType {
medications,
genes,
}

class ListPageInclusionDescription extends StatelessWidget {
const ListPageInclusionDescription({
class ListInclusionDescription extends StatelessWidget {
const ListInclusionDescription({
super.key,
this.text,
this.customPadding,
required this.type,
});

final String? text;
final ListPageInclusionDescriptionType type;
final EdgeInsets? customPadding;
factory ListInclusionDescription.forMedications() =>
ListInclusionDescription(type: ListInclusionDescriptionType.medications);
factory ListInclusionDescription.forGenes() =>
ListInclusionDescription(type: ListInclusionDescriptionType.genes);

final ListInclusionDescriptionType type;

@override
Widget build(BuildContext context) {
final inclusionText = context.l10n.included_content_disclaimer_text(
type == ListPageInclusionDescriptionType.medications
type == ListInclusionDescriptionType.medications
? context.l10n.included_content_medications
: context.l10n.included_content_genes
);
return PageDescription(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (text != null) Text(text!),
if (text != null) SizedBox(height: PharMeTheme.smallToMediumSpace),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.only(
left: PharMeTheme.smallSpace * 1.5,
right: PharMeTheme.smallSpace * 1.5,
top: PharMeTheme.smallSpace * 0.5,
bottom: PharMeTheme.smallSpace,
),
child: IncludedContentIcon(type: type),
),
Expanded(
child: Text(
inclusionText,
style: TextStyle(color: PharMeTheme.iconColor),
),
),
],
),
],
return DisclaimerRow(
icon: Padding(
padding: EdgeInsets.only(
left: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace * 0.5,
),
child: IncludedContentIcon(type: type),
),
text: Text(
inclusionText,
style: TextStyle(color: PharMeTheme.iconColor),
),
customPadding: customPadding,
);
}

Expand All @@ -68,20 +52,20 @@ class IncludedContentIcon extends StatelessWidget {
this.size,
});

final ListPageInclusionDescriptionType type;
final ListInclusionDescriptionType type;
final Color? color;
final double? size;

@override
Widget build(BuildContext context) {
final icon = type == ListPageInclusionDescriptionType.medications
final icon = type == ListInclusionDescriptionType.medications
? medicationsIcon
: genesIcon;
final totalSize = size ?? PharMeTheme.mediumToLargeSpace * 1.5;
final iconSize = totalSize * 0.9;
final checkIconBackgroundSize = totalSize * 0.5;
final checkIconSize = checkIconBackgroundSize * 0.8;
final rightShift = type == ListPageInclusionDescriptionType.medications
final rightShift = type == ListInclusionDescriptionType.medications
? checkIconBackgroundSize / 2
: checkIconBackgroundSize / 4;
return Stack(
Expand Down
3 changes: 2 additions & 1 deletion app/lib/common/widgets/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export 'dialog_action.dart';
export 'dialog_content_text.dart';
export 'dialog_wrapper.dart';
export 'direction_button.dart';
export 'disclaimer_row.dart';
export 'drug_activity_selection.dart';
export 'drug_list/builder.dart';
export 'drug_list/cubit.dart';
Expand All @@ -20,7 +21,7 @@ export 'hyperlink.dart';
export 'indicators.dart';
export 'lifecycle_observer.dart';
export 'list_description.dart';
export 'list_page_inclusion_description.dart';
export 'list_inclusion_description.dart';
export 'page_description.dart';
export 'page_indicator_explanation.dart';
export 'page_scaffold.dart';
Expand Down
23 changes: 0 additions & 23 deletions app/lib/drug/widgets/annotation_cards/disclaimer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,3 @@ class GuidelineDisclaimer extends StatelessWidget {
);
}
}

class DisclaimerRow extends StatelessWidget {
const DisclaimerRow({super.key, required this.icon, required this.text});

final Widget icon;
final Widget text;

@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
right: PharMeTheme.smallSpace,
),
child: icon,
),
Expanded(child: text),
],
);
}
}
2 changes: 1 addition & 1 deletion app/lib/onboarding/pages/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class OnboardingPage extends HookWidget {
color: Colors.grey.shade600,
bottom: DisclaimerCard(
iconWidget: IncludedContentIcon(
type: ListPageInclusionDescriptionType.medications,
type: ListInclusionDescriptionType.medications,
color: PharMeTheme.onSurfaceText,
size: OnboardingDimensions.iconSize,
),
Expand Down
6 changes: 3 additions & 3 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ class ReportPage extends HookWidget {
drugsToFilterBy: null,
onlyCurrentMedications: false,
);
final inclusionDescription = ListPageInclusionDescription(
final inclusionDescription = Padding(
key: Key('included-gene-explanation'),
type: ListPageInclusionDescriptionType.genes,
customPadding: EdgeInsets.only(
padding: EdgeInsets.only(
left: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace,
top: PharMeTheme.smallSpace * 1.5,
),
child: ListInclusionDescription.forGenes(),
);
if (currentMedicationGenes.isEmpty) {
return [
Expand Down

0 comments on commit d5899e7

Please sign in to comment.