Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix can't search with hint-text #1048

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/pages/search/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SSearchController extends GetxController {
RxList<SearchSuggestItem> searchSuggestList = <SearchSuggestItem>[].obs;
final _debouncer =
Debouncer(delay: const Duration(milliseconds: 200)); // 设置延迟时间
bool customSearchHint = false;
String hintText = '搜索';
RxString defaultSearch = ''.obs;
Box setting = GStrorage.setting;
Expand All @@ -32,8 +33,11 @@ class SSearchController extends GetxController {
onClickKeyword(Get.parameters['keyword']!);
}
if (Get.parameters['hintText'] != null) {
customSearchHint = true;
hintText = Get.parameters['hintText']!;
searchKeyWord.value = hintText;
} else {
customSearchHint = false;
}
}
historyCacheList = histiryWord.get('cacheList') ?? [];
Expand All @@ -44,6 +48,9 @@ class SSearchController extends GetxController {
void onChange(value) {
searchKeyWord.value = value;
if (value == '') {
if (customSearchHint) {
searchKeyWord.value = hintText;
}
searchSuggestList.value = [];
return;
}
Expand All @@ -53,7 +60,11 @@ class SSearchController extends GetxController {
void onClear() {
if (searchKeyWord.value.isNotEmpty && controller.value.text != '') {
controller.value.clear();
searchKeyWord.value = '';
if (customSearchHint) {
searchKeyWord.value = hintText;
} else {
searchKeyWord.value = '';
}
searchSuggestList.value = [];
} else {
Get.back();
Expand Down