TF-2717 Write widgets test for RecipientComposerWidget
This commit is contained in:
@@ -49,7 +49,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
? controller.insertImage(context, constraints.maxWidth)
|
? controller.insertImage(context, constraints.maxWidth)
|
||||||
: null,
|
: null,
|
||||||
backgroundColor: MobileAppBarComposerWidgetStyle.backgroundColor,
|
backgroundColor: MobileAppBarComposerWidgetStyle.backgroundColor,
|
||||||
childBuilder: (context) => SafeArea(
|
childBuilder: (context, constraints) => SafeArea(
|
||||||
left: !controller.responsiveUtils.isLandscapeMobile(context),
|
left: !controller.responsiveUtils.isLandscapeMobile(context),
|
||||||
right: !controller.responsiveUtils.isLandscapeMobile(context),
|
right: !controller.responsiveUtils.isLandscapeMobile(context),
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -110,6 +110,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
Obx(() => RecipientComposerWidget(
|
Obx(() => RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.to,
|
prefix: PrefixEmailAddress.to,
|
||||||
listEmailAddress: controller.listToEmailAddress,
|
listEmailAddress: controller.listToEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
fromState: controller.fromRecipientState.value,
|
fromState: controller.fromRecipientState.value,
|
||||||
ccState: controller.ccRecipientState.value,
|
ccState: controller.ccRecipientState.value,
|
||||||
bccState: controller.bccRecipientState.value,
|
bccState: controller.bccRecipientState.value,
|
||||||
@@ -134,6 +136,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
return RecipientComposerWidget(
|
return RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.cc,
|
prefix: PrefixEmailAddress.cc,
|
||||||
listEmailAddress: controller.listCcEmailAddress,
|
listEmailAddress: controller.listCcEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.ccAddressExpandMode.value,
|
expandMode: controller.ccAddressExpandMode.value,
|
||||||
controller: controller.ccEmailAddressController,
|
controller: controller.ccEmailAddressController,
|
||||||
focusNode: controller.ccAddressFocusNode,
|
focusNode: controller.ccAddressFocusNode,
|
||||||
@@ -158,6 +162,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
return RecipientComposerWidget(
|
return RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.bcc,
|
prefix: PrefixEmailAddress.bcc,
|
||||||
listEmailAddress: controller.listBccEmailAddress,
|
listEmailAddress: controller.listBccEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.bccAddressExpandMode.value,
|
expandMode: controller.bccAddressExpandMode.value,
|
||||||
controller: controller.bccEmailAddressController,
|
controller: controller.bccEmailAddressController,
|
||||||
focusNode: controller.bccAddressFocusNode,
|
focusNode: controller.bccAddressFocusNode,
|
||||||
@@ -264,6 +270,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.to,
|
prefix: PrefixEmailAddress.to,
|
||||||
listEmailAddress: controller.listToEmailAddress,
|
listEmailAddress: controller.listToEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
fromState: controller.fromRecipientState.value,
|
fromState: controller.fromRecipientState.value,
|
||||||
ccState: controller.ccRecipientState.value,
|
ccState: controller.ccRecipientState.value,
|
||||||
bccState: controller.bccRecipientState.value,
|
bccState: controller.bccRecipientState.value,
|
||||||
@@ -287,6 +295,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.cc,
|
prefix: PrefixEmailAddress.cc,
|
||||||
listEmailAddress: controller.listCcEmailAddress,
|
listEmailAddress: controller.listCcEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.ccAddressExpandMode.value,
|
expandMode: controller.ccAddressExpandMode.value,
|
||||||
controller: controller.ccEmailAddressController,
|
controller: controller.ccEmailAddressController,
|
||||||
focusNode: controller.ccAddressFocusNode,
|
focusNode: controller.ccAddressFocusNode,
|
||||||
@@ -306,6 +316,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.bcc,
|
prefix: PrefixEmailAddress.bcc,
|
||||||
listEmailAddress: controller.listBccEmailAddress,
|
listEmailAddress: controller.listBccEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.bccAddressExpandMode.value,
|
expandMode: controller.bccAddressExpandMode.value,
|
||||||
controller: controller.bccEmailAddressController,
|
controller: controller.bccEmailAddressController,
|
||||||
focusNode: controller.bccAddressFocusNode,
|
focusNode: controller.bccAddressFocusNode,
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.to,
|
prefix: PrefixEmailAddress.to,
|
||||||
listEmailAddress: controller.listToEmailAddress,
|
listEmailAddress: controller.listToEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
fromState: controller.fromRecipientState.value,
|
fromState: controller.fromRecipientState.value,
|
||||||
ccState: controller.ccRecipientState.value,
|
ccState: controller.ccRecipientState.value,
|
||||||
bccState: controller.bccRecipientState.value,
|
bccState: controller.bccRecipientState.value,
|
||||||
@@ -110,6 +112,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.cc,
|
prefix: PrefixEmailAddress.cc,
|
||||||
listEmailAddress: controller.listCcEmailAddress,
|
listEmailAddress: controller.listCcEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.ccAddressExpandMode.value,
|
expandMode: controller.ccAddressExpandMode.value,
|
||||||
controller: controller.ccEmailAddressController,
|
controller: controller.ccEmailAddressController,
|
||||||
focusNode: controller.ccAddressFocusNode,
|
focusNode: controller.ccAddressFocusNode,
|
||||||
@@ -130,6 +134,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.bcc,
|
prefix: PrefixEmailAddress.bcc,
|
||||||
listEmailAddress: controller.listBccEmailAddress,
|
listEmailAddress: controller.listBccEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.bccAddressExpandMode.value,
|
expandMode: controller.bccAddressExpandMode.value,
|
||||||
controller: controller.bccEmailAddressController,
|
controller: controller.bccEmailAddressController,
|
||||||
focusNode: controller.bccAddressFocusNode,
|
focusNode: controller.bccAddressFocusNode,
|
||||||
@@ -305,6 +311,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.to,
|
prefix: PrefixEmailAddress.to,
|
||||||
listEmailAddress: controller.listToEmailAddress,
|
listEmailAddress: controller.listToEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
fromState: controller.fromRecipientState.value,
|
fromState: controller.fromRecipientState.value,
|
||||||
ccState: controller.ccRecipientState.value,
|
ccState: controller.ccRecipientState.value,
|
||||||
bccState: controller.bccRecipientState.value,
|
bccState: controller.bccRecipientState.value,
|
||||||
@@ -328,6 +336,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.cc,
|
prefix: PrefixEmailAddress.cc,
|
||||||
listEmailAddress: controller.listCcEmailAddress,
|
listEmailAddress: controller.listCcEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.ccAddressExpandMode.value,
|
expandMode: controller.ccAddressExpandMode.value,
|
||||||
controller: controller.ccEmailAddressController,
|
controller: controller.ccEmailAddressController,
|
||||||
focusNode: controller.ccAddressFocusNode,
|
focusNode: controller.ccAddressFocusNode,
|
||||||
@@ -348,6 +358,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.bcc,
|
prefix: PrefixEmailAddress.bcc,
|
||||||
listEmailAddress: controller.listBccEmailAddress,
|
listEmailAddress: controller.listBccEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.bccAddressExpandMode.value,
|
expandMode: controller.bccAddressExpandMode.value,
|
||||||
controller: controller.bccEmailAddressController,
|
controller: controller.bccEmailAddressController,
|
||||||
focusNode: controller.bccAddressFocusNode,
|
focusNode: controller.bccAddressFocusNode,
|
||||||
@@ -562,6 +574,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.to,
|
prefix: PrefixEmailAddress.to,
|
||||||
listEmailAddress: controller.listToEmailAddress,
|
listEmailAddress: controller.listToEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
fromState: controller.fromRecipientState.value,
|
fromState: controller.fromRecipientState.value,
|
||||||
ccState: controller.ccRecipientState.value,
|
ccState: controller.ccRecipientState.value,
|
||||||
bccState: controller.bccRecipientState.value,
|
bccState: controller.bccRecipientState.value,
|
||||||
@@ -585,6 +599,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.cc,
|
prefix: PrefixEmailAddress.cc,
|
||||||
listEmailAddress: controller.listCcEmailAddress,
|
listEmailAddress: controller.listCcEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.ccAddressExpandMode.value,
|
expandMode: controller.ccAddressExpandMode.value,
|
||||||
controller: controller.ccEmailAddressController,
|
controller: controller.ccEmailAddressController,
|
||||||
focusNode: controller.ccAddressFocusNode,
|
focusNode: controller.ccAddressFocusNode,
|
||||||
@@ -605,6 +621,8 @@ class ComposerView extends GetWidget<ComposerController> {
|
|||||||
RecipientComposerWidget(
|
RecipientComposerWidget(
|
||||||
prefix: PrefixEmailAddress.bcc,
|
prefix: PrefixEmailAddress.bcc,
|
||||||
listEmailAddress: controller.listBccEmailAddress,
|
listEmailAddress: controller.listBccEmailAddress,
|
||||||
|
imagePaths: controller.imagePaths,
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
expandMode: controller.bccAddressExpandMode.value,
|
expandMode: controller.bccAddressExpandMode.value,
|
||||||
controller: controller.bccEmailAddressController,
|
controller: controller.bccEmailAddressController,
|
||||||
focusNode: controller.bccAddressFocusNode,
|
focusNode: controller.bccAddressFocusNode,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ typedef OnInsertImageAction = Function(BoxConstraints constraints);
|
|||||||
|
|
||||||
class MobileContainerView extends StatelessWidget {
|
class MobileContainerView extends StatelessWidget {
|
||||||
|
|
||||||
final Widget Function(BuildContext context) childBuilder;
|
final Widget Function(BuildContext context, BoxConstraints constraints) childBuilder;
|
||||||
final rich_composer.RichTextController keyboardRichTextController;
|
final rich_composer.RichTextController keyboardRichTextController;
|
||||||
final VoidCallback onCloseViewAction;
|
final VoidCallback onCloseViewAction;
|
||||||
final VoidCallback? onAttachFileAction;
|
final VoidCallback? onAttachFileAction;
|
||||||
@@ -69,7 +69,7 @@ class MobileContainerView extends StatelessWidget {
|
|||||||
paddingChild: isKeyboardVisible
|
paddingChild: isKeyboardVisible
|
||||||
? MobileContainerViewStyle.keyboardToolbarPadding
|
? MobileContainerViewStyle.keyboardToolbarPadding
|
||||||
: EdgeInsets.zero,
|
: EdgeInsets.zero,
|
||||||
child: childBuilder(context),
|
child: childBuilder(context, constraints),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import 'package:core/utils/app_logger.dart';
|
|||||||
import 'package:core/utils/platform_info.dart';
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
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/email/prefix_email_address.dart';
|
import 'package:model/email/prefix_email_address.dart';
|
||||||
import 'package:model/extensions/email_address_extension.dart';
|
import 'package:model/extensions/email_address_extension.dart';
|
||||||
@@ -41,6 +40,8 @@ class RecipientComposerWidget extends StatefulWidget {
|
|||||||
|
|
||||||
final PrefixEmailAddress prefix;
|
final PrefixEmailAddress prefix;
|
||||||
final List<EmailAddress> listEmailAddress;
|
final List<EmailAddress> listEmailAddress;
|
||||||
|
final ImagePaths imagePaths;
|
||||||
|
final double maxWidth;
|
||||||
final ExpandMode expandMode;
|
final ExpandMode expandMode;
|
||||||
final PrefixRecipientState fromState;
|
final PrefixRecipientState fromState;
|
||||||
final PrefixRecipientState ccState;
|
final PrefixRecipientState ccState;
|
||||||
@@ -66,6 +67,8 @@ class RecipientComposerWidget extends StatefulWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.prefix,
|
required this.prefix,
|
||||||
required this.listEmailAddress,
|
required this.listEmailAddress,
|
||||||
|
required this.imagePaths,
|
||||||
|
required this.maxWidth,
|
||||||
this.ccState = PrefixRecipientState.disabled,
|
this.ccState = PrefixRecipientState.disabled,
|
||||||
this.bccState = PrefixRecipientState.disabled,
|
this.bccState = PrefixRecipientState.disabled,
|
||||||
this.fromState = PrefixRecipientState.disabled,
|
this.fromState = PrefixRecipientState.disabled,
|
||||||
@@ -99,8 +102,6 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
bool _isDragging = false;
|
bool _isDragging = false;
|
||||||
late List<EmailAddress> _currentListEmailAddress;
|
late List<EmailAddress> _currentListEmailAddress;
|
||||||
|
|
||||||
final _imagePaths = Get.find<ImagePaths>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -117,7 +118,6 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
@@ -136,6 +136,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
padding: RecipientComposerWidgetStyle.labelMargin,
|
padding: RecipientComposerWidgetStyle.labelMargin,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${widget.prefix.asName(context)}:',
|
'${widget.prefix.asName(context)}:',
|
||||||
|
key: Key('prefix_${widget.prefix.name}_recipient_composer_widget'),
|
||||||
style: RecipientComposerWidgetStyle.labelTextStyle
|
style: RecipientComposerWidgetStyle.labelTextStyle
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -178,7 +179,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor,
|
suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor,
|
||||||
suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius,
|
suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius,
|
||||||
suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight,
|
suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight,
|
||||||
suggestionBoxWidth: _getSuggestionBoxWidth(constraints.maxWidth),
|
suggestionBoxWidth: _getSuggestionBoxWidth(widget.maxWidth),
|
||||||
textStyle: RecipientComposerWidgetStyle.inputTextStyle,
|
textStyle: RecipientComposerWidgetStyle.inputTextStyle,
|
||||||
onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter),
|
onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter),
|
||||||
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
|
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
|
||||||
@@ -191,6 +192,8 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
|
final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
|
||||||
|
|
||||||
return RecipientTagItemWidget(
|
return RecipientTagItemWidget(
|
||||||
|
index: index,
|
||||||
|
imagePaths: widget.imagePaths,
|
||||||
prefix: widget.prefix,
|
prefix: widget.prefix,
|
||||||
currentEmailAddress: currentEmailAddress,
|
currentEmailAddress: currentEmailAddress,
|
||||||
currentListEmailAddress: _currentListEmailAddress,
|
currentListEmailAddress: _currentListEmailAddress,
|
||||||
@@ -198,7 +201,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
isLatestEmail: isLatestEmail,
|
isLatestEmail: isLatestEmail,
|
||||||
isCollapsed: _isCollapse,
|
isCollapsed: _isCollapse,
|
||||||
isLatestTagFocused: _lastTagFocused,
|
isLatestTagFocused: _lastTagFocused,
|
||||||
maxWidth: constraints.maxWidth,
|
maxWidth: widget.maxWidth,
|
||||||
onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter),
|
onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter),
|
||||||
onShowFullAction: widget.onShowFullListEmailAddressAction,
|
onShowFullAction: widget.onShowFullListEmailAddressAction,
|
||||||
);
|
);
|
||||||
@@ -208,6 +211,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
useDefaultHighlight: false,
|
useDefaultHighlight: false,
|
||||||
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
|
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
|
||||||
return RecipientSuggestionItemWidget(
|
return RecipientSuggestionItemWidget(
|
||||||
|
imagePaths: widget.imagePaths,
|
||||||
suggestionState: suggestionEmailAddress.state,
|
suggestionState: suggestionEmailAddress.state,
|
||||||
emailAddress: suggestionEmailAddress.emailAddress,
|
emailAddress: suggestionEmailAddress.emailAddress,
|
||||||
suggestionValid: suggestionValid,
|
suggestionValid: suggestionValid,
|
||||||
@@ -252,7 +256,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor,
|
suggestionsBoxBackgroundColor: RecipientComposerWidgetStyle.suggestionsBoxBackgroundColor,
|
||||||
suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius,
|
suggestionsBoxRadius: RecipientComposerWidgetStyle.suggestionsBoxRadius,
|
||||||
suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight,
|
suggestionsBoxMaxHeight: RecipientComposerWidgetStyle.suggestionsBoxMaxHeight,
|
||||||
suggestionBoxWidth: _getSuggestionBoxWidth(constraints.maxWidth),
|
suggestionBoxWidth: _getSuggestionBoxWidth(widget.maxWidth),
|
||||||
textStyle: RecipientComposerWidgetStyle.inputTextStyle,
|
textStyle: RecipientComposerWidgetStyle.inputTextStyle,
|
||||||
onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter),
|
onFocusTagAction: (focused) => _handleFocusTagAction.call(focused, stateSetter),
|
||||||
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
|
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
|
||||||
@@ -265,6 +269,8 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
|
final isLatestEmail = currentEmailAddress == _currentListEmailAddress.last;
|
||||||
|
|
||||||
return RecipientTagItemWidget(
|
return RecipientTagItemWidget(
|
||||||
|
index: index,
|
||||||
|
imagePaths: widget.imagePaths,
|
||||||
prefix: widget.prefix,
|
prefix: widget.prefix,
|
||||||
currentEmailAddress: currentEmailAddress,
|
currentEmailAddress: currentEmailAddress,
|
||||||
currentListEmailAddress: _currentListEmailAddress,
|
currentListEmailAddress: _currentListEmailAddress,
|
||||||
@@ -272,7 +278,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
isLatestEmail: isLatestEmail,
|
isLatestEmail: isLatestEmail,
|
||||||
isCollapsed: _isCollapse,
|
isCollapsed: _isCollapse,
|
||||||
isLatestTagFocused: _lastTagFocused,
|
isLatestTagFocused: _lastTagFocused,
|
||||||
maxWidth: constraints.maxWidth,
|
maxWidth: widget.maxWidth,
|
||||||
onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter),
|
onDeleteTagAction: (emailAddress) => _handleDeleteTagAction.call(emailAddress, stateSetter),
|
||||||
onShowFullAction: widget.onShowFullListEmailAddressAction,
|
onShowFullAction: widget.onShowFullListEmailAddressAction,
|
||||||
);
|
);
|
||||||
@@ -282,6 +288,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
useDefaultHighlight: false,
|
useDefaultHighlight: false,
|
||||||
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
|
suggestionBuilder: (context, tagEditorState, suggestionEmailAddress, index, length, highlight, suggestionValid) {
|
||||||
return RecipientSuggestionItemWidget(
|
return RecipientSuggestionItemWidget(
|
||||||
|
imagePaths: widget.imagePaths,
|
||||||
suggestionState: suggestionEmailAddress.state,
|
suggestionState: suggestionEmailAddress.state,
|
||||||
emailAddress: suggestionEmailAddress.emailAddress,
|
emailAddress: suggestionEmailAddress.emailAddress,
|
||||||
suggestionValid: suggestionValid,
|
suggestionValid: suggestionValid,
|
||||||
@@ -337,8 +344,8 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
...[
|
...[
|
||||||
TMailButtonWidget.fromIcon(
|
TMailButtonWidget.fromIcon(
|
||||||
icon: _isAllRecipientInputEnabled
|
icon: _isAllRecipientInputEnabled
|
||||||
? _imagePaths.icChevronUp
|
? widget.imagePaths.icChevronUp
|
||||||
: _imagePaths.icChevronDownOutline,
|
: widget.imagePaths.icChevronDownOutline,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
iconSize: 24,
|
iconSize: 24,
|
||||||
padding: const EdgeInsets.all(5),
|
padding: const EdgeInsets.all(5),
|
||||||
@@ -349,7 +356,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
]
|
]
|
||||||
else if (PlatformInfo.isWeb)
|
else if (PlatformInfo.isWeb)
|
||||||
TMailButtonWidget.fromIcon(
|
TMailButtonWidget.fromIcon(
|
||||||
icon: _imagePaths.icClose,
|
icon: widget.imagePaths.icClose,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
iconColor: RecipientComposerWidgetStyle.deleteRecipientFieldIconColor,
|
iconColor: RecipientComposerWidgetStyle.deleteRecipientFieldIconColor,
|
||||||
iconSize: RecipientComposerWidgetStyle.deleteRecipientFieldIconSize,
|
iconSize: RecipientComposerWidgetStyle.deleteRecipientFieldIconSize,
|
||||||
@@ -360,7 +367,6 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _isCollapse => _currentListEmailAddress.length > 1 && widget.expandMode == ExpandMode.COLLAPSE;
|
bool get _isCollapse => _currentListEmailAddress.length > 1 && widget.expandMode == ExpandMode.COLLAPSE;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:core/presentation/extensions/color_extension.dart';
|
|||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
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/extensions/email_address_extension.dart';
|
import 'package:model/extensions/email_address_extension.dart';
|
||||||
import 'package:super_tag_editor/widgets/rich_text_widget.dart';
|
import 'package:super_tag_editor/widgets/rich_text_widget.dart';
|
||||||
@@ -17,16 +16,16 @@ class RecipientSuggestionItemWidget extends StatelessWidget {
|
|||||||
|
|
||||||
final SuggestionEmailState suggestionState;
|
final SuggestionEmailState suggestionState;
|
||||||
final EmailAddress emailAddress;
|
final EmailAddress emailAddress;
|
||||||
|
final ImagePaths imagePaths;
|
||||||
final String? suggestionValid;
|
final String? suggestionValid;
|
||||||
final bool highlight;
|
final bool highlight;
|
||||||
final OnSelectedRecipientSuggestionAction? onSelectedAction;
|
final OnSelectedRecipientSuggestionAction? onSelectedAction;
|
||||||
|
|
||||||
final _imagePaths = Get.find<ImagePaths>();
|
const RecipientSuggestionItemWidget({
|
||||||
|
|
||||||
RecipientSuggestionItemWidget({
|
|
||||||
super.key,
|
super.key,
|
||||||
required this.suggestionState,
|
required this.suggestionState,
|
||||||
required this.emailAddress,
|
required this.emailAddress,
|
||||||
|
required this.imagePaths,
|
||||||
this.suggestionValid,
|
this.suggestionValid,
|
||||||
this.highlight = false,
|
this.highlight = false,
|
||||||
this.onSelectedAction,
|
this.onSelectedAction,
|
||||||
@@ -61,7 +60,7 @@ class RecipientSuggestionItemWidget extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
trailing: SvgPicture.asset(
|
trailing: SvgPicture.asset(
|
||||||
_imagePaths.icFilterSelected,
|
imagePaths.icFilterSelected,
|
||||||
width: RecipientSuggestionItemWidgetStyle.selectedIconSize,
|
width: RecipientSuggestionItemWidgetStyle.selectedIconSize,
|
||||||
height: RecipientSuggestionItemWidgetStyle.selectedIconSize,
|
height: RecipientSuggestionItemWidgetStyle.selectedIconSize,
|
||||||
fit: BoxFit.fill
|
fit: BoxFit.fill
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:core/utils/direction_utils.dart';
|
|||||||
import 'package:core/utils/platform_info.dart';
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
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/email/prefix_email_address.dart';
|
import 'package:model/email/prefix_email_address.dart';
|
||||||
import 'package:model/extensions/email_address_extension.dart';
|
import 'package:model/extensions/email_address_extension.dart';
|
||||||
@@ -23,7 +22,9 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
final bool isCollapsed;
|
final bool isCollapsed;
|
||||||
final bool isLatestTagFocused;
|
final bool isLatestTagFocused;
|
||||||
final bool isLatestEmail;
|
final bool isLatestEmail;
|
||||||
|
final ImagePaths imagePaths;
|
||||||
final double? maxWidth;
|
final double? maxWidth;
|
||||||
|
final int index;
|
||||||
final PrefixEmailAddress prefix;
|
final PrefixEmailAddress prefix;
|
||||||
final EmailAddress currentEmailAddress;
|
final EmailAddress currentEmailAddress;
|
||||||
final List<EmailAddress> currentListEmailAddress;
|
final List<EmailAddress> currentListEmailAddress;
|
||||||
@@ -31,14 +32,14 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
final OnShowFullListEmailAddressAction? onShowFullAction;
|
final OnShowFullListEmailAddressAction? onShowFullAction;
|
||||||
final OnDeleteTagAction? onDeleteTagAction;
|
final OnDeleteTagAction? onDeleteTagAction;
|
||||||
|
|
||||||
final _imagePaths = Get.find<ImagePaths>();
|
const RecipientTagItemWidget({
|
||||||
|
|
||||||
RecipientTagItemWidget({
|
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.index,
|
||||||
required this.prefix,
|
required this.prefix,
|
||||||
required this.currentEmailAddress,
|
required this.currentEmailAddress,
|
||||||
required this.currentListEmailAddress,
|
required this.currentListEmailAddress,
|
||||||
required this.collapsedListEmailAddress,
|
required this.collapsedListEmailAddress,
|
||||||
|
required this.imagePaths,
|
||||||
this.isCollapsed = false,
|
this.isCollapsed = false,
|
||||||
this.isLatestTagFocused = false,
|
this.isLatestTagFocused = false,
|
||||||
this.isLatestEmail = false,
|
this.isLatestEmail = false,
|
||||||
@@ -50,6 +51,7 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
key: Key('recipient_tag_item_${prefix.name}_$index'),
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -77,12 +79,17 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
label: Text(
|
label: Text(
|
||||||
|
key: Key('label_recipient_tag_item_${prefix.name}_$index'),
|
||||||
currentEmailAddress.asString(),
|
currentEmailAddress.asString(),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
),
|
),
|
||||||
deleteIcon: SvgPicture.asset(_imagePaths.icClose, fit: BoxFit.fill),
|
deleteIcon: SvgPicture.asset(
|
||||||
|
imagePaths.icClose,
|
||||||
|
key: Key('delete_icon_recipient_tag_item_${prefix.name}_$index'),
|
||||||
|
fit: BoxFit.fill
|
||||||
|
),
|
||||||
labelStyle: RecipientTagItemWidgetStyle.labelTextStyle,
|
labelStyle: RecipientTagItemWidgetStyle.labelTextStyle,
|
||||||
backgroundColor: _getTagBackgroundColor(),
|
backgroundColor: _getTagBackgroundColor(),
|
||||||
side: _getTagBorderSide(),
|
side: _getTagBorderSide(),
|
||||||
@@ -91,6 +98,7 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
avatar: currentEmailAddress.displayName.isNotEmpty
|
avatar: currentEmailAddress.displayName.isNotEmpty
|
||||||
? GradientCircleAvatarIcon(
|
? GradientCircleAvatarIcon(
|
||||||
|
key: Key('avatar_icon_recipient_tag_item_${prefix.name}_$index'),
|
||||||
colors: currentEmailAddress.avatarColors,
|
colors: currentEmailAddress.avatarColors,
|
||||||
label: currentEmailAddress.displayName.firstLetterToUpperCase,
|
label: currentEmailAddress.displayName.firstLetterToUpperCase,
|
||||||
labelFontSize: RecipientTagItemWidgetStyle.avatarLabelFontSize,
|
labelFontSize: RecipientTagItemWidgetStyle.avatarLabelFontSize,
|
||||||
@@ -116,13 +124,18 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
vertical: DirectionUtils.isDirectionRTLByHasAnyRtl(currentEmailAddress.asString()) ? 0 : 2
|
vertical: DirectionUtils.isDirectionRTLByHasAnyRtl(currentEmailAddress.asString()) ? 0 : 2
|
||||||
),
|
),
|
||||||
label: Text(
|
label: Text(
|
||||||
|
key: Key('label_recipient_tag_item_${prefix.name}_$index'),
|
||||||
currentEmailAddress.asString(),
|
currentEmailAddress.asString(),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
deleteIcon: SvgPicture.asset(_imagePaths.icClose, fit: BoxFit.fill),
|
deleteIcon: SvgPicture.asset(
|
||||||
|
imagePaths.icClose,
|
||||||
|
key: Key('delete_icon_recipient_tag_item_${prefix.name}_$index'),
|
||||||
|
fit: BoxFit.fill
|
||||||
|
),
|
||||||
labelStyle: RecipientTagItemWidgetStyle.labelTextStyle,
|
labelStyle: RecipientTagItemWidgetStyle.labelTextStyle,
|
||||||
backgroundColor: _getTagBackgroundColor(),
|
backgroundColor: _getTagBackgroundColor(),
|
||||||
side: _getTagBorderSide(),
|
side: _getTagBorderSide(),
|
||||||
@@ -131,6 +144,7 @@ class RecipientTagItemWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
avatar: currentEmailAddress.displayName.isNotEmpty
|
avatar: currentEmailAddress.displayName.isNotEmpty
|
||||||
? GradientCircleAvatarIcon(
|
? GradientCircleAvatarIcon(
|
||||||
|
key: Key('avatar_icon_recipient_tag_item_${prefix.name}_$index'),
|
||||||
colors: currentEmailAddress.avatarColors,
|
colors: currentEmailAddress.avatarColors,
|
||||||
label: currentEmailAddress.displayName.firstLetterToUpperCase,
|
label: currentEmailAddress.displayName.firstLetterToUpperCase,
|
||||||
labelFontSize: RecipientTagItemWidgetStyle.avatarLabelFontSize,
|
labelFontSize: RecipientTagItemWidgetStyle.avatarLabelFontSize,
|
||||||
|
|||||||
@@ -0,0 +1,184 @@
|
|||||||
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
|
import 'package:model/email/prefix_email_address.dart';
|
||||||
|
import 'package:super_tag_editor/tag_editor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/recipient_composer_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/recipient_tag_item_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations_delegate.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/localization_service.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('recipient_composer_widget test', () {
|
||||||
|
final imagePaths = ImagePaths();
|
||||||
|
final keyEmailTagEditor = GlobalKey<TagsEditorState>();
|
||||||
|
const prefix = PrefixEmailAddress.to;
|
||||||
|
|
||||||
|
Widget makeTestableWidget({required Widget child}) {
|
||||||
|
return GetMaterialApp(
|
||||||
|
localizationsDelegates: const [
|
||||||
|
AppLocalizationsDelegate(),
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
],
|
||||||
|
supportedLocales: LocalizationService.supportedLocales,
|
||||||
|
home: Scaffold(body: child),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
testWidgets('RecipientComposerWidget renders correctly', (tester) async {
|
||||||
|
final listEmailAddress = <EmailAddress>[];
|
||||||
|
|
||||||
|
final widget = makeTestableWidget(
|
||||||
|
child: RecipientComposerWidget(
|
||||||
|
prefix: prefix,
|
||||||
|
listEmailAddress: listEmailAddress,
|
||||||
|
imagePaths: imagePaths,
|
||||||
|
maxWidth: 360,
|
||||||
|
keyTagEditor: keyEmailTagEditor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpWidget(widget);
|
||||||
|
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final recipientComposerWidgetFinder = find.byType(RecipientComposerWidget);
|
||||||
|
|
||||||
|
expect(recipientComposerWidgetFinder, findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('RecipientComposerWidget renders list email address correctly', (tester) async {
|
||||||
|
final listEmailAddress = <EmailAddress>[
|
||||||
|
EmailAddress(null, 'test1@example.com'),
|
||||||
|
EmailAddress(null, 'test2@example.com'),
|
||||||
|
];
|
||||||
|
|
||||||
|
final widget = makeTestableWidget(
|
||||||
|
child: RecipientComposerWidget(
|
||||||
|
prefix: prefix,
|
||||||
|
listEmailAddress: listEmailAddress,
|
||||||
|
imagePaths: imagePaths,
|
||||||
|
maxWidth: 360,
|
||||||
|
keyTagEditor: keyEmailTagEditor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpWidget(widget);
|
||||||
|
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.byType(RecipientTagItemWidget), findsNWidgets(2));
|
||||||
|
expect(find.text('test1@example.com'), findsOneWidget);
|
||||||
|
expect(find.text('test2@example.com'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('RecipientTagItemWidget should have a `maxWidth` equal to the RecipientComposerWidget\'s `maxWidth`', (tester) async {
|
||||||
|
final listEmailAddress = <EmailAddress>[
|
||||||
|
EmailAddress('test1', 'test1@example.com'),
|
||||||
|
];
|
||||||
|
|
||||||
|
final widget = makeTestableWidget(
|
||||||
|
child: RecipientComposerWidget(
|
||||||
|
prefix: prefix,
|
||||||
|
listEmailAddress: listEmailAddress,
|
||||||
|
imagePaths: imagePaths,
|
||||||
|
maxWidth: 360,
|
||||||
|
keyTagEditor: keyEmailTagEditor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpWidget(widget);
|
||||||
|
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final recipientTagItemWidgetFinder = find.byKey(Key('recipient_tag_item_${prefix.name}_0'));
|
||||||
|
|
||||||
|
final Container recipientTagItemWidget = tester.widget(recipientTagItemWidgetFinder);
|
||||||
|
|
||||||
|
expect(recipientTagItemWidgetFinder, findsOneWidget);
|
||||||
|
expect(recipientTagItemWidget.constraints!.maxWidth, 360);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('RecipientTagItemWidget should have all the components (AvatarIcon, Label, DeleteIcon)', (tester) async {
|
||||||
|
final listEmailAddress = <EmailAddress>[
|
||||||
|
EmailAddress('test1', 'test1@example.com'),
|
||||||
|
];
|
||||||
|
|
||||||
|
final widget = makeTestableWidget(
|
||||||
|
child: RecipientComposerWidget(
|
||||||
|
prefix: prefix,
|
||||||
|
listEmailAddress: listEmailAddress,
|
||||||
|
imagePaths: imagePaths,
|
||||||
|
maxWidth: 360,
|
||||||
|
keyTagEditor: keyEmailTagEditor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpWidget(widget);
|
||||||
|
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final recipientTagItemWidgetFinder = find.byKey(Key('recipient_tag_item_${prefix.name}_0'));
|
||||||
|
final labelRecipientTagItemWidgetFinder = find.byKey(Key('label_recipient_tag_item_${prefix.name}_0'));
|
||||||
|
final deleteIconRecipientTagItemWidgetFinder = find.byKey(Key('delete_icon_recipient_tag_item_${prefix.name}_0'));
|
||||||
|
final avatarIconRecipientTagItemWidgetFinder = find.byKey(Key('avatar_icon_recipient_tag_item_${prefix.name}_0'));
|
||||||
|
|
||||||
|
final Size recipientTagItemWidgetSize = tester.getSize(recipientTagItemWidgetFinder);
|
||||||
|
final Size labelRecipientTagItemWidgetSize = tester.getSize(labelRecipientTagItemWidgetFinder);
|
||||||
|
final Size deleteIconRecipientTagItemWidgetSize = tester.getSize(deleteIconRecipientTagItemWidgetFinder);
|
||||||
|
final Size avatarIconRecipientTagItemWidgetSize = tester.getSize(avatarIconRecipientTagItemWidgetFinder);
|
||||||
|
|
||||||
|
log('recipient_composer_widget_test::main: TagSize = $recipientTagItemWidgetSize | LabelTagSize = $labelRecipientTagItemWidgetSize | DeleteIconTagSize = $deleteIconRecipientTagItemWidgetSize | AvatarIconTagSize = $avatarIconRecipientTagItemWidgetSize');
|
||||||
|
|
||||||
|
expect(labelRecipientTagItemWidgetFinder, findsOneWidget);
|
||||||
|
expect(deleteIconRecipientTagItemWidgetFinder, findsOneWidget);
|
||||||
|
expect(avatarIconRecipientTagItemWidgetFinder, findsOneWidget);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
labelRecipientTagItemWidgetSize.width + deleteIconRecipientTagItemWidgetSize.width + avatarIconRecipientTagItemWidgetSize.width,
|
||||||
|
lessThanOrEqualTo(recipientTagItemWidgetSize.width)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('RecipientComponentWidget should have all the components (PrefixLabel, RecipientTagItemWidget)', (tester) async {
|
||||||
|
final listEmailAddress = <EmailAddress>[
|
||||||
|
EmailAddress('test1', 'test1@example.com'),
|
||||||
|
];
|
||||||
|
|
||||||
|
final widget = makeTestableWidget(
|
||||||
|
child: RecipientComposerWidget(
|
||||||
|
prefix: prefix,
|
||||||
|
listEmailAddress: listEmailAddress,
|
||||||
|
imagePaths: imagePaths,
|
||||||
|
maxWidth: 360,
|
||||||
|
keyTagEditor: keyEmailTagEditor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.pumpWidget(widget);
|
||||||
|
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
final prefixRecipientComposerWidgetFinder = find.byKey(Key('prefix_${prefix.name}_recipient_composer_widget'));
|
||||||
|
final recipientTagItemWidgetFinder = find.byKey(Key('recipient_tag_item_${prefix.name}_0'));
|
||||||
|
|
||||||
|
final Size prefixRecipientComposerWidgetSize = tester.getSize(prefixRecipientComposerWidgetFinder);
|
||||||
|
final Size recipientTagItemWidgetSize = tester.getSize(prefixRecipientComposerWidgetFinder);
|
||||||
|
|
||||||
|
log('recipient_composer_widget_test::main: PrefixLabelSize = $prefixRecipientComposerWidgetSize | TagSize = $recipientTagItemWidgetSize');
|
||||||
|
|
||||||
|
expect(prefixRecipientComposerWidgetFinder, findsOneWidget);
|
||||||
|
expect(recipientTagItemWidgetFinder, findsOneWidget);
|
||||||
|
expect(
|
||||||
|
prefixRecipientComposerWidgetSize.width + recipientTagItemWidgetSize.width,
|
||||||
|
lessThanOrEqualTo(360)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user