opt: reply del
This commit is contained in:
@ -132,4 +132,24 @@ class VideoReplyController extends GetxController {
|
||||
queryReplyList(type: 'init');
|
||||
});
|
||||
}
|
||||
|
||||
// 移除评论
|
||||
Future removeReply(int? rpid, int? frpid) async {
|
||||
// 移除一楼评论
|
||||
if (rpid != null) {
|
||||
replyList.removeWhere((item) {
|
||||
return item.rpid == rpid;
|
||||
});
|
||||
}
|
||||
// 移除二楼评论
|
||||
if (frpid != 0 && frpid != null) {
|
||||
replyList.value = replyList.map((item) {
|
||||
if (item.rpid! == frpid) {
|
||||
return item..replies!.removeWhere((reply) => reply.rpid == rpid);
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,10 +242,9 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
.replyList[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: replyLevel,
|
||||
replyReply: (replyItem, currentReply,
|
||||
loadMore) =>
|
||||
replyReply(replyItem, currentReply,
|
||||
loadMore),
|
||||
replyReply: replyReply,
|
||||
onDelete:
|
||||
_videoReplyController.removeReply,
|
||||
replyType: ReplyType.video,
|
||||
);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class ReplyItem extends StatelessWidget {
|
||||
this.replyReply,
|
||||
this.replyType,
|
||||
this.replySave = false,
|
||||
this.onDelete,
|
||||
super.key,
|
||||
});
|
||||
final ReplyItemModel? replyItem;
|
||||
@ -46,6 +47,7 @@ class ReplyItem extends StatelessWidget {
|
||||
final Function? replyReply;
|
||||
final ReplyType? replyType;
|
||||
final bool replySave;
|
||||
final Function(int? rpid, int? frpid)? onDelete;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -75,6 +77,7 @@ class ReplyItem extends StatelessWidget {
|
||||
item: replyItem,
|
||||
mainFloor: true,
|
||||
isOwner: isOwner,
|
||||
onDelete: onDelete,
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -275,6 +278,7 @@ class ReplyItem extends StatelessWidget {
|
||||
// f_rpid: replyItem!.rpid,
|
||||
replyItem: replyItem,
|
||||
replyReply: replyReply,
|
||||
onDelete: onDelete,
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -371,15 +375,15 @@ class ReplyItemRow extends StatelessWidget {
|
||||
super.key,
|
||||
this.replies,
|
||||
this.replyControl,
|
||||
// this.f_rpid,
|
||||
this.replyItem,
|
||||
this.replyReply,
|
||||
this.onDelete,
|
||||
});
|
||||
final List? replies;
|
||||
ReplyControl? replyControl;
|
||||
// int? f_rpid;
|
||||
ReplyItemModel? replyItem;
|
||||
Function? replyReply;
|
||||
final Function(int? rpid, int? frpid)? onDelete;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -410,12 +414,18 @@ class ReplyItemRow extends StatelessWidget {
|
||||
},
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
final bool isOwner = int.parse(replyItem!.member!.mid!) ==
|
||||
(GlobalDataCache().userInfo?.mid ?? -1);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return MorePanel(item: replies![i]);
|
||||
return MorePanel(
|
||||
item: replies![i],
|
||||
isOwner: isOwner,
|
||||
onDelete: onDelete,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -1019,11 +1029,13 @@ class MorePanel extends StatelessWidget {
|
||||
final dynamic item;
|
||||
final bool mainFloor;
|
||||
final bool isOwner;
|
||||
final Function(int? rpid, int? frpid)? onDelete;
|
||||
const MorePanel({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.mainFloor = false,
|
||||
this.isOwner = false,
|
||||
this.onDelete,
|
||||
});
|
||||
|
||||
Future<dynamic> menuActionHandler(String type) async {
|
||||
@ -1077,13 +1089,17 @@ class MorePanel extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
print('item.rpid: ${item.rpid}');
|
||||
onDelete?.call(item.rpid!, item.root);
|
||||
return;
|
||||
var result = await ReplyHttp.replyDel(
|
||||
type: item.type!,
|
||||
oid: item.oid!,
|
||||
rpid: item.rpid!,
|
||||
);
|
||||
if (result['status']) {
|
||||
SmartDialog.showToast('评论删除成功,需手动刷新');
|
||||
// SmartDialog.showToast('评论删除成功,需手动刷新');
|
||||
onDelete?.call(item.rpid!, item.root);
|
||||
Get.back();
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
|
@ -84,6 +84,16 @@ class VideoReplyReplyController extends GetxController {
|
||||
return res;
|
||||
}
|
||||
|
||||
// 移除评论
|
||||
Future removeReply(int? rpid, int? frpid) async {
|
||||
// 移除一楼评论
|
||||
if (rpid != null) {
|
||||
replyList.removeWhere((item) {
|
||||
return item.rpid == rpid;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
currentPage = 0;
|
||||
|
@ -118,6 +118,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
},
|
||||
replyType: widget.replyType,
|
||||
replyReply: (replyItem) => replyReply(replyItem),
|
||||
onDelete: _videoReplyReplyController.removeReply,
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user