TF-1153 Improve recipient input in composer
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
import 'package:model/model.dart';
|
import 'package:model/model.dart';
|
||||||
import 'package:super_tag_editor/tag_editor.dart';
|
import 'package:super_tag_editor/tag_editor.dart';
|
||||||
|
import 'package:super_tag_editor/widgets/rich_text_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/prefix_email_address_extension.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/extensions/prefix_email_address_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/suggestion_email_address.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/suggestion_email_address.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
@@ -231,13 +232,22 @@ class EmailAddressInputBuilder {
|
|||||||
},
|
},
|
||||||
findSuggestions: _findSuggestions,
|
findSuggestions: _findSuggestions,
|
||||||
useDefaultHighlight: false,
|
useDefaultHighlight: false,
|
||||||
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight) {
|
suggestionBuilder: (
|
||||||
|
context,
|
||||||
|
tagEditorState,
|
||||||
|
suggestionEmailAddress,
|
||||||
|
index,
|
||||||
|
length,
|
||||||
|
highlight,
|
||||||
|
suggestionValid
|
||||||
|
) {
|
||||||
switch (suggestionEmailAddress.state) {
|
switch (suggestionEmailAddress.state) {
|
||||||
case SuggestionEmailState.duplicated:
|
case SuggestionEmailState.duplicated:
|
||||||
return _buildExistedSuggestionItem(
|
return _buildExistedSuggestionItem(
|
||||||
setState,
|
setState,
|
||||||
context,
|
context,
|
||||||
suggestionEmailAddress,
|
suggestionEmailAddress,
|
||||||
|
suggestionValid
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return _buildSuggestionItem(
|
return _buildSuggestionItem(
|
||||||
@@ -247,7 +257,8 @@ class EmailAddressInputBuilder {
|
|||||||
suggestionEmailAddress,
|
suggestionEmailAddress,
|
||||||
index,
|
index,
|
||||||
length,
|
length,
|
||||||
highlight
|
highlight,
|
||||||
|
suggestionValid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -279,11 +290,11 @@ class EmailAddressInputBuilder {
|
|||||||
return listEmailAddress.length > 1 && expandMode == ExpandMode.COLLAPSE;
|
return listEmailAddress.length > 1 && expandMode == ExpandMode.COLLAPSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildExistedSuggestionItem(
|
Widget _buildExistedSuggestionItem(
|
||||||
StateSetter setState,
|
StateSetter setState,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
SuggestionEmailAddress suggestionEmailAddress,
|
SuggestionEmailAddress suggestionEmailAddress,
|
||||||
|
String? suggestionValid
|
||||||
) {
|
) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@@ -306,17 +317,23 @@ class EmailAddressInputBuilder {
|
|||||||
child: Text(
|
child: Text(
|
||||||
suggestionEmailAddress.emailAddress.asString().isNotEmpty ? suggestionEmailAddress.emailAddress.asString()[0].toUpperCase() : '',
|
suggestionEmailAddress.emailAddress.asString().isNotEmpty ? suggestionEmailAddress.emailAddress.asString()[0].toUpperCase() : '',
|
||||||
style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.w600))),
|
style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.w600))),
|
||||||
title: Text(
|
title: RichTextWidget(
|
||||||
suggestionEmailAddress.emailAddress.asString(),
|
textOrigin: suggestionEmailAddress.emailAddress.asString(),
|
||||||
maxLines: 1,
|
wordSearched: suggestionValid ?? '',
|
||||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
),
|
||||||
style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.normal)),
|
|
||||||
subtitle: suggestionEmailAddress.emailAddress.displayName.isNotEmpty && suggestionEmailAddress.emailAddress.emailAddress.isNotEmpty
|
subtitle: suggestionEmailAddress.emailAddress.displayName.isNotEmpty && suggestionEmailAddress.emailAddress.emailAddress.isNotEmpty
|
||||||
? Text(
|
? RichTextWidget(
|
||||||
suggestionEmailAddress.emailAddress.emailAddress,
|
textOrigin: suggestionEmailAddress.emailAddress.emailAddress,
|
||||||
maxLines: 1,
|
wordSearched: suggestionValid ?? '',
|
||||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
styleTextOrigin: const TextStyle(
|
||||||
style: const TextStyle(color: AppColor.colorHintSearchBar, fontSize: 13, fontWeight: FontWeight.normal))
|
color: AppColor.colorHintSearchBar,
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.normal),
|
||||||
|
styleWordSearched: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
trailing: SvgPicture.asset(_imagePaths.icFilterSelected,
|
trailing: SvgPicture.asset(_imagePaths.icFilterSelected,
|
||||||
width: 24,
|
width: 24,
|
||||||
@@ -334,7 +351,8 @@ class EmailAddressInputBuilder {
|
|||||||
SuggestionEmailAddress suggestionEmailAddress,
|
SuggestionEmailAddress suggestionEmailAddress,
|
||||||
int index,
|
int index,
|
||||||
int length,
|
int length,
|
||||||
bool highlight
|
bool highlight,
|
||||||
|
String? suggestionValid
|
||||||
) {
|
) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -353,18 +371,24 @@ class EmailAddressInputBuilder {
|
|||||||
child: Text(
|
child: Text(
|
||||||
suggestionEmailAddress.emailAddress.asString().isNotEmpty ? suggestionEmailAddress.emailAddress.asString()[0].toUpperCase() : '',
|
suggestionEmailAddress.emailAddress.asString().isNotEmpty ? suggestionEmailAddress.emailAddress.asString()[0].toUpperCase() : '',
|
||||||
style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.w600))),
|
style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.w600))),
|
||||||
title: Text(
|
title: RichTextWidget(
|
||||||
suggestionEmailAddress.emailAddress.asString(),
|
textOrigin: suggestionEmailAddress.emailAddress.asString(),
|
||||||
maxLines: 1,
|
wordSearched: suggestionValid ?? '',
|
||||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
),
|
||||||
style: const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.normal)),
|
|
||||||
subtitle: suggestionEmailAddress.emailAddress.displayName.isNotEmpty && suggestionEmailAddress.emailAddress.emailAddress.isNotEmpty
|
subtitle: suggestionEmailAddress.emailAddress.displayName.isNotEmpty && suggestionEmailAddress.emailAddress.emailAddress.isNotEmpty
|
||||||
? Text(
|
? RichTextWidget(
|
||||||
suggestionEmailAddress.emailAddress.emailAddress,
|
textOrigin: suggestionEmailAddress.emailAddress.emailAddress,
|
||||||
maxLines: 1,
|
wordSearched: suggestionValid ?? '',
|
||||||
overflow: kIsWeb ? null : TextOverflow.ellipsis,
|
styleTextOrigin: const TextStyle(
|
||||||
style: const TextStyle(color: AppColor.colorHintSearchBar, fontSize: 13, fontWeight: FontWeight.normal))
|
color: AppColor.colorHintSearchBar,
|
||||||
: null,
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.normal),
|
||||||
|
styleWordSearched: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
log('EmailAddressInputBuilder::_buildSuggestionItem(): onTap: $suggestionEmailAddress');
|
log('EmailAddressInputBuilder::_buildSuggestionItem(): onTap: $suggestionEmailAddress');
|
||||||
setState(() => listEmailAddress.add(suggestionEmailAddress.emailAddress));
|
setState(() => listEmailAddress.add(suggestionEmailAddress.emailAddress));
|
||||||
@@ -378,16 +402,20 @@ class EmailAddressInputBuilder {
|
|||||||
|
|
||||||
BorderRadius _getBorderRadiusSuggestionItem(int index, int length) {
|
BorderRadius _getBorderRadiusSuggestionItem(int index, int length) {
|
||||||
var borderRadius = const BorderRadius.all(Radius.circular(0));
|
var borderRadius = const BorderRadius.all(Radius.circular(0));
|
||||||
if (index == 0) {
|
if (length <= 1) {
|
||||||
borderRadius = const BorderRadius.only(
|
borderRadius = const BorderRadius.all(Radius.circular(20));
|
||||||
topLeft: Radius.circular(20),
|
} else {
|
||||||
topRight: Radius.circular(20),
|
if (index == 0) {
|
||||||
);
|
borderRadius = const BorderRadius.only(
|
||||||
} else if (index == length - 1) {
|
topLeft: Radius.circular(20),
|
||||||
borderRadius = const BorderRadius.only(
|
topRight: Radius.circular(20),
|
||||||
bottomRight: Radius.circular(20),
|
);
|
||||||
bottomLeft: Radius.circular(20),
|
} else if (index == length - 1) {
|
||||||
);
|
borderRadius = const BorderRadius.only(
|
||||||
|
bottomRight: Radius.circular(20),
|
||||||
|
bottomLeft: Radius.circular(20),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return borderRadius;
|
return borderRadius;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -143,7 +143,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
findSuggestions: _findSuggestions,
|
findSuggestions: _findSuggestions,
|
||||||
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight) {
|
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: ContactSuggestionBoxItem(
|
child: ContactSuggestionBoxItem(
|
||||||
|
|||||||
+3
-3
@@ -112,7 +112,7 @@ packages:
|
|||||||
name: built_value
|
name: built_value
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.4.2"
|
version: "8.4.3"
|
||||||
byte_converter:
|
byte_converter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1379,7 +1379,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: master
|
ref: master
|
||||||
resolved-ref: "34ffe7c8c5e8a967ae1cfde2a525c4f5738a0835"
|
resolved-ref: e70771662668617eef860b7ffe52bd7e83b369f4
|
||||||
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"
|
||||||
@@ -1564,7 +1564,7 @@ packages:
|
|||||||
name: web_socket_channel
|
name: web_socket_channel
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.3.0"
|
||||||
webview_flutter:
|
webview_flutter:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user