diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index b59520c7..bc81f121 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -50,8 +50,32 @@ class _SearchPageState extends State with RouteAware { ), ), 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( - onPressed: () => _searchController.submit(), + onPressed: _searchController.submit, icon: const Icon(Icons.search), ), const SizedBox(width: 10) @@ -66,31 +90,6 @@ class _SearchPageState extends State with RouteAware { decoration: InputDecoration( hintText: _searchController.hintText, 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(), ),