mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: search by uid
Closes #157 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -21,6 +21,8 @@ class SSearchController extends GetxController {
|
|||||||
|
|
||||||
int initIndex = 0;
|
int initIndex = 0;
|
||||||
|
|
||||||
|
RxBool showUidBtn = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -44,7 +46,12 @@ class SSearchController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void validateUid() {
|
||||||
|
showUidBtn.value = RegExp(r'^\d+$').hasMatch(controller.text);
|
||||||
|
}
|
||||||
|
|
||||||
void onChange(String value) {
|
void onChange(String value) {
|
||||||
|
validateUid();
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
searchSuggestList.clear();
|
searchSuggestList.clear();
|
||||||
} else {
|
} else {
|
||||||
@@ -57,6 +64,7 @@ class SSearchController extends GetxController {
|
|||||||
controller.clear();
|
controller.clear();
|
||||||
searchSuggestList.clear();
|
searchSuggestList.clear();
|
||||||
searchFocusNode.requestFocus();
|
searchFocusNode.requestFocus();
|
||||||
|
showUidBtn.value = false;
|
||||||
} else {
|
} else {
|
||||||
Get.back();
|
Get.back();
|
||||||
}
|
}
|
||||||
@@ -69,6 +77,7 @@ class SSearchController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controller.text = hintText;
|
controller.text = hintText;
|
||||||
|
validateUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
historyList.remove(controller.text);
|
historyList.remove(controller.text);
|
||||||
@@ -98,6 +107,8 @@ class SSearchController extends GetxController {
|
|||||||
|
|
||||||
void onClickKeyword(String keyword) {
|
void onClickKeyword(String keyword) {
|
||||||
controller.text = keyword;
|
controller.text = keyword;
|
||||||
|
validateUid();
|
||||||
|
|
||||||
searchSuggestList.clear();
|
searchSuggestList.clear();
|
||||||
submit();
|
submit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,26 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
Obx(
|
||||||
|
() => _searchController.showUidBtn.value
|
||||||
|
? IconButton(
|
||||||
|
tooltip: 'UID搜索用户',
|
||||||
|
icon: const Icon(Icons.person_outline, size: 22),
|
||||||
|
onPressed: () {
|
||||||
|
if (RegExp(r'^\d+$')
|
||||||
|
.hasMatch(_searchController.controller.text)) {
|
||||||
|
Get.toNamed(
|
||||||
|
'/member?mid=${_searchController.controller.text}');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
tooltip: '清空',
|
||||||
|
icon: const Icon(Icons.clear, size: 22),
|
||||||
|
onPressed: _searchController.onClear,
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
tooltip: '搜索',
|
tooltip: '搜索',
|
||||||
onPressed: () => _searchController.submit(),
|
onPressed: () => _searchController.submit(),
|
||||||
@@ -46,11 +66,6 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: _searchController.hintText,
|
hintText: _searchController.hintText,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
suffixIcon: IconButton(
|
|
||||||
tooltip: '清空',
|
|
||||||
icon: const Icon(Icons.clear, size: 22),
|
|
||||||
onPressed: _searchController.onClear,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onSubmitted: (value) => _searchController.submit(),
|
onSubmitted: (value) => _searchController.submit(),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user