mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom enable search suggestion
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:PiliPlus/http/search.dart';
|
import 'package:PiliPlus/http/search.dart';
|
||||||
import 'package:PiliPlus/models/search/suggest.dart';
|
import 'package:PiliPlus/models/search/suggest.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
|
import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart';
|
||||||
|
|
||||||
class SSearchController extends GetxController {
|
class SSearchController extends GetxController {
|
||||||
final searchFocusNode = FocusNode();
|
final searchFocusNode = FocusNode();
|
||||||
@@ -23,6 +24,9 @@ class SSearchController extends GetxController {
|
|||||||
|
|
||||||
RxBool showUidBtn = false.obs;
|
RxBool showUidBtn = false.obs;
|
||||||
|
|
||||||
|
final _debouncer = Debouncer(delay: const Duration(milliseconds: 200));
|
||||||
|
late final searchSuggestion = GStorage.searchSuggestion;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -54,8 +58,8 @@ class SSearchController extends GetxController {
|
|||||||
validateUid();
|
validateUid();
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
searchSuggestList.clear();
|
searchSuggestList.clear();
|
||||||
} else {
|
} else if (searchSuggestion) {
|
||||||
querySearchSuggest(value);
|
_debouncer.call(() => querySearchSuggest(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +140,7 @@ class SSearchController extends GetxController {
|
|||||||
void onClose() {
|
void onClose() {
|
||||||
searchFocusNode.dispose();
|
searchFocusNode.dispose();
|
||||||
controller.dispose();
|
controller.dispose();
|
||||||
|
_debouncer.cancel();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1903,6 +1903,13 @@ List<SettingsModel> get extraSettings => [
|
|||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
needReboot: true,
|
needReboot: true,
|
||||||
),
|
),
|
||||||
|
SettingsModel(
|
||||||
|
settingsType: SettingsType.sw1tch,
|
||||||
|
title: '搜索建议',
|
||||||
|
leading: Icon(Icons.search),
|
||||||
|
setKey: SettingBoxKey.searchSuggestion,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
enableFeedback: true,
|
enableFeedback: true,
|
||||||
|
|||||||
@@ -348,6 +348,9 @@ class GStorage {
|
|||||||
static bool get mainTabBarView =>
|
static bool get mainTabBarView =>
|
||||||
GStorage.setting.get(SettingBoxKey.mainTabBarView, defaultValue: false);
|
GStorage.setting.get(SettingBoxKey.mainTabBarView, defaultValue: false);
|
||||||
|
|
||||||
|
static bool get searchSuggestion =>
|
||||||
|
GStorage.setting.get(SettingBoxKey.searchSuggestion, defaultValue: true);
|
||||||
|
|
||||||
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
||||||
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
||||||
|
|
||||||
@@ -573,6 +576,7 @@ class SettingBoxKey {
|
|||||||
superResolutionType = 'superResolutionType',
|
superResolutionType = 'superResolutionType',
|
||||||
preInitPlayer = 'preInitPlayer',
|
preInitPlayer = 'preInitPlayer',
|
||||||
mainTabBarView = 'mainTabBarView',
|
mainTabBarView = 'mainTabBarView',
|
||||||
|
searchSuggestion = 'searchSuggestion',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user