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
@@ -149,6 +149,12 @@ class EmailAddressInputBuilder {
suggestionsBoxMaxHeight: 300, suggestionsBoxMaxHeight: 300,
textStyle: const TextStyle(color: AppColor.colorEmailAddress, fontSize: 14, fontWeight: FontWeight.w500), textStyle: const TextStyle(color: AppColor.colorEmailAddress, fontSize: 14, fontWeight: FontWeight.w500),
onDeleteTagAction: () => _handleDeleteTagAction(setState), onDeleteTagAction: () => _handleDeleteTagAction(setState),
onSelectOptionAction: (item) {
if (!_isDuplicatedRecipient(item.emailAddress.emailAddress)) {
setState(() => listEmailAddress.add(item.emailAddress));
_onUpdateListEmailAddressAction?.call(_prefixEmailAddress, listEmailAddress);
}
},
onSubmitted: (value) { onSubmitted: (value) {
log('EmailAddressInputBuilder::_buildTagEditor(): onSubmitted: $value'); log('EmailAddressInputBuilder::_buildTagEditor(): onSubmitted: $value');
if (!_isDuplicatedRecipient(value)) { if (!_isDuplicatedRecipient(value)) {
@@ -201,7 +207,7 @@ class EmailAddressInputBuilder {
_handleGapBetweenTagChangedAndFindSuggestion); _handleGapBetweenTagChangedAndFindSuggestion);
}, },
findSuggestions: _findSuggestions, findSuggestions: _findSuggestions,
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress) { suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, highlight) {
switch (suggestionEmailAddress.state) { switch (suggestionEmailAddress.state) {
case SuggestionEmailState.duplicated: case SuggestionEmailState.duplicated:
return _buildExistedSuggestionItem(setState, context, suggestionEmailAddress); return _buildExistedSuggestionItem(setState, context, suggestionEmailAddress);
@@ -315,7 +321,8 @@ class EmailAddressInputBuilder {
log('EmailAddressInputBuilder::_buildSuggestionItem(): onTap: $suggestionEmailAddress'); log('EmailAddressInputBuilder::_buildSuggestionItem(): onTap: $suggestionEmailAddress');
setState(() => listEmailAddress.add(suggestionEmailAddress.emailAddress)); setState(() => listEmailAddress.add(suggestionEmailAddress.emailAddress));
_onUpdateListEmailAddressAction?.call(_prefixEmailAddress, listEmailAddress); _onUpdateListEmailAddressAction?.call(_prefixEmailAddress, listEmailAddress);
tagEditorState.selectSuggestion(suggestionEmailAddress); tagEditorState.closeSuggestionBox();
tagEditorState.resetTextField();
}, },
); );
} }
@@ -123,7 +123,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
); );
}, },
findSuggestions: _findSuggestions, findSuggestions: _findSuggestions,
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress) { suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, highlight) {
return Container( return Container(
padding: const EdgeInsets.symmetric(horizontal: 12), padding: const EdgeInsets.symmetric(horizontal: 12),
child: ContactSuggestionBoxItem( child: ContactSuggestionBoxItem(
@@ -132,7 +132,8 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
borderRadius: BorderRadius.all(Radius.circular(12))), borderRadius: BorderRadius.all(Radius.circular(12))),
selectedContactCallbackAction: (contact) { selectedContactCallbackAction: (contact) {
setState(() => listEmailAddress.add(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)); teamMailSuggestion.addAll(_matchedSuggestionEmailAddress(processedQuery, listEmailAddress));
final currentTextOnTextField = widget.controller?.text ?? '';
if (currentTextOnTextField.isEmpty) {
return [];
}
return teamMailSuggestion.toSet().toList(); return teamMailSuggestion.toSet().toList();
} }
+16 -16
View File
@@ -14,7 +14,7 @@ packages:
name: _flutterfire_internals name: _flutterfire_internals
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.10" version: "1.0.11"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
@@ -154,21 +154,21 @@ packages:
name: cloud_firestore_platform_interface name: cloud_firestore_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.9.1" version: "5.10.0"
cloud_firestore_web: cloud_firestore_web:
dependency: transitive dependency: transitive
description: description:
name: cloud_firestore_web name: cloud_firestore_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.1" version: "3.2.0"
code_builder: code_builder:
dependency: transitive dependency: transitive
description: description:
name: code_builder name: code_builder
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.3.0" version: "4.4.0"
collection: collection:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -480,7 +480,7 @@ packages:
name: firebase_core_web name: firebase_core_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.1.0"
firebase_messaging: firebase_messaging:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -494,14 +494,14 @@ packages:
name: firebase_messaging_platform_interface name: firebase_messaging_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.2.8" version: "4.2.9"
firebase_messaging_web: firebase_messaging_web:
dependency: transitive dependency: transitive
description: description:
name: firebase_messaging_web name: firebase_messaging_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.2.9" version: "3.2.10"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@@ -837,7 +837,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.2.2" version: "3.3.0"
infinite_listview: infinite_listview:
dependency: transitive dependency: transitive
description: description:
@@ -871,7 +871,7 @@ packages:
description: description:
path: "." path: "."
ref: master ref: master
resolved-ref: "66ef334ac2cf4d5cb30835b30094a51802fae2ba" resolved-ref: b848fdda3c48c78594a804bb609e1077bb42125d
url: "https://github.com/linagora/jmap-dart-client.git" url: "https://github.com/linagora/jmap-dart-client.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
@@ -1256,14 +1256,14 @@ packages:
name: shared_preferences_linux name: shared_preferences_linux
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
shared_preferences_macos: shared_preferences_macos:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_macos name: shared_preferences_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.4" version: "2.0.5"
shared_preferences_platform_interface: shared_preferences_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -1284,7 +1284,7 @@ packages:
name: shared_preferences_windows name: shared_preferences_windows
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
shelf: shelf:
dependency: transitive dependency: transitive
description: description:
@@ -1380,14 +1380,14 @@ packages:
name: super_tag_editor name: super_tag_editor
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.0.3+3" version: "0.0.3+4"
syncfusion_flutter_core: syncfusion_flutter_core:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_flutter_core name: syncfusion_flutter_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "20.3.60" version: "20.4.43"
syncfusion_flutter_datepicker: syncfusion_flutter_datepicker:
dependency: transitive dependency: transitive
description: description:
@@ -1436,7 +1436,7 @@ packages:
name: timezone name: timezone
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.9.0" version: "0.9.1"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@@ -1611,7 +1611,7 @@ packages:
name: xdg_directories name: xdg_directories
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.0+2" version: "0.2.0+3"
xml: xml:
dependency: "direct dev" dependency: "direct dev"
description: description:
+1 -1
View File
@@ -99,7 +99,7 @@ dependencies:
filesize: 2.0.1 filesize: 2.0.1
# super_tag_editor # super_tag_editor
super_tag_editor: 0.0.3+3 super_tag_editor: 0.0.3+4
# uuid # uuid
uuid: 3.0.4 uuid: 3.0.4