diff --git a/example/assets/sample_data.json b/example/assets/sample_data.json index ac8509e8..f73d647f 100644 --- a/example/assets/sample_data.json +++ b/example/assets/sample_data.json @@ -5,7 +5,7 @@ }, "attributes":{ "width":"230", - "style":"display: block; margin: auto; mobileWidth: 50; mobileHeight: 50; mobileMargin: 10; mobileAlignment: topLeft" + "style":"display: block; margin: auto; mobileWidth: 40; mobileHeight: 40; mobileMargin: 0; mobileAlignment: bottomRight" } }, { @@ -17,9 +17,12 @@ }, "attributes":{ "width":"230", - "style":"display: block; margin: auto;" + "style":"mobileWidth: 40; mobileHeight: 40; mobileMargin: 0; mobileAlignment: bottomLeft" } }, + { + "insert":"Bullet Journal" + }, { "insert": "\n" } diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index f9a677b6..a78d3939 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/text_line.dart @@ -48,23 +48,21 @@ class TextLine extends StatelessWidget { } // The line could contain more than one Embed & more than one Text - // TODO: handle more than one Embed + final textSpanChildren = []; + for (final child in line.children) { + var inlineSpan; + if (child is Embed) { + inlineSpan = WidgetSpan( + child: EmbedProxy(embedBuilder(context, child, readOnly))); + } else { + inlineSpan = _getTextSpanFromNode(styles, child); + } + textSpanChildren.add(inlineSpan); + } textSpan = TextSpan( - style: const TextStyle(color: Colors.black), - children: [ - const TextSpan(text: 'Flutter is'), - WidgetSpan( - child: SizedBox( - width: 50, - height: 50, - child: Image.network( - 'https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png', - fit: BoxFit.cover, - ), - )), - const TextSpan(text: 'the best!'), - ]); + style: const TextStyle(color: Colors.black), // TODO: figure out style + children: textSpanChildren); } if (!line.hasEmbed) {