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