Skip to content

Commit

Permalink
add unordereditemwidget
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpengi committed Dec 15, 2023
1 parent c96be5d commit 81ef315
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions lib/widgets/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,42 @@ class ListNodeWidget extends StatelessWidget {
// see:
// https://html.spec.whatwg.org/multipage/rendering.html#lists
// https://www.w3.org/TR/css-counter-styles-3/#simple-symbolic
// TODO proper alignment of unordered marker; should be "• ", one space,
// but that comes out too close to item; not sure what's fixing that
// in a browser
case ListStyle.unordered: marker = "• "; break;
case ListStyle.unordered:
marker = "\u2022";
return ListUnorderedItemWidget(marker: marker, nodes: item);
// TODO(#59) ordered lists starting not at 1
case ListStyle.ordered: marker = "${index+1}. "; break;
case ListStyle.ordered:
marker = "${index+1}. ";
return ListItemWidget(marker: marker, nodes: item);
}
return ListItemWidget(marker: marker, nodes: item);
});
return Padding(
padding: const EdgeInsets.only(top: 2, bottom: 5),
padding: const EdgeInsets.only(bottom: 5),
child: Column(children: items));
}
}

class ListUnorderedItemWidget extends StatelessWidget {
const ListUnorderedItemWidget({super.key, required this.marker, required this.nodes});

final String marker;
final List<BlockContentNode> nodes;

@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
SizedBox(
width: 20,
child: Text(marker, textAlign: TextAlign.center)),
Expanded(child: BlockContentList(nodes: nodes)),
]);
}
}

class ListItemWidget extends StatelessWidget {
const ListItemWidget({super.key, required this.marker, required this.nodes});

Expand Down

0 comments on commit 81ef315

Please sign in to comment.