feat: 移除单个稍后再看

This commit is contained in:
guozhigq
2023-08-30 09:36:19 +08:00
parent fceb55aaa3
commit 108c37f0d7
3 changed files with 36 additions and 19 deletions

View File

@ -179,14 +179,16 @@ class UserHttp {
}
// 移除已观看
static Future toViewDel() async {
static Future toViewDel({int? aid}) async {
final Map<String, dynamic> params = {
'jsonp': 'jsonp',
'csrf': await Request.getCsrf(),
};
params[aid != null ? 'aid' : 'viewed'] = aid ?? true;
var res = await Request().post(
Api.toViewDel,
queryParameters: {
'jsonp': 'jsonp',
'viewed': true,
'csrf': await Request.getCsrf(),
},
queryParameters: params,
);
if (res.data['code'] == 0) {
return {'status': true, 'msg': 'yeah成功移除'};

View File

@ -23,29 +23,38 @@ class LaterController extends GetxController {
return res;
}
Future toViewDel() async {
Future toViewDel({int? aid}) async {
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: const Text('即将删除所有已观看视频,此操作不可恢复。确定是否删除?'),
content: Text(
aid != null ? '即将移除该视频,确定是否移除' : '即将删除所有已观看视频,此操作不可恢复。确定是否删除?'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: const Text('取消')),
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await UserHttp.toViewDel();
var res = await UserHttp.toViewDel(aid: aid);
if (res['status']) {
laterList.clear();
queryLaterList();
if (aid != null) {
laterList.removeWhere((e) => e.aid == aid);
} else {
laterList.clear();
queryLaterList();
}
}
SmartDialog.dismiss();
SmartDialog.showToast(res['msg']);
},
child: const Text('确认删除'),
child: Text(aid != null ? '确认移除' : '确认删除'),
)
],
);
@ -64,8 +73,12 @@ class LaterController extends GetxController {
content: const Text('确定要清空你的稍后再看列表吗?'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: const Text('取消')),
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await UserHttp.toViewClear();

View File

@ -80,10 +80,12 @@ class _LaterPageState extends State<LaterPage> {
? SliverList(
delegate:
SliverChildBuilderDelegate((context, index) {
var videoItem = _laterController.laterList[index];
return VideoCardH(
videoItem: _laterController.laterList[index],
source: 'later',
);
videoItem: videoItem,
source: 'later',
longPress: () => _laterController.toViewDel(
aid: videoItem.aid));
}, childCount: _laterController.laterList.length),
)
: _laterController.isLoading.value