mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: article
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPalaX/models/dynamics/article_content_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
|
||||
class ArticleContent extends StatelessWidget {
|
||||
const ArticleContent({
|
||||
super.key,
|
||||
required this.htmlContent,
|
||||
required this.list,
|
||||
});
|
||||
|
||||
final dynamic htmlContent;
|
||||
final List<ArticleContentModel> list;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<ArticleContentModel> list = (htmlContent['ops'] as List)
|
||||
.map((item) => ArticleContentModel.fromJson(item))
|
||||
.toList();
|
||||
return SliverList.separated(
|
||||
itemCount: list.length,
|
||||
itemBuilder: (_, index) {
|
||||
ArticleContentModel item = list[index];
|
||||
if (item.insert is String) {
|
||||
return Text(
|
||||
item.insert,
|
||||
return SelectableText(
|
||||
(item.insert as String).replaceAll('\n', '\n\n'),
|
||||
style: TextStyle(
|
||||
letterSpacing: 0.3,
|
||||
fontSize: FontSize.large.value,
|
||||
height: LineHeight.percent(125).size,
|
||||
fontWeight:
|
||||
item.attributes?.bold == true ? FontWeight.bold : null,
|
||||
),
|
||||
@@ -48,7 +49,8 @@ class ArticleContent extends StatelessWidget {
|
||||
// ],
|
||||
// );
|
||||
} else {
|
||||
return Text('unsupported content');
|
||||
return const SizedBox.shrink();
|
||||
// return Text('unsupported content');
|
||||
}
|
||||
},
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 10),
|
||||
|
||||
@@ -59,7 +59,7 @@ class HtmlRender extends StatelessWidget {
|
||||
// height: isEmote ? 22 : null,
|
||||
// );
|
||||
return NetworkImgLayer(
|
||||
width: isEmote ? 22 : constrainedWidth / textScale,
|
||||
width: isEmote ? 22 : constrainedWidth,
|
||||
height: isEmote ? 22 : 200,
|
||||
src: imgUrl,
|
||||
ignoreHeight: !isEmote,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/article_content.dart';
|
||||
import 'package:PiliPalaX/models/dynamics/article_content_model.dart';
|
||||
import 'package:html/dom.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'index.dart';
|
||||
@@ -114,7 +116,9 @@ class HtmlHttp {
|
||||
try {
|
||||
opusContent = jsonDecode(jsonString)['readInfo']['content'];
|
||||
try {
|
||||
opusContent = jsonDecode(opusContent);
|
||||
opusContent = (jsonDecode(opusContent)['ops'] as List)
|
||||
.map((item) => ArticleContentModel.fromJson(item))
|
||||
.toList();
|
||||
isJsonContent = true;
|
||||
} catch (e) {
|
||||
print('second: $e');
|
||||
|
||||
@@ -446,7 +446,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
() => _htmlRenderCtr.loaded.value
|
||||
? _htmlRenderCtr.response['isJsonContent'] == true
|
||||
? ArticleContent(
|
||||
htmlContent: _htmlRenderCtr.response['content'],
|
||||
list: _htmlRenderCtr.response['content'],
|
||||
)
|
||||
: SliverToBoxAdapter(
|
||||
child: LayoutBuilder(
|
||||
|
||||
Reference in New Issue
Block a user