feat: search suggestion switch
This commit is contained in:
@ -25,6 +25,7 @@ class SSearchController extends GetxController {
|
||||
RxString defaultSearch = ''.obs;
|
||||
Box setting = GStrorage.setting;
|
||||
bool enableHotKey = true;
|
||||
bool enableSearchSuggest = true;
|
||||
late StreamController<bool> clearStream = StreamController<bool>.broadcast();
|
||||
|
||||
@override
|
||||
@ -47,6 +48,7 @@ class SSearchController extends GetxController {
|
||||
historyCacheList = GlobalDataCache().historyCacheList;
|
||||
historyList.value = historyCacheList;
|
||||
enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
|
||||
enableSearchSuggest = GlobalDataCache().enableSearchSuggest;
|
||||
}
|
||||
|
||||
void onChange(value) {
|
||||
@ -57,18 +59,16 @@ class SSearchController extends GetxController {
|
||||
return;
|
||||
}
|
||||
clearStream.add(true);
|
||||
_debouncer.call(() => querySearchSuggest(value));
|
||||
if (enableSearchSuggest) {
|
||||
_debouncer.call(() => querySearchSuggest(value));
|
||||
}
|
||||
}
|
||||
|
||||
void onClear() {
|
||||
if (searchKeyWord.value.isNotEmpty && controller.value.text != '') {
|
||||
controller.value.clear();
|
||||
searchKeyWord.value = '';
|
||||
searchSuggestList.value = [];
|
||||
clearStream.add(false);
|
||||
} else {
|
||||
Get.back();
|
||||
}
|
||||
controller.value.clear();
|
||||
searchKeyWord.value = '';
|
||||
searchSuggestList.value = [];
|
||||
clearStream.add(false);
|
||||
}
|
||||
|
||||
// 搜索
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/common/dynamics_type.dart';
|
||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
import '../home/index.dart';
|
||||
@ -146,6 +147,15 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
setKey: SettingBoxKey.enableHotKey,
|
||||
defaultVal: true,
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '展示搜索建议',
|
||||
subTitle: '输入搜索内容时展示建议词',
|
||||
setKey: SettingBoxKey.enableSearchSuggest,
|
||||
defaultVal: true,
|
||||
callFn: (val) {
|
||||
GlobalDataCache().enableSearchSuggest = val;
|
||||
},
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '搜索默认词',
|
||||
subTitle: '是否展示搜索框默认词',
|
||||
|
||||
Reference in New Issue
Block a user