Skip to content

Commit c765966

Browse files
committed
content: revise "unimplemented content" UX
1 parent 96a793c commit c765966

File tree

1 file changed

+49
-33
lines changed

1 file changed

+49
-33
lines changed

lib/widgets/content.dart

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,8 @@ class BlockContentList extends StatelessWidget {
378378
return const SizedBox.shrink();
379379
}(),
380380
WebsitePreviewNode() => WebsitePreview(node: node),
381-
UnimplementedBlockContentNode() =>
382-
Text.rich(_errorUnimplemented(node, context: context)),
381+
UnimplementedBlockContentNode() => ErrorUnimplemented(node: node),
383382
};
384-
385383
}),
386384
]);
387385
}
@@ -1302,7 +1300,8 @@ class _InlineContentBuilder {
13021300
child: GlobalTime(node: node, ambientTextStyle: widget.style));
13031301

13041302
case UnimplementedInlineContentNode():
1305-
return _errorUnimplemented(node, context: _context!);
1303+
return WidgetSpan(alignment: PlaceholderAlignment.middle,
1304+
child: ErrorUnimplemented(node: node));
13061305
}
13071306
}
13081307

@@ -1929,35 +1928,52 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
19291928
}
19301929
}
19311930

1932-
//
1933-
// Small helpers.
1934-
//
1931+
class ErrorUnimplemented extends StatelessWidget {
1932+
const ErrorUnimplemented({
1933+
super.key,
1934+
required this.node,
1935+
});
19351936

1936-
InlineSpan _errorUnimplemented(UnimplementedNode node, {required BuildContext context}) {
1937-
final contentTheme = ContentTheme.of(context);
1938-
final errorStyle = contentTheme.textStyleError;
1939-
final errorCodeStyle = contentTheme.textStyleErrorCode;
1940-
// For now this shows error-styled HTML code even in release mode,
1941-
// because release mode isn't yet about general users but developer demos,
1942-
// and we want to keep the demos honest.
1943-
// TODO(#194) think through UX for general release
1944-
// TODO(#1285) translate this
1945-
final htmlNode = node.htmlNode;
1946-
if (htmlNode is dom.Element) {
1947-
return TextSpan(children: [
1948-
TextSpan(text: "(unimplemented:", style: errorStyle),
1949-
TextSpan(text: htmlNode.outerHtml, style: errorCodeStyle),
1950-
TextSpan(text: ")", style: errorStyle),
1951-
]);
1952-
} else if (htmlNode is dom.Text) {
1953-
return TextSpan(children: [
1954-
TextSpan(text: "(unimplemented: text «", style: errorStyle),
1955-
TextSpan(text: htmlNode.text, style: errorCodeStyle),
1956-
TextSpan(text: "»)", style: errorStyle),
1957-
]);
1958-
} else {
1959-
return TextSpan(
1960-
text: "(unimplemented: DOM node type ${htmlNode.nodeType})",
1961-
style: errorStyle);
1937+
final UnimplementedNode node;
1938+
1939+
@override
1940+
Widget build(BuildContext context) {
1941+
final zulipLocalizations = ZulipLocalizations.of(context);
1942+
final htmlNode = node.htmlNode;
1943+
final text = htmlNode is dom.Element ? htmlNode.outerHtml : htmlNode.text ?? '';
1944+
final header = [
1945+
ParagraphNode(
1946+
links: null,
1947+
nodes: [TextNode(zulipLocalizations.errorUnimplementedHeader)],
1948+
),
1949+
];
1950+
final content = [
1951+
HeadingNode(
1952+
links: null,
1953+
nodes: [TextNode(zulipLocalizations.errorUnimplementedWhatHappened)],
1954+
level: HeadingLevel.h3,
1955+
),
1956+
ParagraphNode(
1957+
links: null,
1958+
nodes: [TextNode(zulipLocalizations.errorUnimplementedDescription)],
1959+
),
1960+
HeadingNode(
1961+
links: null,
1962+
nodes: [TextNode(zulipLocalizations.errorUnimplementedHtmlHeading)],
1963+
level: HeadingLevel.h3,
1964+
),
1965+
ParagraphNode(
1966+
links: null,
1967+
nodes: [InlineCodeNode(nodes: [TextNode(text)])],
1968+
),
1969+
];
1970+
return Modal(
1971+
borderColor: const Color(0xffbb0000),
1972+
expandIconColor: const Color(0xffffff00),
1973+
textColor: const Color(0xffffff00),
1974+
bgColor: const Color(0xffff0000),
1975+
header: header,
1976+
content: content,
1977+
);
19621978
}
19631979
}

0 commit comments

Comments
 (0)