fix: 动态渲染报错、转发评论加载

This commit is contained in:
guozhigq
2023-08-21 21:16:03 +08:00
parent 1884801ed2
commit 5812b5cff1
2 changed files with 50 additions and 39 deletions

View File

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_reply.dart'; import 'package:pilipala/common/skeleton/video_reply.dart';
@ -40,7 +41,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
} else { } else {
oid = Get.arguments['item'].modules.moduleDynamic.major.draw.id; oid = Get.arguments['item'].modules.moduleDynamic.major.draw.id;
} }
type = Get.arguments['item'].basic!['comment_type']; int commentType = Get.arguments['item'].basic!['comment_type'] ?? 11;
type = (commentType == 0) ? 11 : commentType;
action = action =
Get.arguments.containsKey('action') ? Get.arguments['action'] : null; Get.arguments.containsKey('action') ? Get.arguments['action'] : null;
_dynamicDetailController = Get.put(DynamicDetailController(oid, type)); _dynamicDetailController = Get.put(DynamicDetailController(oid, type));
@ -56,10 +59,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
void _listen() async { void _listen() async {
if (scrollController.position.pixels >= if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent - 300) { scrollController.position.maxScrollExtent - 300) {
if (!_dynamicDetailController!.isLoadingMore) { EasyThrottle.throttle('replylist', const Duration(seconds: 2), () {
_dynamicDetailController!.isLoadingMore = true; _dynamicDetailController!.queryReplyList(reqType: 'onLoad');
await _dynamicDetailController!.queryReplyList(reqType: 'onLoad'); });
}
} }
if (scrollController.offset > 55 && !_visibleTitle) { if (scrollController.offset > 55 && !_visibleTitle) {
@ -242,6 +244,11 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
replyReply: (replyItem) => replyReply: (replyItem) =>
replyReply(replyItem), replyReply(replyItem),
replyType: ReplyType.values[type], replyType: ReplyType.values[type],
addReply: (replyItem) {
_dynamicDetailController!
.replyList[index].replies!
.add(replyItem);
},
); );
} }
}, },

View File

@ -60,14 +60,15 @@ Widget addWidget(item, context, type, {floor = 1}) {
), ),
); );
case 'ADDITIONAL_TYPE_RESERVE': case 'ADDITIONAL_TYPE_RESERVE':
return Padding( return dynamicProperty[type].state != -1
? Padding(
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: InkWell( child: InkWell(
onTap: () {}, onTap: () {},
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: padding: const EdgeInsets.only(
const EdgeInsets.only(left: 12, top: 10, right: 12, bottom: 10), left: 12, top: 10, right: 12, bottom: 10),
color: bgColor, color: bgColor,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -82,8 +83,10 @@ Widget addWidget(item, context, type, {floor = 1}) {
TextSpan( TextSpan(
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
fontSize: fontSize: Theme.of(context)
Theme.of(context).textTheme.labelMedium!.fontSize), .textTheme
.labelMedium!
.fontSize),
children: [ children: [
TextSpan(text: dynamicProperty[type].desc1['text']), TextSpan(text: dynamicProperty[type].desc1['text']),
const TextSpan(text: ' '), const TextSpan(text: ' '),
@ -96,7 +99,8 @@ Widget addWidget(item, context, type, {floor = 1}) {
// TextButton(onPressed: () {}, child: Text('123')) // TextButton(onPressed: () {}, child: Text('123'))
), ),
), ),
); )
: const SizedBox();
case 'ADDITIONAL_TYPE_GOODS': case 'ADDITIONAL_TYPE_GOODS':
return Padding( return Padding(
padding: const EdgeInsets.only(top: 6), padding: const EdgeInsets.only(top: 6),