TF-985 Apply new design for EmailAddressWidget in EmailView
This commit is contained in:
@@ -68,7 +68,6 @@ class EmailController extends BaseController with AppLoaderMixin {
|
|||||||
final DownloadAttachmentForWebInteractor _downloadAttachmentForWebInteractor;
|
final DownloadAttachmentForWebInteractor _downloadAttachmentForWebInteractor;
|
||||||
|
|
||||||
final emailAddressExpandMode = ExpandMode.COLLAPSE.obs;
|
final emailAddressExpandMode = ExpandMode.COLLAPSE.obs;
|
||||||
final isDisplayFullEmailAddress = false.obs;
|
|
||||||
final attachmentsExpandMode = ExpandMode.COLLAPSE.obs;
|
final attachmentsExpandMode = ExpandMode.COLLAPSE.obs;
|
||||||
final emailContents = <EmailContent>[].obs;
|
final emailContents = <EmailContent>[].obs;
|
||||||
final attachments = <Attachment>[].obs;
|
final attachments = <Attachment>[].obs;
|
||||||
@@ -83,6 +82,8 @@ class EmailController extends BaseController with AppLoaderMixin {
|
|||||||
|
|
||||||
PresentationEmail? get currentEmail => mailboxDashBoardController.selectedEmail.value;
|
PresentationEmail? get currentEmail => mailboxDashBoardController.selectedEmail.value;
|
||||||
|
|
||||||
|
bool get isDisplayFullEmailAddress => emailAddressExpandMode.value == ExpandMode.EXPAND;
|
||||||
|
|
||||||
EmailController(
|
EmailController(
|
||||||
this._getEmailContentInteractor,
|
this._getEmailContentInteractor,
|
||||||
this._markAsEmailReadInteractor,
|
this._markAsEmailReadInteractor,
|
||||||
@@ -217,27 +218,11 @@ class EmailController extends BaseController with AppLoaderMixin {
|
|||||||
void _resetToOriginalValue() {
|
void _resetToOriginalValue() {
|
||||||
attachmentsExpandMode.value = ExpandMode.COLLAPSE;
|
attachmentsExpandMode.value = ExpandMode.COLLAPSE;
|
||||||
emailAddressExpandMode.value = ExpandMode.COLLAPSE;
|
emailAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||||
isDisplayFullEmailAddress.value = false;
|
|
||||||
emailContents.clear();
|
emailContents.clear();
|
||||||
initialEmailContents?.clear();
|
initialEmailContents?.clear();
|
||||||
attachments.clear();
|
attachments.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleDisplayEmailAddressAction({ExpandMode? expandMode}) {
|
|
||||||
if (expandMode != null) {
|
|
||||||
emailAddressExpandMode.value = expandMode;
|
|
||||||
} else {
|
|
||||||
final newExpandMode = emailAddressExpandMode.value == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND;
|
|
||||||
emailAddressExpandMode.value = newExpandMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emailAddressExpandMode.value == ExpandMode.COLLAPSE) {
|
|
||||||
isDisplayFullEmailAddress.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isExpandEmailAddress => emailAddressExpandMode.value == ExpandMode.EXPAND;
|
|
||||||
|
|
||||||
PresentationMailbox? getMailboxContain(PresentationEmail email) {
|
PresentationMailbox? getMailboxContain(PresentationEmail email) {
|
||||||
return mailboxDashBoardController.searchController.isSearchEmailRunning
|
return mailboxDashBoardController.searchController.isSearchEmailRunning
|
||||||
? email.findMailboxContain(mailboxDashBoardController.mapMailboxById)
|
? email.findMailboxContain(mailboxDashBoardController.mapMailboxById)
|
||||||
@@ -622,8 +607,12 @@ class EmailController extends BaseController with AppLoaderMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void showFullEmailAddress() {
|
void expandEmailAddress() {
|
||||||
isDisplayFullEmailAddress.value = true;
|
emailAddressExpandMode.value = ExpandMode.EXPAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
void collapseEmailAddress() {
|
||||||
|
emailAddressExpandMode.value = ExpandMode.COLLAPSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openEmailAddressDialog(BuildContext context, EmailAddress emailAddress) {
|
void openEmailAddressDialog(BuildContext context, EmailAddress emailAddress) {
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
|||||||
|
|
||||||
class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
||||||
|
|
||||||
|
static const double maxSizeFullDisplayEmailAddressArrowDownButton = 30.0;
|
||||||
|
|
||||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
final imagePaths = Get.find<ImagePaths>();
|
final imagePaths = Get.find<ImagePaths>();
|
||||||
|
|
||||||
static const int limitAddressDisplay = 1;
|
|
||||||
|
|
||||||
EmailView({Key? key}) : super(key: key);
|
EmailView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -54,31 +54,15 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
border: Border.all(color: AppColor.colorBorderBodyThread, width: 1),
|
border: Border.all(color: AppColor.colorBorderBodyThread, width: 1),
|
||||||
color: Colors.white)
|
color: Colors.white)
|
||||||
: null,
|
: const BoxDecoration(color: Colors.white),
|
||||||
margin: responsiveUtils.isWebDesktop(context)
|
margin: _getMarginEmailView(context),
|
||||||
? const EdgeInsets.only(right: 16, top: 16, bottom: 16)
|
child: Obx(() {
|
||||||
: EdgeInsets.zero,
|
if (controller.currentEmail != null) {
|
||||||
padding: responsiveUtils.isWebDesktop(context)
|
return _buildEmailView(context, controller.currentEmail!);
|
||||||
? const EdgeInsets.only(top: 5, bottom: 5, left: 5, right: 3)
|
} else {
|
||||||
: EdgeInsets.zero,
|
return _buildEmailViewEmpty(context);
|
||||||
child: Column(children: [
|
}
|
||||||
_buildAppBar(context),
|
})
|
||||||
_buildVacationNotificationMessage(context),
|
|
||||||
if (responsiveUtils.isWebDesktop(context))
|
|
||||||
const SizedBox(height: 5),
|
|
||||||
Obx(() {
|
|
||||||
if (controller.currentEmail != null &&
|
|
||||||
!responsiveUtils.isWebDesktop(context)) {
|
|
||||||
return _buildDivider();
|
|
||||||
}
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}),
|
|
||||||
Expanded(child: _buildEmailBody(context)),
|
|
||||||
Obx(() => controller.currentEmail != null
|
|
||||||
? const Divider(color: AppColor.colorDividerEmailView, height: 1)
|
|
||||||
: const SizedBox.shrink()),
|
|
||||||
_buildBottomBar(context),
|
|
||||||
])
|
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
])
|
])
|
||||||
@@ -86,6 +70,34 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EdgeInsets _getMarginEmailView(BuildContext context) {
|
||||||
|
if (BuildUtils.isWeb) {
|
||||||
|
if (responsiveUtils.isDesktop(context)) {
|
||||||
|
return const EdgeInsets.only(right: 16, top: 16, bottom: 16);
|
||||||
|
} else {
|
||||||
|
return const EdgeInsets.symmetric(vertical: 16);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return EdgeInsets.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmailViewEmpty(BuildContext context) {
|
||||||
|
return Center(child: _buildEmailEmpty(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmailView(BuildContext context, PresentationEmail email) {
|
||||||
|
return Column(children: [
|
||||||
|
_buildAppBar(context, email),
|
||||||
|
_buildVacationNotificationMessage(context),
|
||||||
|
const Divider(color: AppColor.colorDividerHorizontal, height: 1),
|
||||||
|
Expanded(child: _buildEmailBody(context, email)),
|
||||||
|
const Divider(color: AppColor.colorDividerHorizontal, height: 1),
|
||||||
|
_buildBottomBar(context, email),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool _supportVerticalDivider(BuildContext context) {
|
bool _supportVerticalDivider(BuildContext context) {
|
||||||
if (BuildUtils.isWeb) {
|
if (BuildUtils.isWeb) {
|
||||||
return responsiveUtils.isTabletLarge(context);
|
return responsiveUtils.isTabletLarge(context);
|
||||||
@@ -94,12 +106,6 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDivider({EdgeInsets? edgeInsets}){
|
|
||||||
return Padding(
|
|
||||||
padding: edgeInsets ?? const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
child: const Divider(color: AppColor.colorDividerEmailView, height: 0.5));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildVacationNotificationMessage(BuildContext context) {
|
Widget _buildVacationNotificationMessage(BuildContext context) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
final vacation = controller.mailboxDashBoardController.vacationResponse.value;
|
final vacation = controller.mailboxDashBoardController.vacationResponse.value;
|
||||||
@@ -122,78 +128,51 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAppBar(BuildContext context) {
|
Widget _buildAppBar(BuildContext context, PresentationEmail presentationEmail) {
|
||||||
return Obx(() => Padding(
|
return Obx(() => AppBarMailWidgetBuilder(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
presentationEmail,
|
||||||
child: AppBarMailWidgetBuilder(
|
currentMailbox: controller.mailboxDashBoardController.selectedMailbox.value,
|
||||||
controller.currentEmail,
|
isSearchIsRunning: controller.mailboxDashBoardController.searchController.isSearchEmailRunning,
|
||||||
currentMailbox: controller.mailboxDashBoardController.selectedMailbox.value,
|
onBackActionClick: () => controller.closeEmailView(context),
|
||||||
isSearchIsRunning: controller.mailboxDashBoardController.searchController.isSearchEmailRunning,
|
onEmailActionClick: (email, action) =>
|
||||||
onBackActionClick: () => controller.closeEmailView(context),
|
controller.handleEmailAction(context, email, action),
|
||||||
onEmailActionClick: (email, action) =>
|
onMoreActionClick: (email, position) {
|
||||||
controller.handleEmailAction(context, email, action),
|
if (position == null) {
|
||||||
onMoreActionClick: (email, position) {
|
controller.openContextMenuAction(
|
||||||
if (responsiveUtils.isMobile(context)) {
|
context,
|
||||||
controller.openContextMenuAction(
|
_emailActionMoreActionTile(context, email));
|
||||||
context,
|
} else {
|
||||||
_emailActionMoreActionTile(context, email));
|
controller.openPopupMenuAction(
|
||||||
} else {
|
context,
|
||||||
controller.openPopupMenuAction(
|
position,
|
||||||
context,
|
_popupMenuEmailActionTile(context, email));
|
||||||
position,
|
|
||||||
_popupMenuEmailActionTile(context, email));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBottomBar(BuildContext context) {
|
Widget _buildBottomBar(BuildContext context, PresentationEmail presentationEmail) {
|
||||||
bool isMobileDevice = responsiveUtils.isPortraitMobile(context) ||
|
return BottomBarMailWidgetBuilder(
|
||||||
responsiveUtils.isLandscapeMobile(context);
|
presentationEmail,
|
||||||
return Padding(
|
onPressEmailActionClick: (emailActionType) => controller.pressEmailAction(emailActionType));
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: isMobileDevice ? 16 : 0),
|
|
||||||
child: Obx(() => (BottomBarMailWidgetBuilder(
|
|
||||||
context,
|
|
||||||
imagePaths,
|
|
||||||
responsiveUtils,
|
|
||||||
controller.mailboxDashBoardController.selectedEmail.value)
|
|
||||||
..addOnPressEmailAction((emailActionType) =>
|
|
||||||
controller.pressEmailAction(emailActionType)))
|
|
||||||
.build()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailBody(BuildContext context) {
|
Widget _buildEmailBody(BuildContext context, PresentationEmail email) {
|
||||||
return GestureDetector(
|
if (BuildUtils.isWeb) {
|
||||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
return _buildEmailMessage(context, email);
|
||||||
child: Container(
|
} else {
|
||||||
color: Colors.white,
|
return SingleChildScrollView(
|
||||||
margin: EdgeInsets.zero,
|
physics : const ClampingScrollPhysics(),
|
||||||
alignment: Alignment.topCenter,
|
child: Container(
|
||||||
child: Obx(() {
|
margin: EdgeInsets.zero,
|
||||||
if (controller.currentEmail != null) {
|
width: double.infinity,
|
||||||
if (kIsWeb) {
|
alignment: Alignment.center,
|
||||||
return _buildEmailMessage(context);
|
padding: EdgeInsets.zero,
|
||||||
} else {
|
color: Colors.white,
|
||||||
return SingleChildScrollView(
|
child: _buildEmailMessage(context, email)
|
||||||
physics : const ClampingScrollPhysics(),
|
)
|
||||||
child: Container(
|
);
|
||||||
margin: EdgeInsets.zero,
|
}
|
||||||
width: double.infinity,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
color: Colors.white,
|
|
||||||
child: _buildEmailMessage(context)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Center(child: _buildEmailEmpty(context));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailEmpty(BuildContext context) {
|
Widget _buildEmailEmpty(BuildContext context) {
|
||||||
@@ -203,56 +182,106 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
style: const TextStyle(fontSize: 25, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold));
|
style: const TextStyle(fontSize: 25, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailSubject(BuildContext context) {
|
Widget _buildEmailSubject(BuildContext context, PresentationEmail email) {
|
||||||
return Padding(
|
return Container(
|
||||||
padding: const EdgeInsets.only(right: 16),
|
color: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
child: SelectableText(
|
child: SelectableText(
|
||||||
'${controller.mailboxDashBoardController.selectedEmail.value?.getEmailTitle()}',
|
email.getEmailTitle(),
|
||||||
maxLines: kIsWeb ? 3 : null,
|
maxLines: BuildUtils.isWeb ? 2 : null,
|
||||||
minLines: kIsWeb ? 1 : null,
|
minLines: BuildUtils.isWeb ? 1 : null,
|
||||||
cursorColor: AppColor.colorTextButton,
|
cursorColor: AppColor.colorTextButton,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: AppColor.colorNameEmail,
|
color: AppColor.colorNameEmail,
|
||||||
fontWeight: responsiveUtils.isDesktop(context) ? FontWeight.w500 : FontWeight.normal)
|
fontWeight: FontWeight.w500)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailMessage(BuildContext context) {
|
Widget _buildEmailMessage(BuildContext context, PresentationEmail email) {
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
return Column(crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildEmailSubject(context, email),
|
||||||
|
_buildEmailInformationSenderAndReceiver(context, email),
|
||||||
|
_buildLoadingView(),
|
||||||
|
_buildAttachments(context),
|
||||||
|
if (BuildUtils.isWeb)
|
||||||
|
Expanded(child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 16, bottom: 16),
|
||||||
|
child: _buildEmailContent(context, constraints)))
|
||||||
|
else
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: _buildEmailContent(context, constraints))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmailInformationSenderAndReceiver(
|
||||||
|
BuildContext context,
|
||||||
|
PresentationEmail presentationEmail
|
||||||
|
) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(left: 16, right: 16, top: 10),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: LayoutBuilder(
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
child: Row(
|
||||||
return Column(
|
crossAxisAlignment: presentationEmail.numberOfAllEmailAddress() > 0
|
||||||
children: [
|
? CrossAxisAlignment.start
|
||||||
Row(
|
: CrossAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
children: [
|
||||||
|
(AvatarBuilder()
|
||||||
|
..text(presentationEmail.getAvatarText())
|
||||||
|
..size(48)
|
||||||
|
..addTextStyle(const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 21,
|
||||||
|
color: Colors.white))
|
||||||
|
..backgroundColor(AppColor.colorAvatar))
|
||||||
|
.build(),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: LayoutBuilder(builder: (context, constraints) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _buildEmailSubject(context)),
|
Row(children: [
|
||||||
_buildEmailTime(context),
|
if (presentationEmail.from?.isNotEmpty == true)
|
||||||
]),
|
Expanded(child: Padding(
|
||||||
if (responsiveUtils.isDesktop(context)) const SizedBox(height: 20),
|
padding: const EdgeInsets.only(right: 12),
|
||||||
if (!responsiveUtils.isDesktop(context)) _buildDivider(edgeInsets: const EdgeInsets.only(top: 16)),
|
child: Transform(
|
||||||
Obx(() => controller.currentEmail != null
|
transform: Matrix4.translationValues(-5.0, 0.0, 0.0),
|
||||||
? _buildEmailAddress(
|
child: _buildEmailAddressOfSender(
|
||||||
context,
|
context,
|
||||||
controller.currentEmail!,
|
presentationEmail.from!.first,
|
||||||
controller.emailAddressExpandMode.value,
|
constraints.maxWidth),
|
||||||
controller.isDisplayFullEmailAddress.value)
|
),
|
||||||
: const SizedBox.shrink()),
|
)),
|
||||||
_buildDivider(edgeInsets: const EdgeInsets.only(top: 8)),
|
_buildEmailReceivedTime(context),
|
||||||
_buildLoadingView(),
|
]),
|
||||||
_buildAttachments(context),
|
if (presentationEmail.numberOfAllEmailAddress() > 0)
|
||||||
if (kIsWeb)
|
Obx(() => Row(
|
||||||
Expanded(child: _buildEmailContent(context, constraints))
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
else
|
children: [
|
||||||
_buildEmailContent(context, constraints),
|
Expanded(child: _buildEmailAddressOfReceiver(
|
||||||
const SizedBox(height: 16),
|
context,
|
||||||
],
|
presentationEmail,
|
||||||
);
|
controller.isDisplayFullEmailAddress,
|
||||||
})
|
constraints)),
|
||||||
|
if (controller.isDisplayFullEmailAddress)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
child: _buildGoneDisplayFullButton(context))
|
||||||
|
]
|
||||||
|
)),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,156 +308,265 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailTime(BuildContext context) {
|
Widget _buildEmailReceivedTime(BuildContext context) {
|
||||||
return Transform(
|
return Container(
|
||||||
transform: Matrix4.translationValues(0.0, 12.0, 0.0),
|
constraints: const BoxConstraints(maxWidth: 100),
|
||||||
child: Text(
|
color: Colors.transparent,
|
||||||
'${controller.currentEmail?.getReceivedAt(
|
child: Text(
|
||||||
Localizations.localeOf(context).toLanguageTag(),
|
'${controller.currentEmail?.getReceivedAt(
|
||||||
pattern: controller.currentEmail?.receivedAt?.value.toLocal().toPatternForEmailView())}',
|
Localizations.localeOf(context).toLanguageTag(),
|
||||||
maxLines: 1,
|
pattern: controller.currentEmail?.receivedAt?.value.toLocal().toPatternForEmailView())}',
|
||||||
overflow:TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
style: const TextStyle(fontSize: 13, color: AppColor.colorTime)));
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
color: AppColor.colorEmailAddressFull)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailAddress(BuildContext context, PresentationEmail email, ExpandMode expandMode, bool isDisplayFull) {
|
Widget _buildEmailAddressOfSender(
|
||||||
return Column(
|
BuildContext context,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
EmailAddress sender,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
double maxWidth
|
||||||
children: [
|
) {
|
||||||
if (email.from.numberEmailAddress() > 0)
|
return Row(
|
||||||
_buildEmailAddressByPrefix(context, email, PrefixEmailAddress.from, isDisplayFull),
|
children: [
|
||||||
if (email.to.numberEmailAddress() > 0 && expandMode == ExpandMode.EXPAND)
|
if (sender.displayName.isNotEmpty)
|
||||||
_buildDivider(edgeInsets: const EdgeInsets.only(top: kIsWeb ? 8 : 4, bottom: 4)),
|
Material(
|
||||||
if (email.to.numberEmailAddress() > 0 && expandMode == ExpandMode.EXPAND)
|
color: Colors.transparent,
|
||||||
_buildEmailAddressByPrefix(context, email, PrefixEmailAddress.to, isDisplayFull),
|
child: InkWell(
|
||||||
if (email.cc.numberEmailAddress() > 0 && expandMode == ExpandMode.EXPAND && isDisplayFull)
|
onTap: () => controller.openEmailAddressDialog(context, sender),
|
||||||
_buildDivider(edgeInsets: const EdgeInsets.only(top: kIsWeb ? 8 : 4, bottom: 4)),
|
customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
if (email.cc.numberEmailAddress() > 0 && expandMode == ExpandMode.EXPAND && isDisplayFull)
|
child: Container(
|
||||||
_buildEmailAddressByPrefix(context, email, PrefixEmailAddress.cc, isDisplayFull),
|
constraints: BoxConstraints(maxWidth: maxWidth - 100),
|
||||||
if (email.bcc.numberEmailAddress() > 0 && expandMode == ExpandMode.EXPAND && isDisplayFull)
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
_buildDivider(edgeInsets: const EdgeInsets.only(top: kIsWeb ? 8 : 4, bottom: 4)),
|
child: Text(
|
||||||
if (email.bcc.numberEmailAddress() > 0 && expandMode == ExpandMode.EXPAND && isDisplayFull)
|
sender.displayName,
|
||||||
_buildEmailAddressByPrefix(context, email, PrefixEmailAddress.bcc, isDisplayFull),
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
],
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'<${sender.emailAddress}>',
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppColor.colorEmailAddressFull)),
|
||||||
|
),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double _getMaxWidthEmailAddressDisplayed(BuildContext context, double maxWidth) {
|
||||||
|
if (responsiveUtils.isPortraitMobile(context)) {
|
||||||
|
return maxWidth - maxSizeFullDisplayEmailAddressArrowDownButton;
|
||||||
|
} else if (responsiveUtils.isWebDesktop(context)) {
|
||||||
|
return maxWidth / 2;
|
||||||
|
} else {
|
||||||
|
return maxWidth * 3/4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmailAddressOfReceiver(
|
||||||
|
BuildContext context,
|
||||||
|
PresentationEmail presentationEmail,
|
||||||
|
bool isDisplayFull,
|
||||||
|
BoxConstraints constraints
|
||||||
|
) {
|
||||||
|
if (!isDisplayFull && presentationEmail.numberOfAllEmailAddress() > 2) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 40,
|
||||||
|
color: Colors.white,
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: _getMaxWidthEmailAddressDisplayed(
|
||||||
|
context,
|
||||||
|
constraints.maxWidth)),
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
children: [
|
||||||
|
if (presentationEmail.to.numberEmailAddress() > 0)
|
||||||
|
_buildEmailAddressByPrefix(
|
||||||
|
context,
|
||||||
|
presentationEmail,
|
||||||
|
PrefixEmailAddress.to,
|
||||||
|
isDisplayFull),
|
||||||
|
if (presentationEmail.cc.numberEmailAddress() > 0)
|
||||||
|
_buildEmailAddressByPrefix(
|
||||||
|
context,
|
||||||
|
presentationEmail,
|
||||||
|
PrefixEmailAddress.cc,
|
||||||
|
isDisplayFull),
|
||||||
|
if (presentationEmail.bcc.numberEmailAddress() > 0)
|
||||||
|
_buildEmailAddressByPrefix(
|
||||||
|
context,
|
||||||
|
presentationEmail,
|
||||||
|
PrefixEmailAddress.bcc,
|
||||||
|
isDisplayFull),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: controller.expandEmailAddress,
|
||||||
|
customBorder: const CircleBorder(),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(5),
|
||||||
|
color: Colors.transparent,
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxHeight: maxSizeFullDisplayEmailAddressArrowDownButton,
|
||||||
|
maxWidth: maxSizeFullDisplayEmailAddressArrowDownButton),
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
imagePaths.icChevronDown,
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
fit: BoxFit.fill),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (presentationEmail.to.numberEmailAddress() > 0)
|
||||||
|
_buildEmailAddressByPrefix(
|
||||||
|
context,
|
||||||
|
presentationEmail,
|
||||||
|
PrefixEmailAddress.to,
|
||||||
|
isDisplayFull),
|
||||||
|
if (presentationEmail.cc.numberEmailAddress() > 0 && isDisplayFull)
|
||||||
|
_buildEmailAddressByPrefix(
|
||||||
|
context,
|
||||||
|
presentationEmail,
|
||||||
|
PrefixEmailAddress.cc,
|
||||||
|
isDisplayFull),
|
||||||
|
if (presentationEmail.bcc.numberEmailAddress() > 0 && isDisplayFull)
|
||||||
|
_buildEmailAddressByPrefix(
|
||||||
|
context,
|
||||||
|
presentationEmail,
|
||||||
|
PrefixEmailAddress.bcc,
|
||||||
|
isDisplayFull),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildEmailAddressByPrefix(
|
Widget _buildEmailAddressByPrefix(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
PresentationEmail presentationEmail,
|
PresentationEmail presentationEmail,
|
||||||
PrefixEmailAddress prefixEmailAddress,
|
PrefixEmailAddress prefixEmailAddress,
|
||||||
bool isDisplayFull,
|
bool isDisplayFull
|
||||||
) {
|
) {
|
||||||
return Row(
|
return Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.only(top: 4),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Row(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Padding(
|
mainAxisSize: MainAxisSize.min,
|
||||||
padding: const EdgeInsets.only(top: kIsWeb ? 10: 20),
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 5),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${prefixEmailAddress.asName(context)}:',
|
'${prefixEmailAddress.asName(context)}:',
|
||||||
style: const TextStyle(fontSize: 14, color: AppColor.colorEmailAddressPrefix))),
|
style: const TextStyle(
|
||||||
Expanded(child: _buildEmailAddressWidget(
|
fontSize: 16,
|
||||||
context,
|
fontWeight: FontWeight.w500,
|
||||||
presentationEmail,
|
color: AppColor.colorEmailAddressFull)),
|
||||||
prefixEmailAddress.listEmailAddress(presentationEmail),
|
),
|
||||||
prefixEmailAddress,
|
if (!isDisplayFull && presentationEmail.numberOfAllEmailAddress() > 2)
|
||||||
isDisplayFull
|
_buildListEmailAddressWidget(
|
||||||
)),
|
context,
|
||||||
if (prefixEmailAddress == PrefixEmailAddress.from) _buildEmailAddressDetailButton(context),
|
prefixEmailAddress.listEmailAddress(presentationEmail),
|
||||||
]
|
isDisplayFull
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Expanded(child: _buildListEmailAddressWidget(
|
||||||
|
context,
|
||||||
|
prefixEmailAddress.listEmailAddress(presentationEmail),
|
||||||
|
isDisplayFull
|
||||||
|
))
|
||||||
|
]
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmailAddressWidget(
|
Widget _buildListEmailAddressWidget(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
PresentationEmail presentationEmail,
|
|
||||||
List<EmailAddress> listEmailAddress,
|
List<EmailAddress> listEmailAddress,
|
||||||
PrefixEmailAddress prefixEmailAddress,
|
bool isDisplayFull
|
||||||
bool isDisplayFull,
|
|
||||||
) {
|
) {
|
||||||
final displayedEmailAddress = isDisplayFull
|
final lastEmailAddress = listEmailAddress.last;
|
||||||
? listEmailAddress
|
final emailAddressWidgets = listEmailAddress.map((emailAddress) {
|
||||||
: listEmailAddress.sublist(0, limitAddressDisplay);
|
return Material(
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 4),
|
|
||||||
child: Wrap(
|
|
||||||
children: [
|
|
||||||
...displayedEmailAddress.map((emailAddress) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 10),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => controller.openEmailAddressDialog(context, emailAddress),
|
|
||||||
child: Chip(
|
|
||||||
labelPadding: const EdgeInsets.only(left: 8, right: 8, bottom: 2),
|
|
||||||
label: Text(emailAddress.asString(), maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
||||||
labelStyle: const TextStyle(color: AppColor.colorNameEmail, fontSize: 15, fontWeight: FontWeight.normal),
|
|
||||||
backgroundColor: AppColor.colorEmailAddressTag,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
side: const BorderSide(width: 0, color: AppColor.colorEmailAddressTag),
|
|
||||||
),
|
|
||||||
avatar: (AvatarBuilder()
|
|
||||||
..text(emailAddress.asString().characters.first.toUpperCase())
|
|
||||||
..addTextStyle(const TextStyle(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w600))
|
|
||||||
..avatarColor(emailAddress.avatarColors))
|
|
||||||
.build(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
if (prefixEmailAddress == PrefixEmailAddress.to
|
|
||||||
&& presentationEmail.numberOfAllEmailAddress() > 1
|
|
||||||
&& !isDisplayFull)
|
|
||||||
_buildEmailAddressCounter(context, presentationEmail),
|
|
||||||
]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildEmailAddressDetailButton(BuildContext context) {
|
|
||||||
return Material(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Padding(
|
child: InkWell(
|
||||||
padding: const EdgeInsets.only(top: 4, left: 16),
|
onTap: () => controller.openEmailAddressDialog(context, emailAddress),
|
||||||
child: TextButton(
|
customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
onPressed: () => controller.toggleDisplayEmailAddressAction(),
|
child: Padding(
|
||||||
child: Text(
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
|
||||||
controller.isExpandEmailAddress
|
child: Text(
|
||||||
? AppLocalizations.of(context).hide
|
lastEmailAddress == emailAddress
|
||||||
: AppLocalizations.of(context).details,
|
? emailAddress.asString()
|
||||||
style: const TextStyle(fontSize: 15, color: AppColor.colorTextButton, fontWeight: FontWeight.normal),
|
: '${emailAddress.asString()},',
|
||||||
),
|
maxLines: 1,
|
||||||
)
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
)
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
);
|
style: const TextStyle(
|
||||||
}
|
color: Colors.black,
|
||||||
|
fontSize: 16,
|
||||||
String _getRemainCountAddressReceiver(PresentationEmail email) {
|
fontWeight: FontWeight.normal)),
|
||||||
if (email.numberOfAllEmailAddress() - limitAddressDisplay >= 999) {
|
|
||||||
return '999';
|
|
||||||
}
|
|
||||||
return '${email.numberOfAllEmailAddress() - limitAddressDisplay}';
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildEmailAddressCounter(BuildContext context, PresentationEmail email) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () => controller.showFullEmailAddress(),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8),
|
|
||||||
child: Chip(
|
|
||||||
labelPadding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
label: Text('+${_getRemainCountAddressReceiver(email)}', maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
||||||
labelStyle: const TextStyle(color: AppColor.colorTextButton, fontSize: 15, fontWeight: FontWeight.normal),
|
|
||||||
backgroundColor: AppColor.colorEmailAddressTag,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
side: const BorderSide(width: 0, color: AppColor.colorEmailAddressTag),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
if (isDisplayFull) {
|
||||||
|
return Wrap(children: emailAddressWidgets);
|
||||||
|
} else {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment:CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: emailAddressWidgets),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildGoneDisplayFullButton(BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: controller.collapseEmailAddress,
|
||||||
|
customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).hide,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: AppColor.colorTextButton,
|
||||||
|
fontWeight: FontWeight.normal),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,7 +693,7 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
|||||||
if (controller.emailContents.isNotEmpty) {
|
if (controller.emailContents.isNotEmpty) {
|
||||||
final allEmailContents = controller.emailContents.asHtmlString;
|
final allEmailContents = controller.emailContents.asHtmlString;
|
||||||
|
|
||||||
if (kIsWeb) {
|
if (BuildUtils.isWeb) {
|
||||||
return HtmlContentViewerOnWeb(
|
return HtmlContentViewerOnWeb(
|
||||||
widthContent: constraints.maxWidth,
|
widthContent: constraints.maxWidth,
|
||||||
heightContent: responsiveUtils.getSizeScreenHeight(context),
|
heightContent: responsiveUtils.getSizeScreenHeight(context),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2022-10-11T09:16:53.834708",
|
"@@last_modified": "2022-10-12T11:51:14.324607",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -738,12 +738,6 @@
|
|||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
"details": "Details",
|
|
||||||
"@details": {
|
|
||||||
"type": "text",
|
|
||||||
"placeholders_order": [],
|
|
||||||
"placeholders": {}
|
|
||||||
},
|
|
||||||
"hide": "Hide",
|
"hide": "Hide",
|
||||||
"@hide": {
|
"@hide": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|||||||
@@ -767,12 +767,6 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String get details {
|
|
||||||
return Intl.message(
|
|
||||||
'Details',
|
|
||||||
name: 'details');
|
|
||||||
}
|
|
||||||
|
|
||||||
String get hide {
|
String get hide {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'Hide',
|
'Hide',
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ extension EmailAddressExtension on EmailAddress {
|
|||||||
|
|
||||||
String asString() {
|
String asString() {
|
||||||
if (displayName.isNotEmpty) {
|
if (displayName.isNotEmpty) {
|
||||||
if (emailAddress.isNotEmpty && displayName == emailAddress) {
|
return displayName;
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
return displayName.capitalizeFirstEach;
|
|
||||||
} else if (emailAddress.isNotEmpty) {
|
} else if (emailAddress.isNotEmpty) {
|
||||||
return emailAddress;
|
return emailAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user