diff --git a/lib/pages/history/view.dart b/lib/pages/history/view.dart index 858f751d7..c461e2cf8 100644 --- a/lib/pages/history/view.dart +++ b/lib/pages/history/view.dart @@ -67,126 +67,123 @@ class _HistoryPageState extends State } }, 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( - onSelected: (String type) { - // 处理菜单项选择的逻辑 - switch (type) { - case 'pause': - _historyController.baseCtr.onPauseHistory( - context, - ); - break; - case 'clear': - _historyController.baseCtr.onClearHistory( - context, - () { - _historyController - .loadingState - .value = const Success( + appBar: AppBarWidget( + visible: enableMultiSelect, + child1: AppBar( + title: const Text('观看记录'), + actions: [ + IconButton( + tooltip: '搜索', + onPressed: () => Get.toNamed('/historySearch'), + icon: const Icon(Icons.search_outlined), + ), + PopupMenuButton( + 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( + tag: item.type, + ).loadingState.value = const Success( null, ); - if (_historyController - .tabController != - null) { - for (final item - in _historyController.tabs) { - try { - Get.find( - tag: item.type, - ).loadingState.value = - const Success(null); - } catch (_) {} - } - } - }, - ); - break; - case 'del': - currCtr().onDelHistory(); - break; - case 'multiple': - _historyController + } catch (_) {} + } + } + }, + ); + break; + case 'del': + currCtr().onDelHistory(); + break; + case 'multiple': + _historyController + .baseCtr + .enableMultiSelect + .value = + true; + break; + } + }, + itemBuilder: (BuildContext context) => + >[ + PopupMenuItem( + value: 'pause', + child: Obx( + () => Text( + !_historyController .baseCtr - .enableMultiSelect - .value = - true; - break; - } - }, - itemBuilder: (BuildContext context) => - >[ - PopupMenuItem( - value: 'pause', - child: Obx( - () => Text( - !_historyController - .baseCtr - .pauseStatus - .value - ? '暂停观看记录' - : '恢复观看记录', - ), - ), - ), - const PopupMenuItem( - value: 'clear', - child: Text('清空观看记录'), - ), - const PopupMenuItem( - value: 'del', - child: Text('删除已看记录'), - ), - const PopupMenuItem( - 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, + .pauseStatus + .value + ? '暂停观看记录' + : '恢复观看记录', + ), ), ), - ), - const SizedBox(width: 6), - ], + const PopupMenuItem( + value: 'clear', + child: Text('清空观看记录'), + ), + const PopupMenuItem( + value: 'del', + child: Text('删除已看记录'), + ), + const PopupMenuItem( + 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, + ), ), ), + const SizedBox(width: 6), + ], + ), + ), body: Obx( () => _historyController.tabs.isNotEmpty ? SafeArea( @@ -300,8 +297,22 @@ class _HistoryPageState extends State childCount: response!.length, ), ) - : HttpError( - onReload: _historyController.onReload, + : Builder( + builder: (context) { + final pauseStatus = + _historyController.baseCtr.pauseStatus.value; + return HttpError( + errMsg: pauseStatus ? '历史记录功能已关闭' : null, + btnText: pauseStatus ? '点击开启' : null, + onReload: () { + if (pauseStatus) { + _historyController.baseCtr.onPauseHistory(context); + } else { + _historyController.onReload(); + } + }, + ); + }, ), Error(:var errMsg) => HttpError( errMsg: errMsg,