TF-1296 Improve auto suggestion is still slow response

This commit is contained in:
dab246
2023-01-16 15:49:31 +07:00
committed by Dat H. Pham
parent cd04a1b8d0
commit d5b61a2a7d
3 changed files with 7 additions and 27 deletions
@@ -140,6 +140,7 @@ class EmailAddressInputBuilder {
autoDisposeFocusNode: autoDisposeFocusNode, autoDisposeFocusNode: autoDisposeFocusNode,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.done, textInputAction: TextInputAction.done,
debounceDuration: const Duration(milliseconds: 150),
hasAddButton: false, hasAddButton: false,
tagSpacing: 8, tagSpacing: 8,
autofocus: _prefixEmailAddress != PrefixEmailAddress.to && listEmailAddress.isEmpty, autofocus: _prefixEmailAddress != PrefixEmailAddress.to && listEmailAddress.isEmpty,
@@ -148,7 +149,7 @@ class EmailAddressInputBuilder {
suggestionsBoxElevation: _suggestionBoxRadius, suggestionsBoxElevation: _suggestionBoxRadius,
suggestionsBoxBackgroundColor: Colors.white, suggestionsBoxBackgroundColor: Colors.white,
suggestionsBoxRadius: 20, suggestionsBoxRadius: 20,
suggestionsBoxMaxHeight: 300, suggestionsBoxMaxHeight: 350,
textStyle: const TextStyle(color: AppColor.colorEmailAddress, fontSize: 14, fontWeight: FontWeight.w500), textStyle: const TextStyle(color: AppColor.colorEmailAddress, fontSize: 14, fontWeight: FontWeight.w500),
onFocusTagAction: (focused) { onFocusTagAction: (focused) {
setState(() { setState(() {
@@ -355,9 +356,7 @@ class EmailAddressInputBuilder {
String? suggestionValid String? suggestionValid
) { ) {
return Container( return Container(
decoration: BoxDecoration( color: highlight ? AppColor.colorItemSelected : Colors.white,
color: highlight ? AppColor.colorItemSelected : Colors.white,
borderRadius: _getBorderRadiusSuggestionItem(index, length)),
child: ListTile( child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16), contentPadding: const EdgeInsets.symmetric(horizontal: 16),
leading: Container( leading: Container(
@@ -400,26 +399,6 @@ class EmailAddressInputBuilder {
); );
} }
BorderRadius _getBorderRadiusSuggestionItem(int index, int length) {
var borderRadius = const BorderRadius.all(Radius.circular(0));
if (length <= 1) {
borderRadius = const BorderRadius.all(Radius.circular(20));
} else {
if (index == 0) {
borderRadius = const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
);
} else if (index == length - 1) {
borderRadius = const BorderRadius.only(
bottomRight: Radius.circular(20),
bottomLeft: Radius.circular(20),
);
}
}
return borderRadius;
}
FutureOr<List<SuggestionEmailAddress>> _findSuggestions(String query) async { FutureOr<List<SuggestionEmailAddress>> _findSuggestions(String query) async {
log('EmailAddressInputBuilder::_findSuggestions():query: $query'); log('EmailAddressInputBuilder::_findSuggestions():query: $query');
if (_gapBetweenTagChangedAndFindSuggestion?.isActive ?? false) { if (_gapBetweenTagChangedAndFindSuggestion?.isActive ?? false) {
@@ -86,6 +86,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
tagSpacing: BuildUtils.isWeb ? 12 : 8, tagSpacing: BuildUtils.isWeb ? 12 : 8,
autofocus: false, autofocus: false,
minTextFieldWidth: 20, minTextFieldWidth: 20,
debounceDuration: const Duration(milliseconds: 150),
resetTextOnSubmitted: true, resetTextOnSubmitted: true,
suggestionsBoxBackgroundColor: Colors.white, suggestionsBoxBackgroundColor: Colors.white,
suggestionsBoxRadius: 16, suggestionsBoxRadius: 16,
+3 -3
View File
@@ -871,7 +871,7 @@ packages:
description: description:
path: "." path: "."
ref: master ref: master
resolved-ref: "92982e13c9414c71e14451da83668b05c282fc2b" resolved-ref: "1df4203f3c7cb5f24ee68f3e1060efb7283dd3fd"
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"
@@ -1063,7 +1063,7 @@ packages:
name: path_provider_macos name: path_provider_macos
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.6" version: "2.0.7"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -1379,7 +1379,7 @@ packages:
description: description:
path: "." path: "."
ref: master ref: master
resolved-ref: e70771662668617eef860b7ffe52bd7e83b369f4 resolved-ref: e38dc4971cb123833cf81118a2a4b94e6b348d48
url: "https://github.com/dab246/super_tag_editor.git" url: "https://github.com/dab246/super_tag_editor.git"
source: git source: git
version: "0.0.3+4" version: "0.0.3+4"