mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 09:37:52 +08:00
@@ -44,9 +44,6 @@ class _HistoryPageState extends State<HistoryPage>
|
||||
return _historyController;
|
||||
}
|
||||
|
||||
bool get enableMultiSelect =>
|
||||
_historyController.baseCtr.enableMultiSelect.value;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Get.delete<HistoryBaseController>();
|
||||
@@ -59,176 +56,182 @@ class _HistoryPageState extends State<HistoryPage>
|
||||
return widget.type != null
|
||||
? _buildPage
|
||||
: Obx(
|
||||
() => PopScope(
|
||||
canPop: !enableMultiSelect,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (enableMultiSelect) {
|
||||
currCtr().handleSelect();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: widget.type != null
|
||||
? null
|
||||
: AppBarWidget(
|
||||
visible: enableMultiSelect,
|
||||
child1: AppBar(
|
||||
title: const Text('观看记录'),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '搜索',
|
||||
onPressed: () => Get.toNamed('/historySearch'),
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (String type) {
|
||||
// 处理菜单项选择的逻辑
|
||||
switch (type) {
|
||||
case 'pause':
|
||||
_historyController.baseCtr
|
||||
.onPauseHistory(context);
|
||||
break;
|
||||
case 'clear':
|
||||
_historyController.baseCtr
|
||||
.onClearHistory(context, () {
|
||||
_historyController.loadingState.value =
|
||||
const Success(null);
|
||||
if (_historyController.tabController !=
|
||||
null) {
|
||||
for (final item
|
||||
in _historyController.tabs) {
|
||||
try {
|
||||
Get.find<HistoryController>(
|
||||
tag: item.type)
|
||||
.loadingState
|
||||
.value = const Success(null);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'del':
|
||||
currCtr().onDelHistory();
|
||||
break;
|
||||
case 'multiple':
|
||||
_historyController
|
||||
.baseCtr.enableMultiSelect.value = true;
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'pause',
|
||||
child: Obx(
|
||||
() => Text(
|
||||
!_historyController
|
||||
.baseCtr.pauseStatus.value
|
||||
? '暂停观看记录'
|
||||
: '恢复观看记录',
|
||||
),
|
||||
),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'clear',
|
||||
child: Text('清空观看记录'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'del',
|
||||
child: Text('删除已看记录'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'multiple',
|
||||
child: Text('多选删除'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
child2: AppBar(
|
||||
leading: IconButton(
|
||||
tooltip: '取消',
|
||||
onPressed: currCtr().handleSelect,
|
||||
icon: const Icon(Icons.close_outlined),
|
||||
),
|
||||
title: Obx(
|
||||
() => Text(
|
||||
'已选: ${_historyController.baseCtr.checkedCount.value}',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => currCtr().handleSelect(true),
|
||||
child: const Text('全选'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
currCtr().onDelCheckedHistory(context),
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error),
|
||||
() {
|
||||
final enableMultiSelect =
|
||||
_historyController.baseCtr.enableMultiSelect.value;
|
||||
return PopScope(
|
||||
canPop: !enableMultiSelect,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (enableMultiSelect) {
|
||||
currCtr().handleSelect();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: widget.type != null
|
||||
? null
|
||||
: AppBarWidget(
|
||||
visible: enableMultiSelect,
|
||||
child1: AppBar(
|
||||
title: const Text('观看记录'),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '搜索',
|
||||
onPressed: () => Get.toNamed('/historySearch'),
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Obx(
|
||||
() => _historyController.tabs.isNotEmpty
|
||||
? SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TabBar(
|
||||
controller: _historyController.tabController,
|
||||
onTap: (index) {
|
||||
if (!_historyController
|
||||
.tabController!.indexIsChanging) {
|
||||
currCtr().scrollController.animToTop();
|
||||
} else {
|
||||
if (enableMultiSelect) {
|
||||
currCtr(_historyController
|
||||
.tabController!.previousIndex)
|
||||
.handleSelect();
|
||||
}
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (String type) {
|
||||
// 处理菜单项选择的逻辑
|
||||
switch (type) {
|
||||
case 'pause':
|
||||
_historyController.baseCtr
|
||||
.onPauseHistory(context);
|
||||
break;
|
||||
case 'clear':
|
||||
_historyController.baseCtr
|
||||
.onClearHistory(context, () {
|
||||
_historyController.loadingState.value =
|
||||
const Success(null);
|
||||
if (_historyController.tabController !=
|
||||
null) {
|
||||
for (final item
|
||||
in _historyController.tabs) {
|
||||
try {
|
||||
Get.find<HistoryController>(
|
||||
tag: item.type)
|
||||
.loadingState
|
||||
.value = const Success(null);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'del':
|
||||
currCtr().onDelHistory();
|
||||
break;
|
||||
case 'multiple':
|
||||
_historyController.baseCtr
|
||||
.enableMultiSelect.value = true;
|
||||
break;
|
||||
}
|
||||
},
|
||||
tabs: [
|
||||
const Tab(text: '全部'),
|
||||
..._historyController.tabs.map(
|
||||
(item) => Tab(text: item.name),
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'pause',
|
||||
child: Obx(
|
||||
() => Text(
|
||||
!_historyController
|
||||
.baseCtr.pauseStatus.value
|
||||
? '暂停观看记录'
|
||||
: '恢复观看记录',
|
||||
),
|
||||
),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'clear',
|
||||
child: Text('清空观看记录'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'del',
|
||||
child: Text('删除已看记录'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'multiple',
|
||||
child: Text('多选删除'),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: enableMultiSelect
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const CustomTabBarViewScrollPhysics(),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
child2: AppBar(
|
||||
leading: IconButton(
|
||||
tooltip: '取消',
|
||||
onPressed: currCtr().handleSelect,
|
||||
icon: const Icon(Icons.close_outlined),
|
||||
),
|
||||
title: Obx(
|
||||
() => Text(
|
||||
'已选: ${_historyController.baseCtr.checkedCount.value}',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => currCtr().handleSelect(true),
|
||||
child: const Text('全选'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
currCtr().onDelCheckedHistory(context),
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Obx(
|
||||
() => _historyController.tabs.isNotEmpty
|
||||
? SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TabBar(
|
||||
controller: _historyController.tabController,
|
||||
children: [
|
||||
KeepAliveWrapper(
|
||||
builder: (context) => _buildPage),
|
||||
onTap: (index) {
|
||||
if (!_historyController
|
||||
.tabController!.indexIsChanging) {
|
||||
currCtr().scrollController.animToTop();
|
||||
} else {
|
||||
if (enableMultiSelect) {
|
||||
currCtr(_historyController
|
||||
.tabController!.previousIndex)
|
||||
.handleSelect();
|
||||
}
|
||||
}
|
||||
},
|
||||
tabs: [
|
||||
const Tab(text: '全部'),
|
||||
..._historyController.tabs.map(
|
||||
(item) => HistoryPage(type: item.type),
|
||||
(item) => Tab(text: item.name),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: enableMultiSelect
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const CustomTabBarViewScrollPhysics(),
|
||||
controller:
|
||||
_historyController.tabController,
|
||||
children: [
|
||||
KeepAliveWrapper(
|
||||
builder: (context) => _buildPage),
|
||||
..._historyController.tabs.map(
|
||||
(item) => HistoryPage(type: item.type),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: _buildPage,
|
||||
),
|
||||
)
|
||||
: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: _buildPage,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user