feat: 稍后再看页面完善
This commit is contained in:
@ -248,6 +248,9 @@ class Api {
|
|||||||
// 移除已观看
|
// 移除已观看
|
||||||
static const String toViewDel = '/x/v2/history/toview/del';
|
static const String toViewDel = '/x/v2/history/toview/del';
|
||||||
|
|
||||||
|
// 清空稍后再看
|
||||||
|
static const String toViewClear = '/x/v2/history/toview/clear';
|
||||||
|
|
||||||
// 追番
|
// 追番
|
||||||
static const String bangumiAdd = '/pgc/web/follow/add';
|
static const String bangumiAdd = '/pgc/web/follow/add';
|
||||||
|
|
||||||
|
|||||||
@ -85,6 +85,12 @@ class UserHttp {
|
|||||||
static Future<dynamic> seeYouLater() async {
|
static Future<dynamic> seeYouLater() async {
|
||||||
var res = await Request().get(Api.seeYouLater);
|
var res = await Request().get(Api.seeYouLater);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
|
if (res.data['data']['count'] == 0) {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': {'list': [], 'count': 0}
|
||||||
|
};
|
||||||
|
}
|
||||||
List<HotVideoItemModel> list = [];
|
List<HotVideoItemModel> list = [];
|
||||||
for (var i in res.data['data']['list']) {
|
for (var i in res.data['data']['list']) {
|
||||||
list.add(HotVideoItemModel.fromJson(i));
|
list.add(HotVideoItemModel.fromJson(i));
|
||||||
@ -195,4 +201,20 @@ class UserHttp {
|
|||||||
Request().get(res.data['data']['confirm_uri']);
|
Request().get(res.data['data']['confirm_uri']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清空稍后再看
|
||||||
|
static Future toViewClear() async {
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.toViewClear,
|
||||||
|
queryParameters: {
|
||||||
|
'jsonp': 'jsonp',
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true, 'msg': '操作完成'};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,15 +6,20 @@ import 'package:pilipala/models/model_hot_video_item.dart';
|
|||||||
|
|
||||||
class LaterController extends GetxController {
|
class LaterController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
RxList<HotVideoItemModel> laterList = [HotVideoItemModel()].obs;
|
RxList<HotVideoItemModel> laterList = <HotVideoItemModel>[].obs;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
RxBool isLoading = false.obs;
|
||||||
|
|
||||||
Future queryLaterList() async {
|
Future queryLaterList() async {
|
||||||
|
isLoading.value = true;
|
||||||
var res = await UserHttp.seeYouLater();
|
var res = await UserHttp.seeYouLater();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
laterList.value = res['data']['list'];
|
|
||||||
count = res['data']['count'];
|
count = res['data']['count'];
|
||||||
|
if (count > 0) {
|
||||||
|
laterList.value = res['data']['list'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
isLoading.value = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,4 +52,34 @@ class LaterController extends GetxController {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 一键清空
|
||||||
|
Future toViewClear() 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.toViewClear();
|
||||||
|
if (res['status']) {
|
||||||
|
laterList.clear();
|
||||||
|
}
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
},
|
||||||
|
child: const Text('确认'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,25 +29,38 @@ class _LaterPageState extends State<LaterPage> {
|
|||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: Obx(
|
title: Obx(
|
||||||
() => Text(
|
() => _laterController.laterList.isNotEmpty
|
||||||
|
? Text(
|
||||||
'稍后再看 (${_laterController.laterList.length}/100)',
|
'稍后再看 (${_laterController.laterList.length}/100)',
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
'稍后再看',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
Obx(
|
||||||
|
() => _laterController.laterList.isNotEmpty
|
||||||
|
? TextButton(
|
||||||
onPressed: () => _laterController.toViewDel(),
|
onPressed: () => _laterController.toViewDel(),
|
||||||
child: const Text('移除已看'),
|
child: const Text('移除已看'),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
),
|
||||||
|
Obx(
|
||||||
|
() => _laterController.laterList.isNotEmpty
|
||||||
|
? IconButton(
|
||||||
|
tooltip: '一键清空',
|
||||||
|
onPressed: () => _laterController.toViewClear(),
|
||||||
|
icon: Icon(
|
||||||
|
Icons.clear_all_outlined,
|
||||||
|
size: 21,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
// IconButton(
|
|
||||||
// tooltip: '一键清空',
|
|
||||||
// onPressed: () {},
|
|
||||||
// icon: Icon(
|
|
||||||
// Icons.clear_all_outlined,
|
|
||||||
// size: 21,
|
|
||||||
// color: Theme.of(context).colorScheme.primary,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -61,19 +74,31 @@ class _LaterPageState extends State<LaterPage> {
|
|||||||
Map data = snapshot.data as Map;
|
Map data = snapshot.data as Map;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => SliverList(
|
() => _laterController.laterList.isNotEmpty &&
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
!_laterController.isLoading.value
|
||||||
|
? SliverList(
|
||||||
|
delegate:
|
||||||
|
SliverChildBuilderDelegate((context, index) {
|
||||||
return VideoCardH(
|
return VideoCardH(
|
||||||
videoItem: _laterController.laterList[index],
|
videoItem: _laterController.laterList[index],
|
||||||
source: 'later',
|
source: 'later',
|
||||||
);
|
);
|
||||||
}, childCount: _laterController.laterList.length),
|
}, childCount: _laterController.laterList.length),
|
||||||
|
)
|
||||||
|
: SliverToBoxAdapter(
|
||||||
|
child: Center(
|
||||||
|
child: Text(_laterController.isLoading.value
|
||||||
|
? '加载中'
|
||||||
|
: '没有数据'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {}),
|
fn: () => setState(() {
|
||||||
|
_futureBuilderFuture = _laterController.queryLaterList();
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -81,7 +106,7 @@ class _LaterPageState extends State<LaterPage> {
|
|||||||
return SliverList(
|
return SliverList(
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
return const VideoCardHSkeleton();
|
return const VideoCardHSkeleton();
|
||||||
}, childCount: 5),
|
}, childCount: 10),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user