Skip to content
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
21 changes: 13 additions & 8 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,24 @@ class HtmlParser extends StatelessWidget {
style: tree.style,
shrinkWrap: context.parser.shrinkWrap,
child: Stack(
children: <Widget>[
PositionedDirectional(
width: 30, //TODO derive this from list padding.
start: 0,
child: Text('${newContext.style.markerContent}\t',
textAlign: TextAlign.end,
style: newContext.style.generateTextStyle()),
),
children: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much prettier! I'll test this out tomorrow and get it merged

if (tree.style?.listStylePosition == ListStylePosition.OUTSIDE || tree.style?.listStylePosition == null)
PositionedDirectional(
width: 30, //TODO derive this from list padding.
start: 0,
child: Text('${newContext.style.markerContent}\t',
textAlign: TextAlign.right,
style: newContext.style.generateTextStyle()),
),
Padding(
padding: EdgeInsetsDirectional.only(
start: 30), //TODO derive this from list padding.
child: StyledText(
textSpan: TextSpan(
text: (tree.style?.listStylePosition ==
ListStylePosition.INSIDE)
? '${newContext.style.markerContent}\t'
: null,
children: tree.children
?.map((tree) => parseTree(newContext, tree))
?.toList() ??
Expand Down
16 changes: 16 additions & 0 deletions lib/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ class Style {
/// Default: ListStyleType.DISC
ListStyleType listStyleType;

/// CSS attribute "`list-style-position`"
///
/// Inherited: yes,
/// Default: ListStylePosition.OUTSIDE
ListStylePosition listStylePosition;

/// CSS attribute "`padding`"
///
/// Inherited: no,
Expand Down Expand Up @@ -183,6 +189,7 @@ class Style {
this.lineHeight,
this.letterSpacing,
this.listStyleType,
this.listStylePosition,
this.padding,
this.margin,
this.textAlign,
Expand Down Expand Up @@ -251,6 +258,7 @@ class Style {
lineHeight: other.lineHeight,
letterSpacing: other.letterSpacing,
listStyleType: other.listStyleType,
listStylePosition: other.listStylePosition,
padding: other.padding,
//TODO merge EdgeInsets
margin: other.margin,
Expand Down Expand Up @@ -288,6 +296,7 @@ class Style {
fontWeight: child.fontWeight ?? fontWeight,
letterSpacing: child.letterSpacing ?? letterSpacing,
listStyleType: child.listStyleType ?? listStyleType,
listStylePosition: child.listStylePosition ?? listStylePosition,
textAlign: child.textAlign ?? textAlign,
textShadow: child.textShadow ?? textShadow,
whiteSpace: child.whiteSpace ?? whiteSpace,
Expand All @@ -309,6 +318,7 @@ class Style {
double lineHeight,
double letterSpacing,
ListStyleType listStyleType,
ListStylePosition listStylePosition,
EdgeInsets padding,
EdgeInsets margin,
TextAlign textAlign,
Expand Down Expand Up @@ -341,6 +351,7 @@ class Style {
lineHeight: lineHeight ?? this.lineHeight,
letterSpacing: letterSpacing ?? this.letterSpacing,
listStyleType: listStyleType ?? this.listStyleType,
listStylePosition: listStylePosition ?? this.listStylePosition,
padding: padding ?? this.padding,
margin: margin ?? this.margin,
textAlign: textAlign ?? this.textAlign,
Expand Down Expand Up @@ -421,6 +432,11 @@ enum ListStyleType {
DECIMAL,
}

enum ListStylePosition {
OUTSIDE,
INSIDE,
}

enum VerticalAlign {
BASELINE,
SUB,
Expand Down