Skip to content

Commit

Permalink
feat(app): use row instead of rich text for guideline disclaimer
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 23, 2025
1 parent 1f41fa5 commit e826865
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void main() {
ValueKey('annotationCard'),
),
) as RoundedCard;
expect(find.byType(Disclaimer), findsOneWidget);
expect(find.byType(GuidelineDisclaimer), findsOneWidget);
final sourcesSection = find.byKey(Key('sourceCard'));
final context = tester.element(find.byType(Scaffold).first);
if (expectNoBrandNames) {
Expand Down
67 changes: 42 additions & 25 deletions app/lib/drug/widgets/annotation_cards/disclaimer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import '../../../common/module.dart';

class Disclaimer extends StatelessWidget {
const Disclaimer({ this.userGuideline });
class GuidelineDisclaimer extends StatelessWidget {
const GuidelineDisclaimer({ this.userGuideline });

final Guideline? userGuideline;

Expand All @@ -18,36 +18,53 @@ class Disclaimer extends StatelessWidget {
color: PharMeTheme.surfaceColor,
border: Border.all(color: PharMeTheme.errorColor, width: 1.2),
),
child: Text.rich(
TextSpan(children: [
WidgetSpan(
child: Icon(
child: Column(
children: [
DisclaimerRow(
icon: Icon(
Icons.warning_rounded,
size: PharMeTheme.mediumSpace,
color: PharMeTheme.errorColor,
),
text: Text(
context.l10n.drugs_page_main_disclaimer_text,
style: TextStyle(fontWeight: FontWeight.w600),
),
),
TextSpan(text: ' '),
TextSpan(
text: context.l10n.drugs_page_main_disclaimer_text,
style: TextStyle(fontWeight: FontWeight.w600),
SizedBox(height: PharMeTheme.smallSpace),
DisclaimerRow(
icon: Icon(
FontAwesomeIcons.puzzlePiece,
size: PharMeTheme.mediumSpace,
color: PharMeTheme.onSurfaceText,
),
text: Text(context.l10n.drugs_page_puzzle_disclaimer_text),
),
TextSpan(
children: [
TextSpan(text: '\n\n'),
WidgetSpan(
child: Icon(
FontAwesomeIcons.puzzlePiece,
size: PharMeTheme.mediumSpace,
color: PharMeTheme.onSurfaceText,
),
),
TextSpan(text: ' '),
TextSpan(text: context.l10n.drugs_page_puzzle_disclaimer_text),
],
)
]),
],
),
);
}
}

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/drug/widgets/annotation_cards/guideline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GuidelineAnnotationCard extends StatelessWidget {
SizedBox(height: PharMeTheme.smallToMediumSpace),
_buildSourcesSection(context),
SizedBox(height: PharMeTheme.mediumSpace),
Disclaimer(userGuideline: drug.userGuideline),
GuidelineDisclaimer(userGuideline: drug.userGuideline),
]
else ...[
_buildResultSection(context),
Expand Down

0 comments on commit e826865

Please sign in to comment.