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,43 +60,47 @@ Widget addWidget(item, context, type, {floor = 1}) {
), ),
); );
case 'ADDITIONAL_TYPE_RESERVE': case 'ADDITIONAL_TYPE_RESERVE':
return Padding( return dynamicProperty[type].state != -1
padding: const EdgeInsets.only(top: 8), ? Padding(
child: InkWell( padding: const EdgeInsets.only(top: 8),
onTap: () {}, child: InkWell(
child: Container( onTap: () {},
width: double.infinity, child: Container(
padding: width: double.infinity,
const EdgeInsets.only(left: 12, top: 10, right: 12, bottom: 10), padding: const EdgeInsets.only(
color: bgColor, left: 12, top: 10, right: 12, bottom: 10),
child: Column( color: bgColor,
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Text(
dynamicProperty[type].title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 1),
Text.rich(
TextSpan(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize),
children: [ children: [
TextSpan(text: dynamicProperty[type].desc1['text']), Text(
const TextSpan(text: ' '), dynamicProperty[type].title,
TextSpan(text: dynamicProperty[type].desc2['text']), maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 1),
Text.rich(
TextSpan(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
children: [
TextSpan(text: dynamicProperty[type].desc1['text']),
const TextSpan(text: ' '),
TextSpan(text: dynamicProperty[type].desc2['text']),
],
),
)
], ],
), ),
) // 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),