mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: record search history option
Closes #592 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -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 =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000000"><path d="m785-289-58-58q16-29 24.5-63t8.5-70q0-117-81.5-198.5T480-760q-35 0-68.5 8.5T348-726l-59-59q43-26 91.5-40.5T480-840q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-480q0 53-14.5 101T785-289ZM520-554l-80-80v-46h80v126ZM792-56 672-176q-42 26-90 41t-102 15q-138 0-240.5-91.5T122-440h82q14 104 92.5 172T480-200q37 0 70.5-8.5T614-234L288-560H120v-168l-64-64 56-56 736 736-56 56Z"/></svg>';
|
||||
|
||||
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);
|
||||
|
||||
@@ -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<SearchPage> 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(
|
||||
|
||||
@@ -1974,6 +1974,13 @@ List<SettingsModel> 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: '展示头像/评论/动态装饰',
|
||||
|
||||
@@ -1763,11 +1763,13 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
.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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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<double> get dynamicDetailRatio => List<double>.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',
|
||||
|
||||
Reference in New Issue
Block a user