opt: search TextField suffix
This commit is contained in:
@ -50,8 +50,32 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
Obx(() {
|
||||||
|
RxString searchKeyWord = _searchController.searchKeyWord;
|
||||||
|
return searchKeyWord.value.isNotEmpty
|
||||||
|
? 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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: const SizedBox();
|
||||||
|
}),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => _searchController.submit(),
|
onPressed: _searchController.submit,
|
||||||
icon: const Icon(Icons.search),
|
icon: const Icon(Icons.search),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10)
|
const SizedBox(width: 10)
|
||||||
@ -66,31 +90,6 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: _searchController.hintText,
|
hintText: _searchController.hintText,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
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(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
onSubmitted: (String value) => _searchController.submit(),
|
onSubmitted: (String value) => _searchController.submit(),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user