feat: read专栏内容渲染

This commit is contained in:
guozhigq
2024-09-26 23:45:58 +08:00
parent 1ed098fd81
commit 71566ba064
13 changed files with 856 additions and 60 deletions

View File

@ -17,26 +17,46 @@ class TextHelper {
static TextSpan buildTextSpan(
ModuleParagraphTextNode node, int? align, BuildContext context) {
switch (node.type) {
case 'TEXT_NODE_TYPE_WORD':
return TextSpan(
text: node.word?.words ?? '',
style: TextStyle(
fontSize:
node.word?.fontSize != null ? node.word!.fontSize! * 0.95 : 14,
fontWeight: node.word?.style?.bold != null
? FontWeight.bold
: FontWeight.normal,
height: align == 1 ? 2 : 1.5,
color: node.word?.color != null
? Color(
int.parse(node.word!.color!.substring(1, 7), radix: 16) +
0xFF000000)
: Theme.of(context).colorScheme.onBackground,
),
);
default:
return const TextSpan(text: '');
// 获取node的所有key
if (node.nodeType != null) {
return TextSpan(
text: node.word?.words ?? '',
style: TextStyle(
fontSize:
node.word?.fontSize != null ? node.word!.fontSize! * 0.95 : 14,
fontWeight: node.word?.style?.bold != null
? FontWeight.bold
: FontWeight.normal,
height: align == 1 ? 2 : 1.5,
color: node.word?.color != null
? Color(int.parse(node.word!.color!.substring(1, 7), radix: 16) +
0xFF000000)
: Theme.of(context).colorScheme.onBackground,
),
);
} else {
switch (node.type) {
case 'TEXT_NODE_TYPE_WORD':
return TextSpan(
text: node.word?.words ?? '',
style: TextStyle(
fontSize: node.word?.fontSize != null
? node.word!.fontSize! * 0.95
: 14,
fontWeight: node.word?.style?.bold != null
? FontWeight.bold
: FontWeight.normal,
height: align == 1 ? 2 : 1.5,
color: node.word?.color != null
? Color(
int.parse(node.word!.color!.substring(1, 7), radix: 16) +
0xFF000000)
: Theme.of(context).colorScheme.onBackground,
),
);
default:
return const TextSpan(text: '');
}
}
}
}