mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: history: full type
Closes #473 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
74
lib/pages/history/base_controller.dart
Normal file
74
lib/pages/history/base_controller.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class HistoryBaseController extends GetxController {
|
||||
RxBool pauseStatus = false.obs;
|
||||
|
||||
RxBool enableMultiSelect = false.obs;
|
||||
RxInt checkedCount = 0.obs;
|
||||
|
||||
// 清空观看历史
|
||||
Future onClearHistory(BuildContext context, VoidCallback onSuccess) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: const Text('啊叻?你要清空历史记录功能吗?'),
|
||||
actions: [
|
||||
TextButton(onPressed: Get.back, child: const Text('取消')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
var res = await UserHttp.clearHistory();
|
||||
SmartDialog.dismiss();
|
||||
if (res.data['code'] == 0) {
|
||||
SmartDialog.showToast('清空观看历史');
|
||||
onSuccess();
|
||||
}
|
||||
},
|
||||
child: const Text('确认清空'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 暂停观看历史
|
||||
Future onPauseHistory(BuildContext context) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content:
|
||||
Text(!pauseStatus.value ? '啊叻?你要暂停历史记录功能吗?' : '啊叻?要恢复历史记录功能吗?'),
|
||||
actions: [
|
||||
TextButton(onPressed: Get.back, child: const Text('取消')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
var res = await UserHttp.pauseHistory(!pauseStatus.value);
|
||||
SmartDialog.dismiss();
|
||||
if (res.data['code'] == 0) {
|
||||
SmartDialog.showToast(
|
||||
!pauseStatus.value ? '暂停观看历史' : '恢复观看历史');
|
||||
pauseStatus.value = !pauseStatus.value;
|
||||
GStorage.localCache
|
||||
.put(LocalCacheKey.historyPause, pauseStatus.value);
|
||||
}
|
||||
Get.back();
|
||||
},
|
||||
child: Text(!pauseStatus.value ? '确认暂停' : '确认恢复'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user