mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-25 19:46:47 +08:00
@@ -17,6 +17,7 @@ import 'package:PiliPlus/models/dynamics/result.dart' show DynamicStat;
|
||||
import 'package:PiliPlus/pages/article/controller.dart';
|
||||
import 'package:PiliPlus/pages/article/widgets/html_render.dart';
|
||||
import 'package:PiliPlus/pages/article/widgets/opus_content.dart';
|
||||
import 'package:PiliPlus/pages/article/widgets/read_opus.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
||||
@@ -360,6 +361,10 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
child: moduleBlockedItem(theme, moduleBlocked, maxWidth),
|
||||
);
|
||||
} else if (_articleCtr.articleData?.content != null) {
|
||||
if (_articleCtr.articleData?.type == 3) {
|
||||
// json
|
||||
return ReadOpus(ops: _articleCtr.articleData?.ops);
|
||||
}
|
||||
debugPrint('html page');
|
||||
final res = parser.parse(_articleCtr.articleData!.content!);
|
||||
if (res.body!.children.isEmpty) {
|
||||
|
||||
77
lib/pages/article/widgets/read_opus.dart
Normal file
77
lib/pages/article/widgets/read_opus.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_opus/opus.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/widgets/vote.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ReadOpus extends StatelessWidget {
|
||||
const ReadOpus({super.key, required this.ops});
|
||||
|
||||
final List<ReadOpusModel>? ops;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (ops.isNullOrEmpty) {
|
||||
return const SliverToBoxAdapter();
|
||||
}
|
||||
|
||||
return SliverList.separated(
|
||||
itemCount: ops!.length,
|
||||
itemBuilder: (context, index) {
|
||||
try {
|
||||
final item = ops![index];
|
||||
if (item.insert is String) {
|
||||
return SelectableText(item.insert);
|
||||
}
|
||||
|
||||
if (item.insert is Insert) {
|
||||
InsertCard card = item.insert.card;
|
||||
if (card.url?.isNotEmpty == true) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
switch (item.attributes?.clazz) {
|
||||
case 'article-card card':
|
||||
if (card.id != null) {
|
||||
Get.toNamed(
|
||||
'/articlePage',
|
||||
parameters: {
|
||||
'id': card.id!.substring(2),
|
||||
'type': 'read',
|
||||
},
|
||||
);
|
||||
}
|
||||
case 'video-card card':
|
||||
if (card.id != null) {
|
||||
PiliScheme.videoPush(null, card.id);
|
||||
}
|
||||
case 'vote-card card':
|
||||
if (card.id != null) {
|
||||
showVoteDialog(context, card.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: Utils.thumbnailImgUrl(card.url, 60),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Text('${item.attributes}');
|
||||
} catch (e) {
|
||||
return Text(e.toString());
|
||||
}
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const SizedBox(height: 10);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
||||
children: [
|
||||
if (upPanelPosition == UpPanelPosition.top) upPanelPart(theme),
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
child: videoTabBarView(
|
||||
controller: _dynamicsController.tabController,
|
||||
children: _dynamicsController.tabsPageList,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user