alexeyinkin commented on code in PR #23662:
URL: https://github.com/apache/beam/pull/23662#discussion_r997947837
##########
learning/tour-of-beam/frontend/lib/pages/tour/widgets/unit_content.dart:
##########
@@ -30,6 +32,76 @@ class UnitContentWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return MarkdownBody(data: unitContent.description);
+ final textTheme = Theme.of(context).textTheme;
+ final markdownStyle = MarkdownStyleSheet(
+ h1: textTheme.headlineLarge,
+ h3: textTheme.headlineMedium,
+ p: textTheme.bodyMedium,
+ code: Theme.of(context)
+ .extension<BeamThemeExtension>()!
+ .codeRootStyle
+ .copyWith(
+ backgroundColor: BeamColors.transparent,
+ fontSize: BeamSizes.size12,
+ ),
+ codeblockDecoration: BoxDecoration(
+ // TODO(nausharipov): where to store these colors?
+ color: Theme.of(context).brightness == Brightness.dark
+ ? BeamDarkThemeColors.codeBackground
+ : BeamLightThemeColors.codeBackground,
+ border: Border.all(color: Theme.of(context).primaryColor),
+ borderRadius: const BorderRadius.all(
+ Radius.circular(BeamSizes.size4),
+ ),
+ ),
+ );
+
+ return Markdown(
+ selectable: true,
+ data: unitContent.description,
+ builders: {
+ 'code': CodeBuilder(),
+ },
+ styleSheet: markdownStyle,
+ );
+ }
+}
+
+class CodeBuilder extends MarkdownElementBuilder {
+ @override
+ Widget? visitElementAfter(md.Element element, TextStyle? preferredStyle) {
+ final String textContent = element.textContent;
+ final bool isMultilineCode = textContent.contains('\n');
Review Comment:
This comment is irrelevant to our task.
Please revert to `\n` detection, it is more reliable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]