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