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:
@@ -96,9 +96,9 @@ class Request {
|
|||||||
//请求基地址,可以包含子路径
|
//请求基地址,可以包含子路径
|
||||||
baseUrl: HttpString.apiBaseUrl,
|
baseUrl: HttpString.apiBaseUrl,
|
||||||
//连接服务器超时时间,单位是毫秒.
|
//连接服务器超时时间,单位是毫秒.
|
||||||
connectTimeout: const Duration(milliseconds: 4000),
|
connectTimeout: const Duration(milliseconds: 10000),
|
||||||
//响应流上前后两次接受到数据的间隔,单位为毫秒。
|
//响应流上前后两次接受到数据的间隔,单位为毫秒。
|
||||||
receiveTimeout: const Duration(milliseconds: 4000),
|
receiveTimeout: const Duration(milliseconds: 10000),
|
||||||
//Http请求头.
|
//Http请求头.
|
||||||
headers: {
|
headers: {
|
||||||
'connection': 'keep-alive',
|
'connection': 'keep-alive',
|
||||||
|
|||||||
@@ -196,11 +196,12 @@ class UserHttp {
|
|||||||
|
|
||||||
// 观看历史
|
// 观看历史
|
||||||
static Future<LoadingState> historyList({
|
static Future<LoadingState> historyList({
|
||||||
|
required String type,
|
||||||
int? max,
|
int? max,
|
||||||
int? viewAt,
|
int? viewAt,
|
||||||
}) async {
|
}) async {
|
||||||
var res = await Request().get(Api.historyList, queryParameters: {
|
var res = await Request().get(Api.historyList, queryParameters: {
|
||||||
'type': 'all',
|
'type': type,
|
||||||
'ps': 20,
|
'ps': 20,
|
||||||
'max': max ?? 0,
|
'max': max ?? 0,
|
||||||
'view_at': viewAt ?? 0,
|
'view_at': viewAt ?? 0,
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import 'package:get/get.dart';
|
|||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
|
|
||||||
abstract class MultiSelectController extends CommonController {
|
abstract class MultiSelectController extends CommonController {
|
||||||
RxBool enableMultiSelect = false.obs;
|
late final RxBool enableMultiSelect = false.obs;
|
||||||
RxInt checkedCount = 0.obs;
|
late final RxInt checkedCount = 0.obs;
|
||||||
|
|
||||||
onSelect(int index) {
|
onSelect(int index) {
|
||||||
List list = (loadingState.value as Success).response;
|
List list = (loadingState.value as Success).response;
|
||||||
|
|||||||
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 ? '确认暂停' : '确认恢复'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||||
|
import 'package:PiliPlus/pages/history/base_controller.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -8,8 +9,15 @@ import 'package:PiliPlus/http/user.dart';
|
|||||||
import 'package:PiliPlus/models/user/history.dart';
|
import 'package:PiliPlus/models/user/history.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
|
||||||
class HistoryController extends MultiSelectController {
|
class HistoryController extends MultiSelectController
|
||||||
RxBool pauseStatus = false.obs;
|
with GetTickerProviderStateMixin {
|
||||||
|
HistoryController(this.type);
|
||||||
|
|
||||||
|
late final baseCtr = Get.put(HistoryBaseController());
|
||||||
|
|
||||||
|
final String? type;
|
||||||
|
TabController? tabController;
|
||||||
|
late RxList<HisTabItem> tabs = <HisTabItem>[].obs;
|
||||||
|
|
||||||
int? max;
|
int? max;
|
||||||
int? viewAt;
|
int? viewAt;
|
||||||
@@ -28,13 +36,46 @@ class HistoryController extends MultiSelectController {
|
|||||||
return super.onRefresh();
|
return super.onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
onSelect(int index) {
|
||||||
|
List list = (loadingState.value as Success).response;
|
||||||
|
list[index].checked = !(list[index]?.checked ?? false);
|
||||||
|
baseCtr.checkedCount.value =
|
||||||
|
list.where((item) => item.checked == true).length;
|
||||||
|
loadingState.value = LoadingState.success(list);
|
||||||
|
if (baseCtr.checkedCount.value == 0) {
|
||||||
|
baseCtr.enableMultiSelect.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSelect([bool checked = false]) {
|
||||||
|
if (loadingState.value is Success) {
|
||||||
|
List list = (loadingState.value as Success).response;
|
||||||
|
if (list.isNotEmpty) {
|
||||||
|
loadingState.value = LoadingState.success(
|
||||||
|
list.map((item) => item..checked = checked).toList());
|
||||||
|
baseCtr.checkedCount.value = checked ? list.length : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (checked.not) {
|
||||||
|
baseCtr.enableMultiSelect.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool customHandleResponse(Success response) {
|
bool customHandleResponse(Success response) {
|
||||||
HistoryData data = response.response;
|
HistoryData data = response.response;
|
||||||
isEnd = data.list.isNullOrEmpty || data.list!.length < 20;
|
isEnd = data.list.isNullOrEmpty || data.list!.length < 20;
|
||||||
max = data.list?.lastOrNull?.history?.oid;
|
max = data.list?.lastOrNull?.history?.oid;
|
||||||
viewAt = data.list?.lastOrNull?.viewAt;
|
viewAt = data.list?.lastOrNull?.viewAt;
|
||||||
if (currentPage != 1 && loadingState.value is Success) {
|
if (currentPage == 1) {
|
||||||
|
if (type == null && tabs.isEmpty && data.tab?.isNotEmpty == true) {
|
||||||
|
tabs.value = data.tab!;
|
||||||
|
tabController =
|
||||||
|
TabController(length: data.tab!.length + 1, vsync: this);
|
||||||
|
}
|
||||||
|
} else if (loadingState.value is Success) {
|
||||||
data.list ??= <HisListItem>[];
|
data.list ??= <HisListItem>[];
|
||||||
data.list!.insertAll(
|
data.list!.insertAll(
|
||||||
0,
|
0,
|
||||||
@@ -45,79 +86,17 @@ class HistoryController extends MultiSelectController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暂停观看历史
|
|
||||||
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 ? '确认暂停' : '确认恢复'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 观看历史暂停状态
|
// 观看历史暂停状态
|
||||||
Future historyStatus() async {
|
Future historyStatus() async {
|
||||||
var res = await UserHttp.historyStatus();
|
var res = await UserHttp.historyStatus();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
pauseStatus.value = res['data'];
|
baseCtr.pauseStatus.value = res['data'];
|
||||||
GStorage.localCache.put(LocalCacheKey.historyPause, res['data']);
|
GStorage.localCache.put(LocalCacheKey.historyPause, res['data']);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空观看历史
|
|
||||||
Future onClearHistory(BuildContext context) 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 {
|
|
||||||
SmartDialog.showLoading(msg: '请求中');
|
|
||||||
var res = await UserHttp.clearHistory();
|
|
||||||
SmartDialog.dismiss();
|
|
||||||
if (res.data['code'] == 0) {
|
|
||||||
SmartDialog.showToast('清空观看历史');
|
|
||||||
}
|
|
||||||
Get.back();
|
|
||||||
loadingState.value = LoadingState.success([]);
|
|
||||||
},
|
|
||||||
child: const Text('确认清空'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除某条历史记录
|
// 删除某条历史记录
|
||||||
Future delHistory(kid, business) async {
|
Future delHistory(kid, business) async {
|
||||||
_onDelete(((loadingState.value as Success).response as List)
|
_onDelete(((loadingState.value as Success).response as List)
|
||||||
@@ -155,9 +134,9 @@ class HistoryController extends MultiSelectController {
|
|||||||
} else {
|
} else {
|
||||||
onReload();
|
onReload();
|
||||||
}
|
}
|
||||||
if (enableMultiSelect.value) {
|
if (baseCtr.enableMultiSelect.value) {
|
||||||
checkedCount.value = 0;
|
baseCtr.checkedCount.value = 0;
|
||||||
enableMultiSelect.value = false;
|
baseCtr.enableMultiSelect.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
@@ -201,5 +180,11 @@ class HistoryController extends MultiSelectController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LoadingState> customGetData() =>
|
Future<LoadingState> customGetData() =>
|
||||||
UserHttp.historyList(max: max, viewAt: viewAt);
|
UserHttp.historyList(type: type ?? 'all', max: max, viewAt: viewAt);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
tabController?.dispose();
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/widgets/http_error.dart';
|
|||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/pages/fav_search/view.dart' show SearchType;
|
import 'package:PiliPlus/pages/fav_search/view.dart' show SearchType;
|
||||||
|
import 'package:PiliPlus/pages/history/base_controller.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -13,28 +14,63 @@ import '../../utils/grid.dart';
|
|||||||
import 'widgets/item.dart';
|
import 'widgets/item.dart';
|
||||||
|
|
||||||
class HistoryPage extends StatefulWidget {
|
class HistoryPage extends StatefulWidget {
|
||||||
const HistoryPage({super.key});
|
const HistoryPage({super.key, this.type});
|
||||||
|
|
||||||
|
final String? type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HistoryPage> createState() => _HistoryPageState();
|
State<HistoryPage> createState() => _HistoryPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HistoryPageState extends State<HistoryPage> {
|
class _HistoryPageState extends State<HistoryPage>
|
||||||
final _historyController = Get.put(HistoryController());
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
late final _historyController = Get.put(
|
||||||
|
HistoryController(widget.type),
|
||||||
|
tag: widget.type ?? 'all',
|
||||||
|
);
|
||||||
|
|
||||||
|
HistoryController get currCtr {
|
||||||
|
try {
|
||||||
|
if (_historyController.tabController != null &&
|
||||||
|
_historyController.tabController!.index != 0) {
|
||||||
|
return Get.find<HistoryController>(
|
||||||
|
tag: _historyController
|
||||||
|
.tabs[_historyController.tabController!.index - 1].type,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
return _historyController;
|
||||||
|
}
|
||||||
|
return _historyController;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get enableMultiSelect =>
|
||||||
|
_historyController.baseCtr.enableMultiSelect.value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
Get.delete<HistoryBaseController>();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(
|
super.build(context);
|
||||||
|
return widget.type != null
|
||||||
|
? _buildPage
|
||||||
|
: Obx(
|
||||||
() => PopScope(
|
() => PopScope(
|
||||||
canPop: _historyController.enableMultiSelect.value.not,
|
canPop: enableMultiSelect.not,
|
||||||
onPopInvokedWithResult: (didPop, result) {
|
onPopInvokedWithResult: (didPop, result) {
|
||||||
if (_historyController.enableMultiSelect.value) {
|
if (enableMultiSelect) {
|
||||||
_historyController.handleSelect();
|
currCtr.handleSelect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBarWidget(
|
appBar: widget.type != null
|
||||||
visible: _historyController.enableMultiSelect.value,
|
? null
|
||||||
|
: AppBarWidget(
|
||||||
|
visible: enableMultiSelect,
|
||||||
child1: AppBar(
|
child1: AppBar(
|
||||||
title: const Text('观看记录'),
|
title: const Text('观看记录'),
|
||||||
actions: [
|
actions: [
|
||||||
@@ -53,16 +89,35 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
// 处理菜单项选择的逻辑
|
// 处理菜单项选择的逻辑
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'pause':
|
case 'pause':
|
||||||
_historyController.onPauseHistory(context);
|
_historyController.baseCtr
|
||||||
|
.onPauseHistory(context);
|
||||||
break;
|
break;
|
||||||
case 'clear':
|
case 'clear':
|
||||||
_historyController.onClearHistory(context);
|
_historyController.baseCtr
|
||||||
|
.onClearHistory(context, () {
|
||||||
|
_historyController.loadingState.value =
|
||||||
|
LoadingState.success(null);
|
||||||
|
if (_historyController.tabController !=
|
||||||
|
null) {
|
||||||
|
for (final item
|
||||||
|
in _historyController.tabs) {
|
||||||
|
try {
|
||||||
|
Get.find<HistoryController>(
|
||||||
|
tag: item.type)
|
||||||
|
.loadingState
|
||||||
|
.value =
|
||||||
|
LoadingState.success(null);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'del':
|
case 'del':
|
||||||
_historyController.onDelHistory();
|
currCtr.onDelHistory();
|
||||||
break;
|
break;
|
||||||
case 'multiple':
|
case 'multiple':
|
||||||
_historyController.enableMultiSelect.value = true;
|
_historyController
|
||||||
|
.baseCtr.enableMultiSelect.value = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -72,7 +127,8 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
value: 'pause',
|
value: 'pause',
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
!_historyController.pauseStatus.value
|
!_historyController
|
||||||
|
.baseCtr.pauseStatus.value
|
||||||
? '暂停观看记录'
|
? '暂停观看记录'
|
||||||
: '恢复观看记录',
|
: '恢复观看记录',
|
||||||
),
|
),
|
||||||
@@ -98,33 +154,100 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
child2: AppBar(
|
child2: AppBar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
tooltip: '取消',
|
tooltip: '取消',
|
||||||
onPressed: _historyController.handleSelect,
|
onPressed: () {
|
||||||
|
currCtr.handleSelect();
|
||||||
|
},
|
||||||
icon: const Icon(Icons.close_outlined),
|
icon: const Icon(Icons.close_outlined),
|
||||||
),
|
),
|
||||||
title: Obx(
|
title: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
'已选: ${_historyController.checkedCount.value}',
|
'已选: ${_historyController.baseCtr.checkedCount.value}',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => _historyController.handleSelect(true),
|
onPressed: () => currCtr.handleSelect(true),
|
||||||
child: const Text('全选'),
|
child: const Text('全选'),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
_historyController.onDelCheckedHistory(context),
|
currCtr.onDelCheckedHistory(context),
|
||||||
child: Text(
|
child: Text(
|
||||||
'删除',
|
'删除',
|
||||||
style:
|
style: TextStyle(
|
||||||
TextStyle(color: Theme.of(context).colorScheme.error),
|
color: Theme.of(context).colorScheme.error),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: refreshIndicator(
|
body: Obx(
|
||||||
|
() => _historyController.tabs.isNotEmpty
|
||||||
|
? Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TabBar(
|
||||||
|
controller: _historyController.tabController,
|
||||||
|
onTap: (value) {
|
||||||
|
if (_historyController
|
||||||
|
.tabController!.indexIsChanging.not) {
|
||||||
|
currCtr.scrollController.animToTop();
|
||||||
|
} else {
|
||||||
|
if (enableMultiSelect) {
|
||||||
|
if (_historyController
|
||||||
|
.tabController!.previousIndex ==
|
||||||
|
0) {
|
||||||
|
_historyController.handleSelect();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Get.find<HistoryController>(
|
||||||
|
tag: _historyController
|
||||||
|
.tabs[_historyController
|
||||||
|
.tabController!
|
||||||
|
.previousIndex -
|
||||||
|
1]
|
||||||
|
.type)
|
||||||
|
.handleSelect();
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tabs: [
|
||||||
|
Tab(text: '全部'),
|
||||||
|
..._historyController.tabs.map(
|
||||||
|
(item) => Tab(text: item.name),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: TabBarView(
|
||||||
|
physics: enableMultiSelect
|
||||||
|
? const NeverScrollableScrollPhysics()
|
||||||
|
: null,
|
||||||
|
controller: _historyController.tabController,
|
||||||
|
children: [
|
||||||
|
_buildPage,
|
||||||
|
..._historyController.tabs.map(
|
||||||
|
(item) => HistoryPage(type: item.type),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: _buildPage,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget get _buildPage => refreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await _historyController.onRefresh();
|
await _historyController.onRefresh();
|
||||||
},
|
},
|
||||||
@@ -133,18 +256,9 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
controller: _historyController.scrollController,
|
controller: _historyController.scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
Obx(() => _buildBody(_historyController.loadingState.value)),
|
Obx(() => _buildBody(_historyController.loadingState.value)),
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: SizedBox(
|
|
||||||
height: MediaQuery.of(context).padding.bottom + 80,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildBody(LoadingState loadingState) {
|
Widget _buildBody(LoadingState loadingState) {
|
||||||
return switch (loadingState) {
|
return switch (loadingState) {
|
||||||
@@ -162,7 +276,12 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||||
? SliverGrid(
|
? SliverPadding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: StyleString.safeSpace - 5,
|
||||||
|
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||||
|
),
|
||||||
|
sliver: SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||||
mainAxisSpacing: 2,
|
mainAxisSpacing: 2,
|
||||||
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
|
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
|
||||||
@@ -175,12 +294,13 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
}
|
}
|
||||||
return HistoryItem(
|
return HistoryItem(
|
||||||
videoItem: loadingState.response[index],
|
videoItem: loadingState.response[index],
|
||||||
ctr: _historyController,
|
ctr: _historyController.baseCtr,
|
||||||
onChoose: () => _historyController.onSelect(index),
|
onChoose: () => _historyController.onSelect(index),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: loadingState.response.length,
|
childCount: loadingState.response.length,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: HttpError(
|
: HttpError(
|
||||||
callback: _historyController.onReload,
|
callback: _historyController.onReload,
|
||||||
@@ -192,6 +312,9 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
LoadingState() => throw UnimplementedError(),
|
LoadingState() => throw UnimplementedError(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get wantKeepAlive => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
|
class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/video_progress_indicator.dart';
|
|||||||
import 'package:PiliPlus/models/user/history.dart';
|
import 'package:PiliPlus/models/user/history.dart';
|
||||||
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||||
import 'package:PiliPlus/pages/fav_search/controller.dart';
|
import 'package:PiliPlus/pages/fav_search/controller.dart';
|
||||||
|
import 'package:PiliPlus/pages/history/base_controller.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -35,7 +36,8 @@ class HistoryItem extends StatelessWidget {
|
|||||||
String bvid = videoItem.history.bvid ?? IdUtils.av2bv(aid);
|
String bvid = videoItem.history.bvid ?? IdUtils.av2bv(aid);
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (ctr is MultiSelectController && ctr!.enableMultiSelect.value) {
|
if ((ctr is MultiSelectController || ctr is HistoryBaseController) &&
|
||||||
|
ctr!.enableMultiSelect.value) {
|
||||||
feedBack();
|
feedBack();
|
||||||
onChoose?.call();
|
onChoose?.call();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user