feat: 稍后再看添加/清除已看
This commit is contained in:
@ -6,6 +6,7 @@ import 'package:pilipala/common/widgets/badge.dart';
|
||||
import 'package:pilipala/common/widgets/stat/danmu.dart';
|
||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
|
||||
@ -39,6 +40,11 @@ class VideoCardH extends StatelessWidget {
|
||||
longPressEnd!();
|
||||
}
|
||||
},
|
||||
// 双击 稍后再看
|
||||
onDoubleTap: () async {
|
||||
var res = await UserHttp.toViewLater(bvid: videoItem.bvid);
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
try {
|
||||
|
@ -1,8 +1,10 @@
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/widgets/stat/danmu.dart';
|
||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/pages/rcmd/index.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
@ -43,6 +45,11 @@ class VideoCardV extends StatelessWidget {
|
||||
longPressEnd!();
|
||||
}
|
||||
},
|
||||
// 双击 稍后再看
|
||||
onDoubleTap: () async {
|
||||
var res = await UserHttp.toViewLater(bvid: videoItem.bvid);
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
|
||||
|
@ -237,4 +237,10 @@ class Api {
|
||||
|
||||
// 用户动态
|
||||
static const String memberDynamic = '/x/polymer/web-dynamic/v1/feed/space';
|
||||
|
||||
// 稍后再看
|
||||
static const String toViewLater = '/x/v2/history/toview/add';
|
||||
|
||||
// 移除已观看
|
||||
static const String toViewDel = '/x/v2/history/toview/del';
|
||||
}
|
||||
|
@ -143,4 +143,40 @@ class UserHttp {
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
// 稍后再看
|
||||
static Future toViewLater({String? bvid, dynamic aid}) async {
|
||||
var data = {'csrf': await Request.getCsrf()};
|
||||
if (bvid != null) {
|
||||
data['bvid'] = bvid;
|
||||
} else if (aid != null) {
|
||||
data['aid'] = aid;
|
||||
}
|
||||
var res = await Request().post(
|
||||
Api.toViewLater,
|
||||
queryParameters: data,
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'msg': 'yeah!稍后再看'};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
// 移除已观看
|
||||
static Future toViewDel() async {
|
||||
var res = await Request().post(
|
||||
Api.toViewDel,
|
||||
queryParameters: {
|
||||
'jsonp': 'jsonp',
|
||||
'viewed': true,
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'msg': 'yeah!成功移除'};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/models/model_hot_video_item.dart';
|
||||
@ -16,4 +17,34 @@ class LaterController extends GetxController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Future toViewDel() async {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: const Text('即将删除所有已观看视频,此操作不可恢复。确定是否删除?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => SmartDialog.dismiss(),
|
||||
child: const Text('取消')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
var res = await UserHttp.toViewDel();
|
||||
if (res['status']) {
|
||||
laterList.clear();
|
||||
queryLaterList();
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
child: const Text('确认删除'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,28 @@ class _LaterPageState extends State<LaterPage> {
|
||||
appBar: AppBar(
|
||||
titleSpacing: 0,
|
||||
centerTitle: false,
|
||||
title: Text(
|
||||
'稍后再看',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
title: Obx(
|
||||
() => Text(
|
||||
'稍后再看 (${_laterController.laterList.length}/100)',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => _laterController.toViewDel(),
|
||||
child: const Text('移除已看'),
|
||||
),
|
||||
// IconButton(
|
||||
// tooltip: '一键清空',
|
||||
// onPressed: () {},
|
||||
// icon: Icon(
|
||||
// Icons.clear_all_outlined,
|
||||
// size: 21,
|
||||
// color: Theme.of(context).colorScheme.primary,
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
controller: _laterController.scrollController,
|
||||
|
Reference in New Issue
Block a user