Skip to content

Commit

Permalink
Merge pull request #41 from CazSaa/feature/custom-richtext-styling
Browse files Browse the repository at this point in the history
feat: allow overriding text style for rich text
  • Loading branch information
PhiFry authored Sep 3, 2024
2 parents b99aa8e + 640e72d commit 603f3b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/src/widgets/rich_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ final class StoryblokRichText extends StatelessWidget {
void Function(Link)? onTapLink,
required BlockBuilder blockBuilder,
this.textAlign = TextAlign.start,
TextStyle Function(RichTextLeafMarkable)? textStyleOverrides,
}) : _contentData = _StoryblokRichTextContentData(
onTapLink: onTapLink,
buildBlok: blockBuilder,
textStyleOverrides: textStyleOverrides,
);

final _StoryblokRichTextContentData _contentData;
Expand All @@ -47,9 +49,11 @@ final class _StoryblokRichTextContentData {
_StoryblokRichTextContentData({
required this.onTapLink,
required this.buildBlok,
this.textStyleOverrides,
});
final void Function(Link)? onTapLink;
final BlockBuilder buildBlok;
final TextStyle Function(RichTextLeafMarkable)? textStyleOverrides;
}

// MARK: - Containers
Expand Down Expand Up @@ -179,7 +183,7 @@ extension _RichTextLeafMarkableWidget on RichTextLeafMarkable {
(link) => TapGestureRecognizer()..onTap = () => onTapLink(link),
),
),
style: buildTextStyle(),
style: buildTextStyle().merge(contentData.textStyleOverrides?.call(this)),
);
}
}

0 comments on commit 603f3b7

Please sign in to comment.