opt: search TextField suffix
This commit is contained in:
@ -50,28 +50,10 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => _searchController.submit(),
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(width: 10)
|
||||
],
|
||||
title: Obx(
|
||||
() => TextField(
|
||||
autofocus: true,
|
||||
focusNode: _searchController.searchFocusNode,
|
||||
controller: _searchController.controller.value,
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: _searchController.onChange,
|
||||
decoration: InputDecoration(
|
||||
hintText: _searchController.hintText,
|
||||
border: InputBorder.none,
|
||||
suffix: Obx(() {
|
||||
Obx(() {
|
||||
RxString searchKeyWord = _searchController.searchKeyWord;
|
||||
if (searchKeyWord.value.isEmpty) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Row(
|
||||
return searchKeyWord.value.isNotEmpty
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (RegExp(r'^\d+$').hasMatch(searchKeyWord.value))
|
||||
@ -86,11 +68,28 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.clear, size: 22),
|
||||
onPressed: () => _searchController.onClear(),
|
||||
onPressed: _searchController.onClear,
|
||||
),
|
||||
],
|
||||
);
|
||||
)
|
||||
: const SizedBox();
|
||||
}),
|
||||
IconButton(
|
||||
onPressed: _searchController.submit,
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(width: 10)
|
||||
],
|
||||
title: Obx(
|
||||
() => TextField(
|
||||
autofocus: true,
|
||||
focusNode: _searchController.searchFocusNode,
|
||||
controller: _searchController.controller.value,
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: _searchController.onChange,
|
||||
decoration: InputDecoration(
|
||||
hintText: _searchController.hintText,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onSubmitted: (String value) => _searchController.submit(),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user