mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: article: show list
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -339,7 +339,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
() {
|
||||
if (_articleCtr.isLoaded.value) {
|
||||
if (_articleCtr.type == 'read') {
|
||||
var res = parser.parse(_articleCtr.articleData.content);
|
||||
late final res = parser.parse(_articleCtr.articleData.content);
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
if (_articleCtr.articleData.title != null)
|
||||
@@ -403,19 +403,26 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverList.separated(
|
||||
itemCount: res.body!.children.length,
|
||||
itemBuilder: (context, index) {
|
||||
return htmlRender(
|
||||
context: context,
|
||||
element: res.body!.children[index],
|
||||
maxWidth: maxWidth,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(height: 10),
|
||||
),
|
||||
_articleCtr.articleData.modules?.isNotEmpty == true
|
||||
? opusContent(
|
||||
context: context,
|
||||
modules: _articleCtr.articleData.modules,
|
||||
callback: _getImageCallback,
|
||||
maxWidth: maxWidth,
|
||||
)
|
||||
: SliverList.separated(
|
||||
itemCount: res.body!.children.length,
|
||||
itemBuilder: (context, index) {
|
||||
return htmlRender(
|
||||
context: context,
|
||||
element: res.body!.children[index],
|
||||
maxWidth: maxWidth,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(height: 10),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:re_highlight/languages/all.dart';
|
||||
import 'package:re_highlight/re_highlight.dart';
|
||||
import 'package:re_highlight/styles/all.dart';
|
||||
@@ -95,7 +96,7 @@ Widget opusContent({
|
||||
itemBuilder: (context, index) {
|
||||
final element = item.moduleContent!.paragraphs![index];
|
||||
|
||||
if ((element.paraType == 1 || element.paraType == 4)) {
|
||||
if (element.paraType == 1 || element.paraType == 4) {
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
@@ -117,7 +118,7 @@ Widget opusContent({
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (item.rich!.jumpUrl != null) {
|
||||
if (item.rich?.jumpUrl != null) {
|
||||
PiliScheme.routePushFromUrl(
|
||||
item.rich!.jumpUrl!);
|
||||
}
|
||||
@@ -182,6 +183,53 @@ Widget opusContent({
|
||||
);
|
||||
}
|
||||
|
||||
if (element.paraType == 5) {
|
||||
return SelectableText.rich(
|
||||
TextSpan(
|
||||
children:
|
||||
element.list?.items?.asMap().entries.map((entry) {
|
||||
return TextSpan(
|
||||
children: [
|
||||
WidgetSpan(
|
||||
child: Icon(MdiIcons.circleMedium),
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
),
|
||||
...entry.value.nodes!.map((item) {
|
||||
return TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration:
|
||||
item.word?.style?.strikethrough ==
|
||||
true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle:
|
||||
item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
if (entry.key < element.list!.items!.length - 1)
|
||||
TextSpan(text: '\n'),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (element.paraType == 6) {
|
||||
if (element.linkCard?.card?.ugc != null) {
|
||||
return Material(
|
||||
@@ -263,6 +311,33 @@ Widget opusContent({
|
||||
);
|
||||
}
|
||||
|
||||
if (element.text?.nodes?.isNotEmpty == true) {
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text!.nodes!.map<TextSpan>((item) {
|
||||
return TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration: item.word?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
|
||||
Reference in New Issue
Block a user