opt: reply del

This commit is contained in:
guozhigq
2024-11-13 23:59:31 +08:00
parent 57407c943f
commit 0009630639
5 changed files with 54 additions and 8 deletions

View File

@ -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']);