More tuning

pull/324/head
Xin Yao 4 years ago
parent 2a92287c64
commit 6f7f0cc20c
  1. 7
      example/assets/sample_data.json
  2. 28
      lib/src/widgets/text_line.dart

@ -5,7 +5,7 @@
}, },
"attributes":{ "attributes":{
"width":"230", "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":{ "attributes":{
"width":"230", "width":"230",
"style":"display: block; margin: auto;" "style":"mobileWidth: 40; mobileHeight: 40; mobileMargin: 0; mobileAlignment: bottomLeft"
} }
}, },
{
"insert":"Bullet Journal"
},
{ {
"insert": "\n" "insert": "\n"
} }

@ -48,23 +48,21 @@ class TextLine extends StatelessWidget {
} }
// The line could contain more than one Embed & more than one Text // The line could contain more than one Embed & more than one Text
// TODO: handle more than one Embed final textSpanChildren = <InlineSpan>[];
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( textSpan = TextSpan(
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black), // TODO: figure out style
children: <InlineSpan>[ children: textSpanChildren);
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!'),
]);
} }
if (!line.hasEmbed) { if (!line.hasEmbed) {

Loading…
Cancel
Save