86 lines
2.6 KiB
Dart
86 lines
2.6 KiB
Dart
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';
|
|
|
|
class LaterController extends GetxController {
|
|
final ScrollController scrollController = ScrollController();
|
|
RxList<HotVideoItemModel> laterList = <HotVideoItemModel>[].obs;
|
|
int count = 0;
|
|
RxBool isLoading = false.obs;
|
|
|
|
Future queryLaterList() async {
|
|
isLoading.value = true;
|
|
var res = await UserHttp.seeYouLater();
|
|
if (res['status']) {
|
|
count = res['data']['count'];
|
|
if (count > 0) {
|
|
laterList.value = res['data']['list'];
|
|
}
|
|
}
|
|
isLoading.value = false;
|
|
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('确认删除'),
|
|
)
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
// 一键清空
|
|
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('确认'),
|
|
)
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|