@@ -46,10 +46,16 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
46
46
fontFamilyFallback: defaultFontFamilyFallback,
47
47
)
48
48
.merge (weightVariableTextStyle (context))
49
- .copyWith (debugLabel: 'ContentTheme.textStylePlainParagraph' );
49
+ .copyWith (debugLabel: 'ContentTheme.textStylePlainParagraph' ),
50
+ textStyleError = const TextStyle (
51
+ fontSize: kBaseFontSize, fontWeight: FontWeight .bold, color: Colors .red),
52
+ textStyleErrorCode = kMonospaceTextStyle
53
+ .merge (const TextStyle (fontSize: kBaseFontSize, color: Colors .red));
50
54
51
55
ContentTheme ._({
52
56
required this .textStylePlainParagraph,
57
+ required this .textStyleError,
58
+ required this .textStyleErrorCode,
53
59
});
54
60
55
61
/// The [ContentTheme] from the context's active theme.
@@ -70,12 +76,19 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
70
76
/// should not need styles from other sources, such as Material defaults.
71
77
final TextStyle textStylePlainParagraph;
72
78
79
+ final TextStyle textStyleError;
80
+ final TextStyle textStyleErrorCode;
81
+
73
82
@override
74
83
ContentTheme copyWith ({
75
84
TextStyle ? textStylePlainParagraph,
85
+ TextStyle ? textStyleError,
86
+ TextStyle ? textStyleErrorCode,
76
87
}) {
77
88
return ContentTheme ._(
78
89
textStylePlainParagraph: textStylePlainParagraph ?? this .textStylePlainParagraph,
90
+ textStyleError: textStyleError ?? this .textStyleError,
91
+ textStyleErrorCode: textStyleErrorCode ?? this .textStyleErrorCode,
79
92
);
80
93
}
81
94
@@ -86,6 +99,8 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
86
99
}
87
100
return ContentTheme ._(
88
101
textStylePlainParagraph: TextStyle .lerp (textStylePlainParagraph, other? .textStylePlainParagraph, t)! ,
102
+ textStyleError: TextStyle .lerp (textStyleError, other? .textStyleError, t)! ,
103
+ textStyleErrorCode: TextStyle .lerp (textStyleErrorCode, other? .textStyleErrorCode, t)! ,
89
104
);
90
105
}
91
106
}
@@ -175,7 +190,7 @@ class BlockContentList extends StatelessWidget {
175
190
} else if (node is EmbedVideoNode ) {
176
191
return MessageEmbedVideo (node: node);
177
192
} else if (node is UnimplementedBlockContentNode ) {
178
- return Text .rich (_errorUnimplemented (node));
193
+ return Text .rich (_errorUnimplemented (node, context : context ));
179
194
} else {
180
195
// TODO(dart-3): Use a sealed class / pattern-matching to exclude this.
181
196
throw Exception ("impossible BlockContentNode: ${node .debugHtmlText }" );
@@ -836,7 +851,7 @@ class _InlineContentBuilder {
836
851
return WidgetSpan (alignment: PlaceholderAlignment .middle,
837
852
child: GlobalTime (node: node, ambientTextStyle: widget.style));
838
853
} else if (node is UnimplementedInlineContentNode ) {
839
- return _errorUnimplemented (node);
854
+ return _errorUnimplemented (node, context : _context ! );
840
855
} else {
841
856
// TODO(dart-3): Use a sealed class / pattern matching to eliminate this case.
842
857
throw Exception ("impossible InlineContentNode: ${node .debugHtmlText }" );
@@ -1326,33 +1341,30 @@ class AvatarShape extends StatelessWidget {
1326
1341
// Small helpers.
1327
1342
//
1328
1343
1329
- InlineSpan _errorUnimplemented (UnimplementedNode node) {
1344
+ InlineSpan _errorUnimplemented (UnimplementedNode node, {required BuildContext context}) {
1345
+ final contentTheme = ContentTheme .of (context);
1346
+ final errorStyle = contentTheme.textStyleError;
1347
+ final errorCodeStyle = contentTheme.textStyleErrorCode;
1330
1348
// For now this shows error-styled HTML code even in release mode,
1331
1349
// because release mode isn't yet about general users but developer demos,
1332
1350
// and we want to keep the demos honest.
1333
1351
// TODO(#194) think through UX for general release
1334
1352
final htmlNode = node.htmlNode;
1335
1353
if (htmlNode is dom.Element ) {
1336
1354
return TextSpan (children: [
1337
- const TextSpan (text: "(unimplemented:" , style: errorStyle),
1355
+ TextSpan (text: "(unimplemented:" , style: errorStyle),
1338
1356
TextSpan (text: htmlNode.outerHtml, style: errorCodeStyle),
1339
- const TextSpan (text: ")" , style: errorStyle),
1357
+ TextSpan (text: ")" , style: errorStyle),
1340
1358
]);
1341
1359
} else if (htmlNode is dom.Text ) {
1342
1360
return TextSpan (children: [
1343
- const TextSpan (text: "(unimplemented: text «" , style: errorStyle),
1361
+ TextSpan (text: "(unimplemented: text «" , style: errorStyle),
1344
1362
TextSpan (text: htmlNode.text, style: errorCodeStyle),
1345
- const TextSpan (text: "»)" , style: errorStyle),
1363
+ TextSpan (text: "»)" , style: errorStyle),
1346
1364
]);
1347
1365
} else {
1348
1366
return TextSpan (
1349
1367
text: "(unimplemented: DOM node type ${htmlNode .nodeType })" ,
1350
1368
style: errorStyle);
1351
1369
}
1352
1370
}
1353
-
1354
- const errorStyle = TextStyle (
1355
- fontSize: kBaseFontSize, fontWeight: FontWeight .bold, color: Colors .red);
1356
-
1357
- final errorCodeStyle = kMonospaceTextStyle
1358
- .merge (const TextStyle (fontSize: kBaseFontSize, color: Colors .red));
0 commit comments