Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Lists and upgrade List support to CSS3 #1161

Merged
merged 3 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 11 additions & 89 deletions lib/custom_render.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,84 +154,20 @@ CustomRender blockElementRender({Style? style, List<InlineSpan>? children}) =>
});

CustomRender listElementRender(
{Style? style, Widget? child, List<InlineSpan>? children}) =>
CustomRender.inlineSpan(
inlineSpan: (context, buildChildren) => WidgetSpan(
child: CssBoxWidget(
{Style? style, Widget? child, List<InlineSpan>? children}) {
return CustomRender.inlineSpan(
inlineSpan: (context, buildChildren) {
return WidgetSpan(
child: CssBoxWidget.withInlineSpanChildren(
key: context.key,
style: style ?? context.tree.style,
style: style ?? context.style,
shrinkWrap: context.parser.shrinkWrap,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
textDirection: style?.direction ?? context.tree.style.direction,
children: [
(style?.listStylePosition ??
context.tree.style.listStylePosition) ==
ListStylePosition.outside
? Padding(
padding: style?.padding?.nonNegative ??
context.tree.style.padding?.nonNegative ??
EdgeInsets.only(
left: (style?.direction ??
context.tree.style.direction) !=
TextDirection.rtl
? 10.0
: 0.0,
right: (style?.direction ??
context.tree.style.direction) ==
TextDirection.rtl
? 10.0
: 0.0),
child:
style?.markerContent ?? context.style.markerContent)
: const SizedBox(height: 0, width: 0),
const Text("\u0020",
textAlign: TextAlign.right,
style: TextStyle(fontWeight: FontWeight.w400)),
Expanded(
child: Padding(
padding: (style?.listStylePosition ??
context.tree.style.listStylePosition) ==
ListStylePosition.inside
? EdgeInsets.only(
left: (style?.direction ??
context.tree.style.direction) !=
TextDirection.rtl
? 10.0
: 0.0,
right: (style?.direction ??
context.tree.style.direction) ==
TextDirection.rtl
? 10.0
: 0.0)
: EdgeInsets.zero,
child: CssBoxWidget.withInlineSpanChildren(
children: _getListElementChildren(
style?.listStylePosition ??
context.tree.style.listStylePosition,
buildChildren)
..insertAll(
0,
context.tree.style.listStylePosition ==
ListStylePosition.inside
? [
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: style?.markerContent ??
context.style.markerContent ??
const SizedBox(height: 0, width: 0))
]
: []),
style: style ?? context.style,
),
),
),
],
),
children: buildChildren(),
),
),
);
);
},
);
}

CustomRender replacedElementRender(
{PlaceholderAlignment? alignment,
Expand Down Expand Up @@ -517,20 +453,6 @@ Map<CustomRenderMatcher, CustomRender> generateDefaultRenders() {
};
}

List<InlineSpan> _getListElementChildren(
ListStylePosition? position, Function() buildChildren) {
List<InlineSpan> children = buildChildren.call();
if (position == ListStylePosition.inside) {
const tabSpan = WidgetSpan(
child: Text("\t",
textAlign: TextAlign.right,
style: TextStyle(fontWeight: FontWeight.w400)),
);
children.insert(0, tabSpan);
}
return children;
}

InlineSpan _getInteractableChildren(RenderContext context,
InteractableElement tree, InlineSpan childSpan, TextStyle childStyle) {
if (childSpan is TextSpan) {
Expand Down
Loading