diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index af04584b..79afa8a0 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -10,6 +10,9 @@ import 'package:PiliPlus/utils/storage.dart'; import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart'; class SSearchController extends GetxController { + late final historyOff = + ''; + final searchFocusNode = FocusNode(); final controller = TextEditingController(); @@ -29,6 +32,7 @@ class SSearchController extends GetxController { final _debouncer = Debouncer(delay: const Duration(milliseconds: 200)); late final searchSuggestion = GStorage.searchSuggestion; + late final RxBool recordSearchHistory = GStorage.recordSearchHistory.obs; @override void onInit() { @@ -90,7 +94,7 @@ class SSearchController extends GetxController { validateUid(); } - if (MineController.anonymity.value.not) { + if (MineController.anonymity.value.not && recordSearchHistory.value) { historyList.remove(controller.text); historyList.insert(0, controller.text); GStorage.historyWord.put('cacheList', historyList); diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index 6c0b238c..cfc6a8c4 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -1,7 +1,9 @@ import 'package:PiliPlus/common/widgets/loading_widget.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models/search/suggest.dart'; +import 'package:PiliPlus/utils/storage.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; import 'controller.dart'; import 'widgets/hot_keyword.dart'; @@ -199,15 +201,60 @@ class _SearchPageState extends State with RouteAware { Padding( padding: const EdgeInsets.fromLTRB(6, 0, 6, 6), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '搜索历史', + strutStyle: StrutStyle(leading: 0, height: 1), style: Theme.of(context) .textTheme .titleMedium! - .copyWith(fontWeight: FontWeight.bold), + .copyWith(height: 1, fontWeight: FontWeight.bold), ), + const SizedBox(width: 12), + Obx( + () => SizedBox( + width: 34, + height: 34, + child: IconButton( + iconSize: 22, + tooltip: _searchController.recordSearchHistory.value + ? '记录搜索' + : '无痕搜索', + icon: _searchController.recordSearchHistory.value + ? Icon( + Icons.history, + color: Theme.of(context) + .colorScheme + .onSurfaceVariant + .withOpacity(0.8), + ) + : SvgPicture.string( + width: 22, + height: 22, + colorFilter: ColorFilter.mode( + Theme.of(context) + .colorScheme + .outline + .withOpacity(0.8), + BlendMode.srcIn, + ), + _searchController.historyOff, + ), + style: IconButton.styleFrom( + padding: EdgeInsets.zero, + ), + onPressed: () { + _searchController.recordSearchHistory.value = + !_searchController.recordSearchHistory.value; + GStorage.setting.put( + SettingBoxKey.recordSearchHistory, + _searchController.recordSearchHistory.value, + ); + }, + ), + ), + ), + const Spacer(), SizedBox( height: 34, child: TextButton.icon( diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index 58e666dd..ea9e0ec5 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -1974,6 +1974,13 @@ List get extraSettings => [ setKey: SettingBoxKey.searchSuggestion, defaultVal: true, ), + SettingsModel( + settingsType: SettingsType.sw1tch, + title: '记录搜索历史', + leading: const Icon(Icons.history), + setKey: SettingBoxKey.recordSearchHistory, + defaultVal: true, + ), SettingsModel( settingsType: SettingsType.sw1tch, title: '展示头像/评论/动态装饰', diff --git a/lib/pages/video/detail/view_v.dart b/lib/pages/video/detail/view_v.dart index d015d942..6aa6fcc3 100644 --- a/lib/pages/video/detail/view_v.dart +++ b/lib/pages/video/detail/view_v.dart @@ -1763,11 +1763,13 @@ class _VideoDetailPageVState extends State .plPlayerController.isOpenDanmu.value ? 'assets/images/video/danmu_open.svg' : 'assets/images/video/danmu_close.svg', - // ignore: deprecated_member_use - color: videoDetailController - .plPlayerController.isOpenDanmu.value - ? themeData.colorScheme.secondary - : themeData.colorScheme.outline, + colorFilter: ColorFilter.mode( + videoDetailController + .plPlayerController.isOpenDanmu.value + ? themeData.colorScheme.secondary + : themeData.colorScheme.outline, + BlendMode.srcIn, + ), ), ), ), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 75b2d5e4..9057f34b 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -442,6 +442,9 @@ class GStorage { static int get fastForBackwardDuration => GStorage.setting .get(SettingBoxKey.fastForBackwardDuration, defaultValue: 10); + static bool get recordSearchHistory => GStorage.setting + .get(SettingBoxKey.recordSearchHistory, defaultValue: true); + static List get dynamicDetailRatio => List.from(setting .get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0])); @@ -724,6 +727,7 @@ class SettingBoxKey { appFontWeight = 'appFontWeight', enableDragSubtitle = 'enableDragSubtitle', fastForBackwardDuration = 'fastForBackwardDuration', + recordSearchHistory = 'recordSearchHistory', // Sponsor Block enableSponsorBlock = 'enableSponsorBlock',