feat: 转发动态评论渲染
This commit is contained in:
@ -40,9 +40,13 @@ class HtmlHttp {
|
|||||||
//
|
//
|
||||||
String opusContent =
|
String opusContent =
|
||||||
opusDetail.querySelector('.opus-module-content')!.innerHtml;
|
opusDetail.querySelector('.opus-module-content')!.innerHtml;
|
||||||
String test = opusDetail
|
String? test;
|
||||||
.querySelector('.horizontal-scroll-album__pic__img')!
|
try {
|
||||||
.innerHtml;
|
test = opusDetail
|
||||||
|
.querySelector('.horizontal-scroll-album__pic__img')!
|
||||||
|
.innerHtml;
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
String commentId = opusDetail
|
String commentId = opusDetail
|
||||||
.querySelector('.bili-comment-container')!
|
.querySelector('.bili-comment-container')!
|
||||||
.className
|
.className
|
||||||
@ -54,7 +58,7 @@ class HtmlHttp {
|
|||||||
'avatar': avatar,
|
'avatar': avatar,
|
||||||
'uname': uname,
|
'uname': uname,
|
||||||
'updateTime': updateTime,
|
'updateTime': updateTime,
|
||||||
'content': test + opusContent,
|
'content': (test ?? '') + opusContent,
|
||||||
'commentId': int.parse(commentId)
|
'commentId': int.parse(commentId)
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -78,12 +78,14 @@ class ItemModulesModel {
|
|||||||
this.moduleDynamic,
|
this.moduleDynamic,
|
||||||
// this.moduleInter,
|
// this.moduleInter,
|
||||||
this.moduleStat,
|
this.moduleStat,
|
||||||
|
this.moduleTag,
|
||||||
});
|
});
|
||||||
|
|
||||||
ModuleAuthorModel? moduleAuthor;
|
ModuleAuthorModel? moduleAuthor;
|
||||||
ModuleDynamicModel? moduleDynamic;
|
ModuleDynamicModel? moduleDynamic;
|
||||||
// ModuleInterModel? moduleInter;
|
// ModuleInterModel? moduleInter;
|
||||||
ModuleStatModel? moduleStat;
|
ModuleStatModel? moduleStat;
|
||||||
|
Map? moduleTag;
|
||||||
|
|
||||||
ItemModulesModel.fromJson(Map<String, dynamic> json) {
|
ItemModulesModel.fromJson(Map<String, dynamic> json) {
|
||||||
moduleAuthor = json['module_author'] != null
|
moduleAuthor = json['module_author'] != null
|
||||||
@ -96,6 +98,7 @@ class ItemModulesModel {
|
|||||||
moduleStat = json['module_stat'] != null
|
moduleStat = json['module_stat'] != null
|
||||||
? ModuleStatModel.fromJson(json['module_stat'])
|
? ModuleStatModel.fromJson(json['module_stat'])
|
||||||
: null;
|
: null;
|
||||||
|
moduleTag = json['module_tag'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/http/html.dart';
|
||||||
import 'package:pilipala/http/reply.dart';
|
import 'package:pilipala/http/reply.dart';
|
||||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||||
import 'package:pilipala/models/video/reply/item.dart';
|
import 'package:pilipala/models/video/reply/item.dart';
|
||||||
@ -103,4 +104,10 @@ class DynamicDetailController extends GetxController {
|
|||||||
replyList.clear();
|
replyList.clear();
|
||||||
queryReplyList(reqType: 'init');
|
queryReplyList(reqType: 'init');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据jumpUrl获取动态html
|
||||||
|
reqHtmlByOpusId(int id) async {
|
||||||
|
var res = await HtmlHttp.reqHtml(id, 'opus');
|
||||||
|
oid = res['commentId'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:pilipala/common/skeleton/video_reply.dart';
|
import 'package:pilipala/common/skeleton/video_reply.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/models/common/reply_type.dart';
|
import 'package:pilipala/models/common/reply_type.dart';
|
||||||
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
import 'package:pilipala/pages/dynamics/deatil/index.dart';
|
import 'package:pilipala/pages/dynamics/deatil/index.dart';
|
||||||
import 'package:pilipala/pages/dynamics/widgets/author_panel.dart';
|
import 'package:pilipala/pages/dynamics/widgets/author_panel.dart';
|
||||||
import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart';
|
import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart';
|
||||||
@ -35,39 +36,17 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
bool _visibleTitle = false;
|
bool _visibleTitle = false;
|
||||||
String? action;
|
String? action;
|
||||||
// 回复类型
|
// 回复类型
|
||||||
late int type;
|
late int replyType;
|
||||||
bool _isFabVisible = true;
|
bool _isFabVisible = true;
|
||||||
|
int oid = 0;
|
||||||
|
int? opusId;
|
||||||
|
bool isOpusId = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
int oid = 0;
|
|
||||||
// floor 1原创 2转发
|
// floor 1原创 2转发
|
||||||
if (Get.arguments['floor'] == 1) {
|
init();
|
||||||
oid = int.parse(Get.arguments['item'].basic!['comment_id_str']);
|
|
||||||
print(oid);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
String type = Get.arguments['item'].modules.moduleDynamic.major.type;
|
|
||||||
|
|
||||||
/// TODO
|
|
||||||
if (type == 'MAJOR_TYPE_OPUS') {
|
|
||||||
} else {
|
|
||||||
oid = Get.arguments['item'].modules.moduleDynamic.major.draw.id;
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
int commentType = 11;
|
|
||||||
try {
|
|
||||||
commentType = Get.arguments['item'].basic!['comment_type'];
|
|
||||||
} catch (_) {}
|
|
||||||
type = (commentType == 0) ? 11 : commentType;
|
|
||||||
|
|
||||||
action =
|
|
||||||
Get.arguments.containsKey('action') ? Get.arguments['action'] : null;
|
|
||||||
_dynamicDetailController =
|
|
||||||
Get.put(DynamicDetailController(oid, type), tag: oid.toString());
|
|
||||||
_futureBuilderFuture = _dynamicDetailController.queryReplyList();
|
|
||||||
titleStreamC = StreamController<bool>();
|
titleStreamC = StreamController<bool>();
|
||||||
if (action == 'comment') {
|
if (action == 'comment') {
|
||||||
_visibleTitle = true;
|
_visibleTitle = true;
|
||||||
@ -83,6 +62,49 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
scrollListener();
|
scrollListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 页面初始化
|
||||||
|
void init() async {
|
||||||
|
Map args = Get.arguments;
|
||||||
|
// 楼层
|
||||||
|
int floor = args['floor'];
|
||||||
|
// 从action栏点击进入
|
||||||
|
action = args.containsKey('action') ? args['action'] : null;
|
||||||
|
// 评论类型
|
||||||
|
int commentType = args['item'].basic!['comment_type'] ?? 11;
|
||||||
|
replyType = (commentType == 0) ? 11 : commentType;
|
||||||
|
|
||||||
|
if (floor == 1) {
|
||||||
|
oid = int.parse(args['item'].basic!['comment_id_str']);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
ModuleDynamicModel moduleDynamic = args['item'].modules.moduleDynamic;
|
||||||
|
String majorType = moduleDynamic.major!.type!;
|
||||||
|
|
||||||
|
if (majorType == 'MAJOR_TYPE_OPUS') {
|
||||||
|
// 转发的动态
|
||||||
|
String jumpUrl = moduleDynamic.major!.opus!.jumpUrl!;
|
||||||
|
opusId = int.parse(jumpUrl.split('/').last);
|
||||||
|
if (opusId != null) {
|
||||||
|
isOpusId = true;
|
||||||
|
_dynamicDetailController = Get.put(
|
||||||
|
DynamicDetailController(oid, replyType),
|
||||||
|
tag: opusId.toString());
|
||||||
|
await _dynamicDetailController.reqHtmlByOpusId(opusId!);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oid = moduleDynamic.major!.draw!.id!;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
if (!isOpusId) {
|
||||||
|
_dynamicDetailController =
|
||||||
|
Get.put(DynamicDetailController(oid, replyType), tag: oid.toString());
|
||||||
|
}
|
||||||
|
_futureBuilderFuture = _dynamicDetailController.queryReplyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看二级评论
|
||||||
void replyReply(replyItem) {
|
void replyReply(replyItem) {
|
||||||
int oid = replyItem.oid;
|
int oid = replyItem.oid;
|
||||||
int rpid = replyItem.rpid!;
|
int rpid = replyItem.rpid!;
|
||||||
@ -100,13 +122,14 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
oid: oid,
|
oid: oid,
|
||||||
rpid: rpid,
|
rpid: rpid,
|
||||||
source: 'dynamic',
|
source: 'dynamic',
|
||||||
replyType: ReplyType.values[type],
|
replyType: ReplyType.values[replyType],
|
||||||
firstFloor: replyItem,
|
firstFloor: replyItem,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 滑动事件监听
|
||||||
void scrollListener() {
|
void scrollListener() {
|
||||||
scrollController = _dynamicDetailController.scrollController;
|
scrollController = _dynamicDetailController.scrollController;
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
@ -307,7 +330,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
replyLevel: '1',
|
replyLevel: '1',
|
||||||
replyReply: (replyItem) =>
|
replyReply: (replyItem) =>
|
||||||
replyReply(replyItem),
|
replyReply(replyItem),
|
||||||
replyType: ReplyType.values[type],
|
replyType:
|
||||||
|
ReplyType.values[replyType],
|
||||||
addReply: (replyItem) {
|
addReply: (replyItem) {
|
||||||
_dynamicDetailController
|
_dynamicDetailController
|
||||||
.replyList[index].replies!
|
.replyList[index].replies!
|
||||||
@ -365,7 +389,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
IdUtils.bv2av(Get.parameters['bvid']!),
|
IdUtils.bv2av(Get.parameters['bvid']!),
|
||||||
root: 0,
|
root: 0,
|
||||||
parent: 0,
|
parent: 0,
|
||||||
replyType: ReplyType.values[type],
|
replyType: ReplyType.values[replyType],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).then(
|
).then(
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/common/widgets/badge.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
@ -44,15 +45,27 @@ class AuthorPanel extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
item.modules.moduleAuthor.name,
|
children: [
|
||||||
style: TextStyle(
|
Text(
|
||||||
color: item.modules.moduleAuthor!.vip != null &&
|
item.modules.moduleAuthor.name,
|
||||||
item.modules.moduleAuthor!.vip['status'] > 0
|
style: TextStyle(
|
||||||
? const Color.fromARGB(255, 251, 100, 163)
|
color: item.modules.moduleAuthor!.vip != null &&
|
||||||
: Theme.of(context).colorScheme.onBackground,
|
item.modules.moduleAuthor!.vip['status'] > 0
|
||||||
fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
|
? const Color.fromARGB(255, 251, 100, 163)
|
||||||
),
|
: Theme.of(context).colorScheme.onBackground,
|
||||||
|
fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (item.modules.moduleTag != null) ...[
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
PBadge(
|
||||||
|
bottom: 10,
|
||||||
|
right: 10,
|
||||||
|
text: item.modules.moduleTag['text'],
|
||||||
|
)
|
||||||
|
]
|
||||||
|
],
|
||||||
),
|
),
|
||||||
DefaultTextStyle.merge(
|
DefaultTextStyle.merge(
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
Reference in New Issue
Block a user