feat: search user by uid

This commit is contained in:
guozhigq
2024-10-26 16:31:01 +08:00
parent baa6a644e3
commit 4f6ac4aff4
4 changed files with 83 additions and 40 deletions

View File

@ -63,24 +63,35 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
focusNode: _searchController.searchFocusNode,
controller: _searchController.controller.value,
textInputAction: TextInputAction.search,
onChanged: (value) => _searchController.onChange(value),
onChanged: _searchController.onChange,
decoration: InputDecoration(
hintText: _searchController.hintText,
border: InputBorder.none,
suffixIcon: StreamBuilder(
initialData: false,
stream: _searchController.clearStream.stream,
builder: (_, snapshot) {
if (snapshot.data == true) {
return IconButton(
suffix: Obx(() {
RxString searchKeyWord = _searchController.searchKeyWord;
if (searchKeyWord.value.isEmpty) {
return const SizedBox();
}
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (RegExp(r'^\d+$').hasMatch(searchKeyWord.value))
IconButton(
tooltip: '直达up主页',
icon: const Icon(Icons.person_outline, size: 22),
onPressed: () {
_searchController.cacheHistory();
Get.toNamed('/member?mid=${searchKeyWord.value}',
arguments: {'face': null});
},
),
IconButton(
icon: const Icon(Icons.clear, size: 22),
onPressed: () => _searchController.onClear(),
);
} else {
return const SizedBox();
}
},
),
),
],
);
}),
),
onSubmitted: (String value) => _searchController.submit(),
),