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( var res = await Request().post(
Api.toViewDel, Api.toViewDel,
queryParameters: { queryParameters: params,
'jsonp': 'jsonp',
'viewed': true,
'csrf': await Request.getCsrf(),
},
); );
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return {'status': true, 'msg': 'yeah成功移除'}; return {'status': true, 'msg': 'yeah成功移除'};

View File

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

View File

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