TF-1354 Support use Up/Down in keyboard to move selection in the list

This commit is contained in:
dab246
2023-01-11 09:51:18 +07:00
committed by Dat H. Pham
parent d49f276ff3
commit fb690ea078
4 changed files with 34 additions and 21 deletions
@@ -123,7 +123,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
);
},
findSuggestions: _findSuggestions,
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress) {
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, highlight) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: ContactSuggestionBoxItem(
@@ -132,7 +132,8 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
borderRadius: BorderRadius.all(Radius.circular(12))),
selectedContactCallbackAction: (contact) {
setState(() => listEmailAddress.add(contact));
tagEditorState.selectSuggestion(suggestionEmailAddress);
tagEditorState.closeSuggestionBox();
tagEditorState.resetTextField();
},
),
);
@@ -199,6 +200,11 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
teamMailSuggestion.addAll(_matchedSuggestionEmailAddress(processedQuery, listEmailAddress));
final currentTextOnTextField = widget.controller?.text ?? '';
if (currentTextOnTextField.isEmpty) {
return [];
}
return teamMailSuggestion.toSet().toList();
}