mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 13:05:11 +00:00
chore: Follow up search UX
This commit is contained in:
parent
62122e5c79
commit
fb384462e0
2 changed files with 8 additions and 2 deletions
|
@ -192,10 +192,12 @@ class ChatListController extends State<ChatList>
|
|||
setState(() {
|
||||
searchServer = newServer.single;
|
||||
});
|
||||
onSearchEnter(searchController.text);
|
||||
_coolDown?.cancel();
|
||||
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
||||
}
|
||||
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
|
||||
void _search() async {
|
||||
final client = Matrix.of(context).client;
|
||||
|
@ -251,6 +253,9 @@ class ChatListController extends State<ChatList>
|
|||
setState(() {
|
||||
isSearchMode = true;
|
||||
});
|
||||
searchFocusNode.requestFocus();
|
||||
_coolDown?.cancel();
|
||||
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
||||
}
|
||||
|
||||
void cancelSearch({bool unfocus = true}) {
|
||||
|
@ -260,7 +265,7 @@ class ChatListController extends State<ChatList>
|
|||
roomSearchResult = userSearchResult = null;
|
||||
isSearching = false;
|
||||
});
|
||||
if (unfocus) FocusManager.instance.primaryFocus?.unfocus();
|
||||
if (unfocus) searchFocusNode.unfocus();
|
||||
}
|
||||
|
||||
bool isTorBrowser = false;
|
||||
|
|
|
@ -45,6 +45,7 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||
)
|
||||
: TextField(
|
||||
controller: controller.searchController,
|
||||
focusNode: controller.searchFocusNode,
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: controller.onSearchEnter,
|
||||
decoration: InputDecoration(
|
||||
|
|
Loading…
Reference in a new issue