mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: remove dynamic
This commit is contained in:
@@ -186,6 +186,29 @@ class MsgHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future removeDynamic(
|
||||
dynamic dynamicId,
|
||||
) async {
|
||||
String csrf = await Request.getCsrf();
|
||||
Map<String, dynamic> data = await WbiSign().makSign({
|
||||
'dynamic_id': dynamicId,
|
||||
'csrf_token': csrf,
|
||||
'csrf': csrf,
|
||||
});
|
||||
var res = await Request().post(
|
||||
HttpString.tUrl + Api.removeDynamic,
|
||||
data: FormData.fromMap(data),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static Future removeMsg(
|
||||
dynamic talkerId,
|
||||
) async {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/http/msg.dart';
|
||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
import '../../../http/dynamics.dart';
|
||||
|
||||
@@ -39,4 +41,16 @@ class DynamicsTabController extends CommonController {
|
||||
offset: offset,
|
||||
mid: dynamicsType == "up" ? mid : -1,
|
||||
);
|
||||
|
||||
Future onRemove(dynamic dynamicId) async {
|
||||
var res = await MsgHttp.removeDynamic(dynamicId);
|
||||
if (res['status']) {
|
||||
List list = (loadingState.value as Success).response;
|
||||
list.removeWhere((item) => item.idStr == dynamicId);
|
||||
loadingState.value = LoadingState.success(list);
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,10 @@ class _DynamicsTabPageState extends State<DynamicsTabPage>
|
||||
for (var i in loadingState.response)
|
||||
if (!dynamicsController.tempBannedList
|
||||
.contains(i.modules?.moduleAuthor?.mid))
|
||||
DynamicPanel(item: i),
|
||||
DynamicPanel(
|
||||
item: i,
|
||||
onRemove: _dynamicsTabController.onRemove,
|
||||
),
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -14,11 +15,13 @@ class AuthorPanel extends StatelessWidget {
|
||||
final dynamic item;
|
||||
final Function? addBannedList;
|
||||
final String? source;
|
||||
final Function? onRemove;
|
||||
const AuthorPanel({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.addBannedList,
|
||||
this.source,
|
||||
this.onRemove,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -127,7 +130,10 @@ class AuthorPanel extends StatelessWidget {
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return MorePanel(item: item);
|
||||
return MorePanel(
|
||||
item: item,
|
||||
onRemove: onRemove,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -141,7 +147,12 @@ class AuthorPanel extends StatelessWidget {
|
||||
|
||||
class MorePanel extends StatelessWidget {
|
||||
final dynamic item;
|
||||
const MorePanel({super.key, required this.item});
|
||||
final Function? onRemove;
|
||||
const MorePanel({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.onRemove,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -223,6 +234,46 @@ class MorePanel extends StatelessWidget {
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
if (item.modules.moduleAuthor.mid ==
|
||||
GStorage.userInfo.get('userInfoCache').mid)
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text('确定删除该动态?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
if (onRemove != null) {
|
||||
onRemove!(item.idStr);
|
||||
}
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
));
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
leading: Icon(Icons.delete_outline,
|
||||
color: Theme.of(context).colorScheme.error, size: 19),
|
||||
title: Text('删除',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.copyWith(color: Theme.of(context).colorScheme.error)),
|
||||
),
|
||||
const Divider(thickness: 0.1, height: 1),
|
||||
ListTile(
|
||||
onTap: () => Get.back(),
|
||||
|
||||
@@ -9,7 +9,15 @@ import 'forward_panel.dart';
|
||||
class DynamicPanel extends StatelessWidget {
|
||||
final dynamic item;
|
||||
final String? source;
|
||||
DynamicPanel({required this.item, this.source, Key? key}) : super(key: key);
|
||||
final Function? onRemove;
|
||||
|
||||
DynamicPanel({
|
||||
required this.item,
|
||||
this.source,
|
||||
this.onRemove,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||
|
||||
@override
|
||||
@@ -42,7 +50,11 @@ class DynamicPanel extends StatelessWidget {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 6),
|
||||
child: AuthorPanel(item: item, source: source),
|
||||
child: AuthorPanel(
|
||||
item: item,
|
||||
source: source,
|
||||
onRemove: onRemove,
|
||||
),
|
||||
),
|
||||
if (item!.modules!.moduleDynamic!.desc != null ||
|
||||
item!.modules!.moduleDynamic!.major != null)
|
||||
|
||||
@@ -87,7 +87,7 @@ class _SysMsgPageState extends State<SysMsgPage> {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text('确定删除该消息?'),
|
||||
title: const Text('确定删除该通知?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
|
||||
Reference in New Issue
Block a user