feat: 暂停/恢复历史记录、清空历史记录
This commit is contained in:
@ -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/user/history.dart';
|
||||
@ -7,10 +8,12 @@ class HistoryController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
RxList<HisListItem> historyList = [HisListItem()].obs;
|
||||
bool isLoadingMore = false;
|
||||
RxBool pauseStatus = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
historyStatus();
|
||||
}
|
||||
|
||||
Future queryHistoryList({type = 'init'}) async {
|
||||
@ -40,4 +43,76 @@ class HistoryController extends GetxController {
|
||||
Future onRefresh() async {
|
||||
queryHistoryList(type: 'onRefresh');
|
||||
}
|
||||
|
||||
// 暂停观看历史
|
||||
Future onPauseHistory() async {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content:
|
||||
Text(!pauseStatus.value ? '啊叻?你要暂停历史记录功能吗?' : '啊叻?要恢复历史记录功能吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => SmartDialog.dismiss(),
|
||||
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;
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
child: Text(!pauseStatus.value ? '确认暂停' : '确认恢复'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 观看历史暂停状态
|
||||
Future historyStatus() async {
|
||||
var res = await UserHttp.historyStatus();
|
||||
pauseStatus.value = res.data['data'];
|
||||
}
|
||||
|
||||
// 清空观看历史
|
||||
Future onClearHistory() 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 {
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
var res = await UserHttp.clearHistory();
|
||||
SmartDialog.dismiss();
|
||||
if (res.data['code'] == 0) {
|
||||
SmartDialog.showToast('清空观看历史');
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
historyList.clear();
|
||||
},
|
||||
child: const Text('确认清空'),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user