TF-933 Code optimization for EmailItemTile
This commit is contained in:
@@ -0,0 +1,278 @@
|
|||||||
|
|
||||||
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||||
|
import 'package:core/presentation/utils/style_utils.dart';
|
||||||
|
import 'package:core/presentation/views/text/rich_text_builder.dart';
|
||||||
|
import 'package:core/utils/build_utils.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:model/email/email_action_type.dart';
|
||||||
|
import 'package:model/email/presentation_email.dart';
|
||||||
|
import 'package:model/extensions/presentation_email_extension.dart';
|
||||||
|
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||||
|
import 'package:model/mailbox/select_mode.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||||
|
|
||||||
|
typedef OnPressEmailActionClick = void Function(EmailActionType, PresentationEmail);
|
||||||
|
typedef OnMoreActionClick = void Function(PresentationEmail, RelativeRect?);
|
||||||
|
|
||||||
|
mixin BaseEmailItemTile {
|
||||||
|
|
||||||
|
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
|
final imagePaths = Get.find<ImagePaths>();
|
||||||
|
|
||||||
|
Widget buildMailboxContain(
|
||||||
|
SearchStatus state,
|
||||||
|
bool advancedSearchActivated,
|
||||||
|
PresentationEmail email
|
||||||
|
) {
|
||||||
|
if (hasMailboxLabel(state, advancedSearchActivated, email)) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(left: 8),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 3),
|
||||||
|
constraints: const BoxConstraints(maxWidth: 100),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
color: AppColor.backgroundCounterMailboxColor),
|
||||||
|
child: Text(
|
||||||
|
email.mailboxName,
|
||||||
|
maxLines: 1,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
color: AppColor.mailboxTextColor,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSearchEnabled(SearchStatus state, SearchQuery? query) =>
|
||||||
|
state == SearchStatus.ACTIVE && query != null && query.value.isNotEmpty;
|
||||||
|
|
||||||
|
FontWeight buildFontForReadEmail(PresentationEmail email) =>
|
||||||
|
!email.hasRead ? FontWeight.w600 : FontWeight.normal;
|
||||||
|
|
||||||
|
Color buildTextColorForReadEmail(PresentationEmail email) =>
|
||||||
|
email.hasRead ? AppColor.colorContentEmail : AppColor.colorNameEmail;
|
||||||
|
|
||||||
|
bool hasMailboxLabel(SearchStatus state, bool advancedSearchActivated, PresentationEmail email) {
|
||||||
|
return (state == SearchStatus.ACTIVE || advancedSearchActivated) && email.mailboxName.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
String informationSender(PresentationEmail email, PresentationMailbox? mailbox) {
|
||||||
|
if (mailbox?.isSent == true || mailbox?.isDrafts == true || mailbox?.isOutbox == true) {
|
||||||
|
return email.recipientsName();
|
||||||
|
} else {
|
||||||
|
return email.getSenderName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildInformationSender(
|
||||||
|
PresentationEmail email,
|
||||||
|
PresentationMailbox? mailbox,
|
||||||
|
SearchStatus state,
|
||||||
|
SearchQuery? query
|
||||||
|
) {
|
||||||
|
if (isSearchEnabled(state, query)) {
|
||||||
|
return RichTextBuilder(
|
||||||
|
informationSender(email, mailbox),
|
||||||
|
query?.value ?? '',
|
||||||
|
TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
fontWeight: buildFontForReadEmail(email)),
|
||||||
|
TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
backgroundColor: AppColor.bgWordSearch,
|
||||||
|
fontWeight: buildFontForReadEmail(email))
|
||||||
|
).build();
|
||||||
|
} else {
|
||||||
|
return Text(
|
||||||
|
informationSender(email, mailbox),
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
fontWeight: buildFontForReadEmail(email))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildEmailTitle(
|
||||||
|
PresentationEmail email,
|
||||||
|
SearchStatus state,
|
||||||
|
SearchQuery? query
|
||||||
|
) {
|
||||||
|
if (isSearchEnabled(state, query)) {
|
||||||
|
return RichTextBuilder(
|
||||||
|
email.getEmailTitle(),
|
||||||
|
query?.value ?? '',
|
||||||
|
TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
fontWeight: buildFontForReadEmail(email)),
|
||||||
|
TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
backgroundColor: AppColor.bgWordSearch,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
fontWeight: buildFontForReadEmail(email))
|
||||||
|
).build();
|
||||||
|
} else {
|
||||||
|
return Text(
|
||||||
|
email.getEmailTitle(),
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
fontWeight: buildFontForReadEmail(email))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildEmailPartialContent(
|
||||||
|
PresentationEmail email,
|
||||||
|
SearchStatus state,
|
||||||
|
SearchQuery? query
|
||||||
|
) {
|
||||||
|
if (isSearchEnabled(state, query)) {
|
||||||
|
return RichTextBuilder(
|
||||||
|
email.getPartialContent(),
|
||||||
|
query?.value ?? '',
|
||||||
|
const TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: AppColor.colorContentEmail,
|
||||||
|
fontWeight: FontWeight.normal),
|
||||||
|
const TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: AppColor.colorContentEmail,
|
||||||
|
backgroundColor: AppColor.bgWordSearch)
|
||||||
|
).build();
|
||||||
|
} else {
|
||||||
|
return Text(
|
||||||
|
email.getPartialContent(),
|
||||||
|
maxLines: 1,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: AppColor.colorContentEmail,
|
||||||
|
fontWeight: FontWeight.normal)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildDateTime(BuildContext context, PresentationEmail email) {
|
||||||
|
return Text(
|
||||||
|
email.getReceivedAt(Localizations.localeOf(context).toLanguageTag()),
|
||||||
|
maxLines: 1,
|
||||||
|
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||||
|
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: buildTextColorForReadEmail(email),
|
||||||
|
fontWeight: buildFontForReadEmail(email))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildIconChevron() {
|
||||||
|
return SvgPicture.asset(
|
||||||
|
imagePaths.icChevron,
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
fit: BoxFit.fill);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildIconAttachment() {
|
||||||
|
return SvgPicture.asset(
|
||||||
|
imagePaths.icAttachment,
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
fit: BoxFit.fill);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildIconStar() {
|
||||||
|
return SvgPicture.asset(
|
||||||
|
imagePaths.icStar,
|
||||||
|
width: 15,
|
||||||
|
height: 15,
|
||||||
|
fit: BoxFit.fill);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildIconAvatarText(PresentationEmail email, {
|
||||||
|
double? iconSize,
|
||||||
|
TextStyle? textStyle
|
||||||
|
}) {
|
||||||
|
return Container(
|
||||||
|
width: iconSize ?? 56,
|
||||||
|
height: iconSize ?? 56,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular((iconSize ?? 56) * 0.5),
|
||||||
|
border: Border.all(color: Colors.transparent),
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
stops: const [0.0, 1.0],
|
||||||
|
colors: email.avatarColors),
|
||||||
|
color: AppColor.avatarColor
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
email.getAvatarText(),
|
||||||
|
style: textStyle ?? const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w500)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildIconAvatarSelection(
|
||||||
|
BuildContext context,
|
||||||
|
PresentationEmail email,
|
||||||
|
{
|
||||||
|
double? iconSize,
|
||||||
|
TextStyle? textStyle
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
if (BuildUtils.isWeb) {
|
||||||
|
return Container(
|
||||||
|
color: Colors.transparent,
|
||||||
|
width: iconSize ?? 48,
|
||||||
|
height: iconSize ?? 48,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
padding: responsiveUtils.isDesktop(context)
|
||||||
|
? const EdgeInsets.symmetric(horizontal: 4)
|
||||||
|
: const EdgeInsets.all(12),
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
email.selectMode == SelectMode.ACTIVE
|
||||||
|
? imagePaths.icSelected
|
||||||
|
: imagePaths.icUnSelected,
|
||||||
|
fit: BoxFit.fill),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
email.selectMode == SelectMode.ACTIVE
|
||||||
|
? imagePaths.icSelected
|
||||||
|
: imagePaths.icUnSelected,
|
||||||
|
width: 24, height: 24));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,12 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.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:model/model.dart';
|
import 'package:model/model.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread/presentation/mixin/base_email_item_tile.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||||
|
|
||||||
typedef OnPressEmailActionClick = void Function(EmailActionType, PresentationEmail);
|
class EmailTileBuilder with BaseEmailItemTile {
|
||||||
typedef OnMoreActionClick = void Function(PresentationEmail, RelativeRect?);
|
|
||||||
|
|
||||||
class EmailTileBuilder {
|
|
||||||
|
|
||||||
final _imagePaths = Get.find<ImagePaths>();
|
|
||||||
|
|
||||||
final PresentationEmail _presentationEmail;
|
final PresentationEmail _presentationEmail;
|
||||||
final BuildContext _context;
|
final BuildContext _context;
|
||||||
@@ -20,6 +15,8 @@ class EmailTileBuilder {
|
|||||||
final SearchStatus _searchStatus;
|
final SearchStatus _searchStatus;
|
||||||
final SearchQuery? _searchQuery;
|
final SearchQuery? _searchQuery;
|
||||||
final bool advancedSearchActivated;
|
final bool advancedSearchActivated;
|
||||||
|
final EdgeInsets? padding;
|
||||||
|
final EdgeInsets? paddingDivider;
|
||||||
|
|
||||||
OnPressEmailActionClick? _emailActionClick;
|
OnPressEmailActionClick? _emailActionClick;
|
||||||
|
|
||||||
@@ -30,8 +27,10 @@ class EmailTileBuilder {
|
|||||||
this._searchStatus,
|
this._searchStatus,
|
||||||
this._searchQuery,
|
this._searchQuery,
|
||||||
{
|
{
|
||||||
this.mailboxCurrent,
|
|
||||||
this.advancedSearchActivated = false,
|
this.advancedSearchActivated = false,
|
||||||
|
this.mailboxCurrent,
|
||||||
|
this.padding,
|
||||||
|
this.paddingDivider,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ class EmailTileBuilder {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
contentPadding: padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
||||||
onTap: () => _emailActionClick?.call(
|
onTap: () => _emailActionClick?.call(
|
||||||
EmailActionType.preview,
|
EmailActionType.preview,
|
||||||
_presentationEmail),
|
_presentationEmail),
|
||||||
@@ -73,60 +72,23 @@ class EmailTileBuilder {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 5),
|
padding: const EdgeInsets.only(right: 5),
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
_imagePaths.icUnreadStatus,
|
imagePaths.icUnreadStatus,
|
||||||
width: 9,
|
width: 9,
|
||||||
height: 9,
|
height: 9,
|
||||||
fit: BoxFit.fill)),
|
fit: BoxFit.fill)),
|
||||||
Expanded(
|
Expanded(child: buildInformationSender(
|
||||||
child: _searchStatus == SearchStatus.ACTIVE &&
|
_presentationEmail,
|
||||||
_searchQuery != null &&
|
mailboxCurrent,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_getInformationSender(),
|
|
||||||
_searchQuery!.value,
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: AppColor.colorNameEmail,
|
|
||||||
fontWeight: FontWeight.w600),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
fontWeight: _buildFontForReadEmail())).build()
|
|
||||||
: Text(
|
|
||||||
_getInformationSender(),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow:TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()))
|
|
||||||
),
|
|
||||||
if (_presentationEmail.hasAttachment == true)
|
if (_presentationEmail.hasAttachment == true)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8),
|
padding: const EdgeInsets.only(left: 8),
|
||||||
child: SvgPicture.asset(
|
child: buildIconAttachment()),
|
||||||
_imagePaths.icAttachment,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
fit: BoxFit.fill)),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 4, left: 8),
|
padding: const EdgeInsets.only(right: 4, left: 8),
|
||||||
child: Text(
|
child: buildDateTime(_context, _presentationEmail)),
|
||||||
_presentationEmail
|
buildIconChevron(),
|
||||||
.getReceivedAt(Localizations.localeOf(_context)
|
|
||||||
.toLanguageTag()),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow:TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()))),
|
|
||||||
SvgPicture.asset(
|
|
||||||
_imagePaths.icChevron,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
fit: BoxFit.fill),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
@@ -138,158 +100,49 @@ class EmailTileBuilder {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildEmailTitle(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_presentationEmail.getEmailTitle(),
|
buildMailboxContain(
|
||||||
_searchQuery!.value,
|
_searchStatus,
|
||||||
TextStyle(
|
advancedSearchActivated,
|
||||||
fontSize: 13,
|
_presentationEmail),
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail())).build()
|
|
||||||
: Text(
|
|
||||||
_presentationEmail.getEmailTitle(),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()))
|
|
||||||
),
|
|
||||||
if (_hasMailboxLabel)
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(left: 8),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 3),
|
|
||||||
constraints: const BoxConstraints(maxWidth: 100),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
color: AppColor.backgroundCounterMailboxColor),
|
|
||||||
child: Text(
|
|
||||||
_presentationEmail.mailboxName,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: AppColor.mailboxTextColor,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
if (_presentationEmail.hasStarred)
|
if (_presentationEmail.hasStarred)
|
||||||
SvgPicture.asset(
|
Padding(
|
||||||
_imagePaths.icStar,
|
padding: const EdgeInsets.only(left: 8),
|
||||||
width: 15,
|
child: buildIconStar(),
|
||||||
height: 15,
|
)
|
||||||
fit: BoxFit.fill)
|
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
padding: const EdgeInsets.only(top: 6),
|
||||||
child: Row(children: [
|
child: Row(children: [
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildEmailPartialContent(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_presentationEmail.getPartialContent(),
|
|
||||||
_searchQuery!.value,
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail),
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail,
|
|
||||||
backgroundColor: AppColor.bgWordSearch)).build()
|
|
||||||
: Text(
|
|
||||||
_presentationEmail.getPartialContent(),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail))
|
|
||||||
),
|
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
padding: paddingDivider ?? const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Divider(
|
child: const Divider(
|
||||||
color: AppColor.lineItemListColor,
|
color: AppColor.lineItemListColor,
|
||||||
height: 1,
|
height: 1,
|
||||||
thickness: 0.2)),
|
thickness: 0.2)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAvatarIcon({
|
Widget _buildAvatarIcon() {
|
||||||
double? iconSize,
|
|
||||||
TextStyle? textStyle
|
|
||||||
}) {
|
|
||||||
if (_selectModeAll == SelectMode.ACTIVE) {
|
if (_selectModeAll == SelectMode.ACTIVE) {
|
||||||
return Container(
|
return buildIconAvatarSelection(_context, _presentationEmail);
|
||||||
alignment: Alignment.center,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
_presentationEmail.selectMode == SelectMode.ACTIVE
|
|
||||||
? _imagePaths.icSelected
|
|
||||||
: _imagePaths.icUnSelected,
|
|
||||||
width: 24, height: 24));
|
|
||||||
} else {
|
} else {
|
||||||
return Container(
|
return buildIconAvatarText(_presentationEmail);
|
||||||
width: iconSize ?? 56,
|
|
||||||
height: iconSize ?? 56,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular((iconSize ?? 56) * 0.5),
|
|
||||||
border: Border.all(color: Colors.transparent),
|
|
||||||
gradient: LinearGradient(
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter,
|
|
||||||
stops: const [0.0, 1.0],
|
|
||||||
colors: _presentationEmail.avatarColors),
|
|
||||||
color: AppColor.avatarColor
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
_presentationEmail.getAvatarText(),
|
|
||||||
style: textStyle ?? const TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.w500)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FontWeight _buildFontForReadEmail() {
|
|
||||||
return !_presentationEmail.hasRead ? FontWeight.w600 : FontWeight.normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color _buildTextColorForReadEmail() {
|
|
||||||
return _presentationEmail.hasRead
|
|
||||||
? AppColor.colorContentEmail
|
|
||||||
: AppColor.colorNameEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
String _getInformationSender() {
|
|
||||||
if (mailboxCurrent?.isSent == true
|
|
||||||
|| mailboxCurrent?.isDrafts == true
|
|
||||||
|| mailboxCurrent?.isOutbox == true) {
|
|
||||||
return _presentationEmail.recipientsName();
|
|
||||||
}
|
|
||||||
return _presentationEmail.getSenderName();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get _hasMailboxLabel {
|
|
||||||
return (_searchStatus == SearchStatus.ACTIVE ||
|
|
||||||
advancedSearchActivated) &&
|
|
||||||
_presentationEmail.mailboxName.isNotEmpty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,19 +2,13 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.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:model/model.dart';
|
import 'package:model/model.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||||
|
import 'package:tmail_ui_user/features/thread/presentation/mixin/base_email_item_tile.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
typedef OnPressEmailActionClick = void Function(EmailActionType, PresentationEmail);
|
class EmailTileBuilder with BaseEmailItemTile {
|
||||||
typedef OnMoreActionClick = void Function(PresentationEmail, RelativeRect?);
|
|
||||||
|
|
||||||
class EmailTileBuilder {
|
|
||||||
|
|
||||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
|
||||||
final _imagePaths = Get.find<ImagePaths>();
|
|
||||||
|
|
||||||
final PresentationEmail _presentationEmail;
|
final PresentationEmail _presentationEmail;
|
||||||
final BuildContext _context;
|
final BuildContext _context;
|
||||||
@@ -23,6 +17,8 @@ class EmailTileBuilder {
|
|||||||
final SearchStatus _searchStatus;
|
final SearchStatus _searchStatus;
|
||||||
final SearchQuery? _searchQuery;
|
final SearchQuery? _searchQuery;
|
||||||
final bool advancedSearchActivated;
|
final bool advancedSearchActivated;
|
||||||
|
final EdgeInsets? padding;
|
||||||
|
final EdgeInsets? paddingDivider;
|
||||||
|
|
||||||
OnPressEmailActionClick? _emailActionClick;
|
OnPressEmailActionClick? _emailActionClick;
|
||||||
OnMoreActionClick? _onMoreActionClick;
|
OnMoreActionClick? _onMoreActionClick;
|
||||||
@@ -37,8 +33,10 @@ class EmailTileBuilder {
|
|||||||
this._searchStatus,
|
this._searchStatus,
|
||||||
this._searchQuery,
|
this._searchQuery,
|
||||||
{
|
{
|
||||||
|
this.advancedSearchActivated = false,
|
||||||
this.mailboxCurrent,
|
this.mailboxCurrent,
|
||||||
this.advancedSearchActivated = false
|
this.padding,
|
||||||
|
this.paddingDivider,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -59,16 +57,20 @@ class EmailTileBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget build() {
|
Widget build() {
|
||||||
return ResponsiveWidget(
|
return Container(
|
||||||
responsiveUtils: _responsiveUtils,
|
color: Colors.transparent,
|
||||||
mobile: _wrapContainerForTile(_buildListTile()),
|
padding: padding,
|
||||||
tablet: _wrapContainerForTile(_buildListTileTablet()),
|
child: ResponsiveWidget(
|
||||||
desktop: _wrapContainerForTile(_buildListTileForDesktop()),
|
responsiveUtils: responsiveUtils,
|
||||||
|
mobile: _wrapContainerForTile(_buildListTile()),
|
||||||
|
tablet: _wrapContainerForTile(_buildListTileTablet()),
|
||||||
|
desktop: _wrapContainerForTile(_buildListTileForDesktop()),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _wrapContainerForTile(Widget tile) {
|
Widget _wrapContainerForTile(Widget tile) {
|
||||||
if (_responsiveUtils.isDesktop(_context)) {
|
if (responsiveUtils.isDesktop(_context)) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(top: 3),
|
margin: const EdgeInsets.only(top: 3),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
@@ -126,142 +128,53 @@ class EmailTileBuilder {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 5),
|
padding: const EdgeInsets.only(right: 5),
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
_imagePaths.icUnreadStatus,
|
imagePaths.icUnreadStatus,
|
||||||
width: 9,
|
width: 9,
|
||||||
height: 9,
|
height: 9,
|
||||||
fit: BoxFit.fill)),
|
fit: BoxFit.fill)),
|
||||||
Expanded(
|
Expanded(child: buildInformationSender(
|
||||||
child: _searchStatus == SearchStatus.ACTIVE &&
|
_presentationEmail,
|
||||||
_searchQuery != null &&
|
mailboxCurrent,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_getInformationSender(),
|
|
||||||
_searchQuery!.value,
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
fontWeight: _buildFontForReadEmail())).build()
|
|
||||||
: Text(
|
|
||||||
_getInformationSender(),
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()))
|
|
||||||
),
|
|
||||||
if (_presentationEmail.hasAttachment == true)
|
if (_presentationEmail.hasAttachment == true)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8),
|
padding: const EdgeInsets.only(left: 8),
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
_imagePaths.icAttachment,
|
imagePaths.icAttachment,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
fit: BoxFit.fill)),
|
fit: BoxFit.fill)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 4, left: 8),
|
padding: const EdgeInsets.only(right: 4, left: 8),
|
||||||
child: Text(
|
child: buildDateTime(_context, _presentationEmail)),
|
||||||
_presentationEmail
|
buildIconChevron()
|
||||||
.getReceivedAt(Localizations.localeOf(_context)
|
|
||||||
.toLanguageTag()),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail))),
|
|
||||||
SvgPicture.asset(
|
|
||||||
_imagePaths.icChevron,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
fit: BoxFit.fill)
|
|
||||||
]),
|
]),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildEmailTitle(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_presentationEmail.getEmailTitle(),
|
buildMailboxContain(
|
||||||
_searchQuery!.value,
|
_searchStatus,
|
||||||
TextStyle(
|
advancedSearchActivated,
|
||||||
fontSize: 13,
|
_presentationEmail),
|
||||||
color: _buildTextColorForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
color: _buildTextColorForReadEmail())).build()
|
|
||||||
: Text(
|
|
||||||
_presentationEmail.getEmailTitle(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail()))
|
|
||||||
),
|
|
||||||
if (_hasMailboxLabel)
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(left: 8),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 3),
|
|
||||||
constraints: const BoxConstraints(maxWidth: 100),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
color: AppColor.backgroundCounterMailboxColor),
|
|
||||||
child: Text(
|
|
||||||
_presentationEmail.mailboxName,
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: AppColor.mailboxTextColor,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
if (_presentationEmail.hasStarred)
|
if (_presentationEmail.hasStarred)
|
||||||
SvgPicture.asset(
|
Padding(
|
||||||
_imagePaths.icStar,
|
padding: const EdgeInsets.only(left: 8),
|
||||||
width: 15,
|
child: buildIconStar(),
|
||||||
height: 15,
|
),
|
||||||
fit: BoxFit.fill),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(children: [
|
Row(children: [
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildEmailPartialContent(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_presentationEmail.getPartialContent(),
|
|
||||||
_searchQuery!.value,
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail),
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail,
|
|
||||||
backgroundColor: AppColor.bgWordSearch)).build()
|
|
||||||
: Text(
|
|
||||||
_presentationEmail.getPartialContent(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail))
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
@@ -308,36 +221,15 @@ class EmailTileBuilder {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 5),
|
padding: const EdgeInsets.only(right: 5),
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
_imagePaths.icUnreadStatus,
|
imagePaths.icUnreadStatus,
|
||||||
width: 9,
|
width: 9,
|
||||||
height: 9,
|
height: 9,
|
||||||
fit: BoxFit.fill)),
|
fit: BoxFit.fill)),
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildInformationSender(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
mailboxCurrent,
|
||||||
? RichTextBuilder(
|
_searchStatus,
|
||||||
_getInformationSender(),
|
_searchQuery)),
|
||||||
_searchQuery!.value,
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
fontWeight: _buildFontForReadEmail())).build()
|
|
||||||
: Text(
|
|
||||||
_getInformationSender(),
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()))
|
|
||||||
),
|
|
||||||
if (isHoverItem)
|
if (isHoverItem)
|
||||||
const SizedBox(width: 120)
|
const SizedBox(width: 120)
|
||||||
else
|
else
|
||||||
@@ -347,82 +239,27 @@ class EmailTileBuilder {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildEmailTitle(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_presentationEmail.getEmailTitle(),
|
buildMailboxContain(
|
||||||
_searchQuery!.value,
|
_searchStatus,
|
||||||
TextStyle(
|
advancedSearchActivated,
|
||||||
fontSize: 13,
|
_presentationEmail),
|
||||||
color: _buildTextColorForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
color: _buildTextColorForReadEmail())
|
|
||||||
).build()
|
|
||||||
: Text(
|
|
||||||
_presentationEmail.getEmailTitle(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail()))
|
|
||||||
),
|
|
||||||
if (_hasMailboxLabel)
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(left: 8),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 3),
|
|
||||||
constraints: const BoxConstraints(maxWidth: 100),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
color: AppColor.backgroundCounterMailboxColor),
|
|
||||||
child: Text(
|
|
||||||
_presentationEmail.mailboxName,
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: AppColor.mailboxTextColor,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
if (_presentationEmail.hasStarred)
|
if (_presentationEmail.hasStarred)
|
||||||
SvgPicture.asset(
|
Padding(
|
||||||
_imagePaths.icStar,
|
padding: const EdgeInsets.only(left: 8),
|
||||||
width: 15,
|
child: buildIconStar(),
|
||||||
height: 15,
|
)
|
||||||
fit: BoxFit.fill)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(children: [
|
Row(children: [
|
||||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
Expanded(child: buildEmailPartialContent(
|
||||||
_searchQuery != null &&
|
_presentationEmail,
|
||||||
_searchQuery!.value.isNotEmpty
|
_searchStatus,
|
||||||
? RichTextBuilder(
|
_searchQuery)),
|
||||||
_presentationEmail.getPartialContent(),
|
|
||||||
_searchQuery!.value,
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail),
|
|
||||||
const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail,
|
|
||||||
backgroundColor: AppColor.bgWordSearch)).build()
|
|
||||||
: Text(
|
|
||||||
_presentationEmail.getPartialContent(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail))
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
if (_selectModeAll == SelectMode.INACTIVE)
|
if (_selectModeAll == SelectMode.INACTIVE)
|
||||||
@@ -466,15 +303,16 @@ class EmailTileBuilder {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: !_presentationEmail.hasRead
|
child: !_presentationEmail.hasRead
|
||||||
? SvgPicture.asset(
|
? SvgPicture.asset(
|
||||||
_imagePaths.icUnreadStatus,
|
imagePaths.icUnreadStatus,
|
||||||
width: 9, height: 9,
|
width: 9,
|
||||||
|
height: 9,
|
||||||
fit: BoxFit.fill)
|
fit: BoxFit.fill)
|
||||||
: const SizedBox(width: 9)),
|
: const SizedBox(width: 9)),
|
||||||
buildIconWeb(
|
buildIconWeb(
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
_presentationEmail.hasStarred
|
_presentationEmail.hasStarred
|
||||||
? _imagePaths.icStar
|
? imagePaths.icStar
|
||||||
: _imagePaths.icUnStar,
|
: imagePaths.icUnStar,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
fit: BoxFit.fill),
|
fit: BoxFit.fill),
|
||||||
@@ -500,35 +338,16 @@ class EmailTileBuilder {
|
|||||||
textStyle: const TextStyle(
|
textStyle: const TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Colors.white),
|
color: Colors.white)),
|
||||||
paddingIconSelect: const EdgeInsets.all(5)),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 160,
|
width: 160,
|
||||||
child: _isSearchEnabled
|
child: buildInformationSender(
|
||||||
? RichTextBuilder(
|
_presentationEmail,
|
||||||
_getInformationSender(),
|
mailboxCurrent,
|
||||||
_searchQuery!.value,
|
_searchStatus,
|
||||||
TextStyle(
|
_searchQuery)),
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail(),
|
|
||||||
backgroundColor: AppColor.bgWordSearch)).build()
|
|
||||||
: Text(_getInformationSender(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
fontWeight: _buildFontForReadEmail())),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 24),
|
const SizedBox(width: 24),
|
||||||
Expanded(child: _buildSubjectAndContent()),
|
Expanded(child: _buildSubjectAndContent()),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
@@ -561,8 +380,8 @@ class EmailTileBuilder {
|
|||||||
splashRadius: 10,
|
splashRadius: 10,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
_presentationEmail.hasRead
|
_presentationEmail.hasRead
|
||||||
? _imagePaths.icRead
|
? imagePaths.icRead
|
||||||
: _imagePaths.icUnread,
|
: imagePaths.icUnread,
|
||||||
color: AppColor.colorActionButtonHover,
|
color: AppColor.colorActionButtonHover,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
@@ -584,7 +403,7 @@ class EmailTileBuilder {
|
|||||||
iconPadding: const EdgeInsets.all(5),
|
iconPadding: const EdgeInsets.all(5),
|
||||||
splashRadius: 10,
|
splashRadius: 10,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
_imagePaths.icMove,
|
imagePaths.icMove,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
color: AppColor.colorActionButtonHover,
|
color: AppColor.colorActionButtonHover,
|
||||||
@@ -601,7 +420,7 @@ class EmailTileBuilder {
|
|||||||
iconPadding: const EdgeInsets.all(5),
|
iconPadding: const EdgeInsets.all(5),
|
||||||
splashRadius: 10,
|
splashRadius: 10,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
canDeletePermanently ? _imagePaths.icDeleteComposer : _imagePaths.icDelete,
|
canDeletePermanently ? imagePaths.icDeleteComposer : imagePaths.icDelete,
|
||||||
width: canDeletePermanently ? 14 : 16,
|
width: canDeletePermanently ? 14 : 16,
|
||||||
height: canDeletePermanently ? 14 : 16,
|
height: canDeletePermanently ? 14 : 16,
|
||||||
color: AppColor.colorActionButtonHover,
|
color: AppColor.colorActionButtonHover,
|
||||||
@@ -619,23 +438,23 @@ class EmailTileBuilder {
|
|||||||
buildIconWebHasPosition(
|
buildIconWebHasPosition(
|
||||||
_context,
|
_context,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
_imagePaths.icMore,
|
imagePaths.icMore,
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
color: AppColor.colorActionButtonHover,
|
color: AppColor.colorActionButtonHover,
|
||||||
fit: BoxFit.fill),
|
fit: BoxFit.fill),
|
||||||
tooltip: AppLocalizations.of(_context).more,
|
tooltip: AppLocalizations.of(_context).more,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_responsiveUtils.isMobile(_context)) {
|
if (responsiveUtils.isMobile(_context)) {
|
||||||
_onMoreActionClick?.call(_presentationEmail, null);
|
_onMoreActionClick?.call(_presentationEmail, null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onTapDown: (position) {
|
onTapDown: (position) {
|
||||||
if (!_responsiveUtils.isMobile(_context)) {
|
if (!responsiveUtils.isMobile(_context)) {
|
||||||
_onMoreActionClick?.call(_presentationEmail, position);
|
_onMoreActionClick?.call(_presentationEmail, position);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
if (_responsiveUtils.isDesktop(_context)) const SizedBox(width: 16),
|
if (responsiveUtils.isDesktop(_context)) const SizedBox(width: 16),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,43 +464,17 @@ class EmailTileBuilder {
|
|||||||
|
|
||||||
Widget _buildDateTimeForDesktopScreen() {
|
Widget _buildDateTimeForDesktopScreen() {
|
||||||
return Row(children: [
|
return Row(children: [
|
||||||
if (_hasMailboxLabel)
|
buildMailboxContain(
|
||||||
Container(
|
_searchStatus,
|
||||||
margin: const EdgeInsets.only(left: 8),
|
advancedSearchActivated,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
_presentationEmail),
|
||||||
constraints: const BoxConstraints(maxWidth: 100),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
color: AppColor.backgroundCounterMailboxColor),
|
|
||||||
child: Text(_presentationEmail.mailboxName,
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: AppColor.mailboxTextColor,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
if (_presentationEmail.hasAttachment == true)
|
if (_presentationEmail.hasAttachment == true)
|
||||||
Padding(padding: const EdgeInsets.only(left: 8),
|
Padding(
|
||||||
child: SvgPicture.asset(
|
padding: const EdgeInsets.only(left: 8),
|
||||||
_imagePaths.icAttachment,
|
child: buildIconAttachment()),
|
||||||
width: 16,
|
Padding(
|
||||||
height: 16,
|
padding: const EdgeInsets.only(right: 20, left: 8),
|
||||||
fit: BoxFit.fill)),
|
child: buildDateTime(_context, _presentationEmail))
|
||||||
Padding(padding: const EdgeInsets.only(right: 20, left: 8),
|
|
||||||
child: Text(
|
|
||||||
_presentationEmail
|
|
||||||
.getReceivedAt(Localizations.localeOf(_context)
|
|
||||||
.toLanguageTag()),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail())))
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,163 +483,49 @@ class EmailTileBuilder {
|
|||||||
if (_presentationEmail.hasAttachment == true)
|
if (_presentationEmail.hasAttachment == true)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8),
|
padding: const EdgeInsets.only(left: 8),
|
||||||
child: SvgPicture.asset(
|
child: buildIconAttachment()),
|
||||||
_imagePaths.icAttachment,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
fit: BoxFit.fill)),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 4, left: 8),
|
padding: const EdgeInsets.only(right: 4, left: 8),
|
||||||
child: Text(
|
child: buildDateTime(_context, _presentationEmail)),
|
||||||
_presentationEmail
|
buildIconChevron()
|
||||||
.getReceivedAt(Localizations.localeOf(_context)
|
|
||||||
.toLanguageTag()),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail))),
|
|
||||||
SvgPicture.asset(
|
|
||||||
_imagePaths.icChevron,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
fit: BoxFit.fill)
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSubjectAndContent() {
|
Widget _buildSubjectAndContent() {
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
return Row(children: [
|
return Row(children: [
|
||||||
Container(
|
|
||||||
constraints: BoxConstraints(maxWidth: constraints.maxWidth / 2),
|
|
||||||
child: _isSearchEnabled
|
|
||||||
? RichTextBuilder(
|
|
||||||
_presentationEmail.getEmailTitle(),
|
|
||||||
_searchQuery!.value,
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()),
|
|
||||||
TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
backgroundColor: AppColor.bgWordSearch,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail())).build()
|
|
||||||
: Text(_presentationEmail.getEmailTitle(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _buildTextColorForReadEmail(),
|
|
||||||
fontWeight: _buildFontForReadEmail()))
|
|
||||||
),
|
|
||||||
if (_presentationEmail.getEmailTitle().isNotEmpty)
|
if (_presentationEmail.getEmailTitle().isNotEmpty)
|
||||||
const SizedBox(width: 12),
|
Container(
|
||||||
Expanded(
|
constraints: BoxConstraints(maxWidth: constraints.maxWidth / 2),
|
||||||
child: Container(
|
padding: const EdgeInsets.only(right: 12),
|
||||||
child: _isSearchEnabled
|
child: buildEmailTitle(
|
||||||
? RichTextBuilder(
|
_presentationEmail,
|
||||||
_presentationEmail.getPartialContent(),
|
_searchStatus,
|
||||||
_searchQuery!.value,
|
_searchQuery)),
|
||||||
const TextStyle(
|
Expanded(child: Container(
|
||||||
fontSize: 13,
|
child: buildEmailPartialContent(
|
||||||
color: AppColor.colorContentEmail,
|
_presentationEmail,
|
||||||
fontWeight: FontWeight.normal),
|
_searchStatus,
|
||||||
const TextStyle(
|
_searchQuery))
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail,
|
|
||||||
backgroundColor: AppColor.bgWordSearch)).build()
|
|
||||||
: Text(_presentationEmail.getPartialContent(),
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
|
||||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: AppColor.colorContentEmail,
|
|
||||||
fontWeight: FontWeight.normal))
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAvatarIcon({
|
Widget _buildAvatarIcon({double? iconSize, TextStyle? textStyle}) {
|
||||||
double? iconSize,
|
if (isHoverIcon || _presentationEmail.selectMode == SelectMode.ACTIVE ||
|
||||||
EdgeInsets? paddingIconSelect,
|
(responsiveUtils.isMobile(_context) && _selectModeAll == SelectMode.ACTIVE)) {
|
||||||
TextStyle? textStyle
|
return buildIconAvatarSelection(
|
||||||
}) {
|
_context,
|
||||||
if (isHoverIcon ||
|
_presentationEmail,
|
||||||
_presentationEmail.selectMode == SelectMode.ACTIVE ||
|
iconSize: iconSize ?? 48,
|
||||||
(_responsiveUtils.isMobile(_context) &&
|
textStyle: textStyle);
|
||||||
_selectModeAll == SelectMode.ACTIVE)) {
|
|
||||||
return Container(
|
|
||||||
color: Colors.transparent,
|
|
||||||
width: iconSize ?? 48,
|
|
||||||
height: iconSize ?? 48,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: _responsiveUtils.isDesktop(_context)
|
|
||||||
? const EdgeInsets.symmetric(horizontal: 4)
|
|
||||||
: const EdgeInsets.all(12),
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
_presentationEmail.selectMode == SelectMode.ACTIVE
|
|
||||||
? _imagePaths.icSelected
|
|
||||||
: _imagePaths.icUnSelected,
|
|
||||||
fit: BoxFit.fill),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return Container(
|
return buildIconAvatarText(
|
||||||
width: iconSize ?? 48,
|
_presentationEmail,
|
||||||
height: iconSize ?? 48,
|
iconSize: iconSize ?? 48,
|
||||||
alignment: Alignment.center,
|
textStyle: textStyle);
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular((iconSize ?? 48) * 0.5),
|
|
||||||
border: Border.all(color: Colors.transparent),
|
|
||||||
gradient: LinearGradient(
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter,
|
|
||||||
stops: const [0.0, 1.0],
|
|
||||||
colors: _presentationEmail.avatarColors),
|
|
||||||
color: AppColor.avatarColor
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
_presentationEmail.getAvatarText(),
|
|
||||||
style: textStyle ?? const TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.w500)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FontWeight _buildFontForReadEmail() {
|
|
||||||
return !_presentationEmail.hasRead ? FontWeight.w600 : FontWeight.normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color _buildTextColorForReadEmail() {
|
|
||||||
return _presentationEmail.hasRead
|
|
||||||
? AppColor.colorContentEmail
|
|
||||||
: AppColor.colorNameEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
String _getInformationSender() {
|
|
||||||
if (mailboxCurrent?.isSent == true
|
|
||||||
|| mailboxCurrent?.isDrafts == true
|
|
||||||
|| mailboxCurrent?.isOutbox == true) {
|
|
||||||
return _presentationEmail.recipientsName();
|
|
||||||
}
|
|
||||||
return _presentationEmail.getSenderName();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get _isSearchEnabled => _searchStatus == SearchStatus.ACTIVE
|
|
||||||
&& _searchQuery != null
|
|
||||||
&& _searchQuery!.value.isNotEmpty;
|
|
||||||
|
|
||||||
bool get _hasMailboxLabel {
|
|
||||||
return (_searchStatus == SearchStatus.ACTIVE ||
|
|
||||||
advancedSearchActivated) &&
|
|
||||||
_presentationEmail.mailboxName.isNotEmpty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user