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:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.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/presentation/mixin/base_email_item_tile.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?);
|
||||
|
||||
class EmailTileBuilder {
|
||||
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
class EmailTileBuilder with BaseEmailItemTile {
|
||||
|
||||
final PresentationEmail _presentationEmail;
|
||||
final BuildContext _context;
|
||||
@@ -20,6 +15,8 @@ class EmailTileBuilder {
|
||||
final SearchStatus _searchStatus;
|
||||
final SearchQuery? _searchQuery;
|
||||
final bool advancedSearchActivated;
|
||||
final EdgeInsets? padding;
|
||||
final EdgeInsets? paddingDivider;
|
||||
|
||||
OnPressEmailActionClick? _emailActionClick;
|
||||
|
||||
@@ -30,8 +27,10 @@ class EmailTileBuilder {
|
||||
this._searchStatus,
|
||||
this._searchQuery,
|
||||
{
|
||||
this.mailboxCurrent,
|
||||
this.advancedSearchActivated = false,
|
||||
this.mailboxCurrent,
|
||||
this.padding,
|
||||
this.paddingDivider,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -47,7 +46,7 @@ class EmailTileBuilder {
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
||||
contentPadding: padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
||||
onTap: () => _emailActionClick?.call(
|
||||
EmailActionType.preview,
|
||||
_presentationEmail),
|
||||
@@ -73,60 +72,23 @@ class EmailTileBuilder {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icUnreadStatus,
|
||||
imagePaths.icUnreadStatus,
|
||||
width: 9,
|
||||
height: 9,
|
||||
fit: BoxFit.fill)),
|
||||
Expanded(
|
||||
child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_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()))
|
||||
),
|
||||
Expanded(child: buildInformationSender(
|
||||
_presentationEmail,
|
||||
mailboxCurrent,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icAttachment,
|
||||
width: 16,
|
||||
height: 16,
|
||||
fit: BoxFit.fill)),
|
||||
child: buildIconAttachment()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 4, left: 8),
|
||||
child: Text(
|
||||
_presentationEmail
|
||||
.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),
|
||||
child: buildDateTime(_context, _presentationEmail)),
|
||||
buildIconChevron(),
|
||||
],
|
||||
),
|
||||
subtitle: Column(
|
||||
@@ -138,158 +100,49 @@ class EmailTileBuilder {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? 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,
|
||||
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),
|
||||
)
|
||||
),
|
||||
Expanded(child: buildEmailTitle(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
buildMailboxContain(
|
||||
_searchStatus,
|
||||
advancedSearchActivated,
|
||||
_presentationEmail),
|
||||
if (_presentationEmail.hasStarred)
|
||||
SvgPicture.asset(
|
||||
_imagePaths.icStar,
|
||||
width: 15,
|
||||
height: 15,
|
||||
fit: BoxFit.fill)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: buildIconStar(),
|
||||
)
|
||||
],
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Row(children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_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))
|
||||
),
|
||||
Expanded(child: buildEmailPartialContent(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
])
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Divider(
|
||||
color: AppColor.lineItemListColor,
|
||||
height: 1,
|
||||
thickness: 0.2)),
|
||||
Padding(
|
||||
padding: paddingDivider ?? const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: const Divider(
|
||||
color: AppColor.lineItemListColor,
|
||||
height: 1,
|
||||
thickness: 0.2)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvatarIcon({
|
||||
double? iconSize,
|
||||
TextStyle? textStyle
|
||||
}) {
|
||||
Widget _buildAvatarIcon() {
|
||||
if (_selectModeAll == SelectMode.ACTIVE) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: SvgPicture.asset(
|
||||
_presentationEmail.selectMode == SelectMode.ACTIVE
|
||||
? _imagePaths.icSelected
|
||||
: _imagePaths.icUnSelected,
|
||||
width: 24, height: 24));
|
||||
return buildIconAvatarSelection(_context, _presentationEmail);
|
||||
} else {
|
||||
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: _presentationEmail.avatarColors),
|
||||
color: AppColor.avatarColor
|
||||
),
|
||||
child: Text(
|
||||
_presentationEmail.getAvatarText(),
|
||||
style: textStyle ?? const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w500)
|
||||
)
|
||||
);
|
||||
return buildIconAvatarText(_presentationEmail);
|
||||
}
|
||||
}
|
||||
|
||||
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:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.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/presentation/mixin/base_email_item_tile.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
typedef OnPressEmailActionClick = void Function(EmailActionType, PresentationEmail);
|
||||
typedef OnMoreActionClick = void Function(PresentationEmail, RelativeRect?);
|
||||
|
||||
class EmailTileBuilder {
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
class EmailTileBuilder with BaseEmailItemTile {
|
||||
|
||||
final PresentationEmail _presentationEmail;
|
||||
final BuildContext _context;
|
||||
@@ -23,6 +17,8 @@ class EmailTileBuilder {
|
||||
final SearchStatus _searchStatus;
|
||||
final SearchQuery? _searchQuery;
|
||||
final bool advancedSearchActivated;
|
||||
final EdgeInsets? padding;
|
||||
final EdgeInsets? paddingDivider;
|
||||
|
||||
OnPressEmailActionClick? _emailActionClick;
|
||||
OnMoreActionClick? _onMoreActionClick;
|
||||
@@ -37,8 +33,10 @@ class EmailTileBuilder {
|
||||
this._searchStatus,
|
||||
this._searchQuery,
|
||||
{
|
||||
this.advancedSearchActivated = false,
|
||||
this.mailboxCurrent,
|
||||
this.advancedSearchActivated = false
|
||||
this.padding,
|
||||
this.paddingDivider,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -59,16 +57,20 @@ class EmailTileBuilder {
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return ResponsiveWidget(
|
||||
responsiveUtils: _responsiveUtils,
|
||||
mobile: _wrapContainerForTile(_buildListTile()),
|
||||
tablet: _wrapContainerForTile(_buildListTileTablet()),
|
||||
desktop: _wrapContainerForTile(_buildListTileForDesktop()),
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
padding: padding,
|
||||
child: ResponsiveWidget(
|
||||
responsiveUtils: responsiveUtils,
|
||||
mobile: _wrapContainerForTile(_buildListTile()),
|
||||
tablet: _wrapContainerForTile(_buildListTileTablet()),
|
||||
desktop: _wrapContainerForTile(_buildListTileForDesktop()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _wrapContainerForTile(Widget tile) {
|
||||
if (_responsiveUtils.isDesktop(_context)) {
|
||||
if (responsiveUtils.isDesktop(_context)) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(top: 3),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
@@ -126,142 +128,53 @@ class EmailTileBuilder {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icUnreadStatus,
|
||||
imagePaths.icUnreadStatus,
|
||||
width: 9,
|
||||
height: 9,
|
||||
fit: BoxFit.fill)),
|
||||
Expanded(
|
||||
child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_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()))
|
||||
),
|
||||
Expanded(child: buildInformationSender(
|
||||
_presentationEmail,
|
||||
mailboxCurrent,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icAttachment,
|
||||
imagePaths.icAttachment,
|
||||
width: 16,
|
||||
height: 16,
|
||||
fit: BoxFit.fill)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 4, left: 8),
|
||||
child: Text(
|
||||
_presentationEmail
|
||||
.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)
|
||||
child: buildDateTime(_context, _presentationEmail)),
|
||||
buildIconChevron()
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_presentationEmail.getEmailTitle(),
|
||||
_searchQuery!.value,
|
||||
TextStyle(
|
||||
fontSize: 13,
|
||||
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),
|
||||
)
|
||||
),
|
||||
Expanded(child: buildEmailTitle(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
buildMailboxContain(
|
||||
_searchStatus,
|
||||
advancedSearchActivated,
|
||||
_presentationEmail),
|
||||
if (_presentationEmail.hasStarred)
|
||||
SvgPicture.asset(
|
||||
_imagePaths.icStar,
|
||||
width: 15,
|
||||
height: 15,
|
||||
fit: BoxFit.fill),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: buildIconStar(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_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))
|
||||
),
|
||||
Expanded(child: buildEmailPartialContent(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
@@ -308,36 +221,15 @@ class EmailTileBuilder {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icUnreadStatus,
|
||||
imagePaths.icUnreadStatus,
|
||||
width: 9,
|
||||
height: 9,
|
||||
fit: BoxFit.fill)),
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_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()))
|
||||
),
|
||||
Expanded(child: buildInformationSender(
|
||||
_presentationEmail,
|
||||
mailboxCurrent,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
if (isHoverItem)
|
||||
const SizedBox(width: 120)
|
||||
else
|
||||
@@ -347,82 +239,27 @@ class EmailTileBuilder {
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_presentationEmail.getEmailTitle(),
|
||||
_searchQuery!.value,
|
||||
TextStyle(
|
||||
fontSize: 13,
|
||||
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),
|
||||
)
|
||||
),
|
||||
Expanded(child: buildEmailTitle(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
buildMailboxContain(
|
||||
_searchStatus,
|
||||
advancedSearchActivated,
|
||||
_presentationEmail),
|
||||
if (_presentationEmail.hasStarred)
|
||||
SvgPicture.asset(
|
||||
_imagePaths.icStar,
|
||||
width: 15,
|
||||
height: 15,
|
||||
fit: BoxFit.fill)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: buildIconStar(),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(children: [
|
||||
Expanded(child: _searchStatus == SearchStatus.ACTIVE &&
|
||||
_searchQuery != null &&
|
||||
_searchQuery!.value.isNotEmpty
|
||||
? RichTextBuilder(
|
||||
_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))
|
||||
),
|
||||
Expanded(child: buildEmailPartialContent(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
]),
|
||||
]),
|
||||
if (_selectModeAll == SelectMode.INACTIVE)
|
||||
@@ -466,15 +303,16 @@ class EmailTileBuilder {
|
||||
alignment: Alignment.center,
|
||||
child: !_presentationEmail.hasRead
|
||||
? SvgPicture.asset(
|
||||
_imagePaths.icUnreadStatus,
|
||||
width: 9, height: 9,
|
||||
imagePaths.icUnreadStatus,
|
||||
width: 9,
|
||||
height: 9,
|
||||
fit: BoxFit.fill)
|
||||
: const SizedBox(width: 9)),
|
||||
buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_presentationEmail.hasStarred
|
||||
? _imagePaths.icStar
|
||||
: _imagePaths.icUnStar,
|
||||
? imagePaths.icStar
|
||||
: imagePaths.icUnStar,
|
||||
width: 16,
|
||||
height: 16,
|
||||
fit: BoxFit.fill),
|
||||
@@ -500,35 +338,16 @@ class EmailTileBuilder {
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white),
|
||||
paddingIconSelect: const EdgeInsets.all(5)),
|
||||
color: Colors.white)),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
SizedBox(
|
||||
width: 160,
|
||||
child: _isSearchEnabled
|
||||
? RichTextBuilder(
|
||||
_getInformationSender(),
|
||||
_searchQuery!.value,
|
||||
TextStyle(
|
||||
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())),
|
||||
),
|
||||
child: buildInformationSender(
|
||||
_presentationEmail,
|
||||
mailboxCurrent,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
const SizedBox(width: 24),
|
||||
Expanded(child: _buildSubjectAndContent()),
|
||||
const SizedBox(width: 16),
|
||||
@@ -561,8 +380,8 @@ class EmailTileBuilder {
|
||||
splashRadius: 10,
|
||||
icon: SvgPicture.asset(
|
||||
_presentationEmail.hasRead
|
||||
? _imagePaths.icRead
|
||||
: _imagePaths.icUnread,
|
||||
? imagePaths.icRead
|
||||
: imagePaths.icUnread,
|
||||
color: AppColor.colorActionButtonHover,
|
||||
width: 16,
|
||||
height: 16,
|
||||
@@ -584,7 +403,7 @@ class EmailTileBuilder {
|
||||
iconPadding: const EdgeInsets.all(5),
|
||||
splashRadius: 10,
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icMove,
|
||||
imagePaths.icMove,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: AppColor.colorActionButtonHover,
|
||||
@@ -601,7 +420,7 @@ class EmailTileBuilder {
|
||||
iconPadding: const EdgeInsets.all(5),
|
||||
splashRadius: 10,
|
||||
icon: SvgPicture.asset(
|
||||
canDeletePermanently ? _imagePaths.icDeleteComposer : _imagePaths.icDelete,
|
||||
canDeletePermanently ? imagePaths.icDeleteComposer : imagePaths.icDelete,
|
||||
width: canDeletePermanently ? 14 : 16,
|
||||
height: canDeletePermanently ? 14 : 16,
|
||||
color: AppColor.colorActionButtonHover,
|
||||
@@ -619,23 +438,23 @@ class EmailTileBuilder {
|
||||
buildIconWebHasPosition(
|
||||
_context,
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icMore,
|
||||
imagePaths.icMore,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: AppColor.colorActionButtonHover,
|
||||
fit: BoxFit.fill),
|
||||
tooltip: AppLocalizations.of(_context).more,
|
||||
onTap: () {
|
||||
if (_responsiveUtils.isMobile(_context)) {
|
||||
if (responsiveUtils.isMobile(_context)) {
|
||||
_onMoreActionClick?.call(_presentationEmail, null);
|
||||
}
|
||||
},
|
||||
onTapDown: (position) {
|
||||
if (!_responsiveUtils.isMobile(_context)) {
|
||||
if (!responsiveUtils.isMobile(_context)) {
|
||||
_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() {
|
||||
return Row(children: [
|
||||
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),
|
||||
)
|
||||
),
|
||||
buildMailboxContain(
|
||||
_searchStatus,
|
||||
advancedSearchActivated,
|
||||
_presentationEmail),
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(padding: const EdgeInsets.only(left: 8),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icAttachment,
|
||||
width: 16,
|
||||
height: 16,
|
||||
fit: BoxFit.fill)),
|
||||
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())))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: buildIconAttachment()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20, left: 8),
|
||||
child: buildDateTime(_context, _presentationEmail))
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -690,163 +483,49 @@ class EmailTileBuilder {
|
||||
if (_presentationEmail.hasAttachment == true)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icAttachment,
|
||||
width: 16,
|
||||
height: 16,
|
||||
fit: BoxFit.fill)),
|
||||
child: buildIconAttachment()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 4, left: 8),
|
||||
child: Text(
|
||||
_presentationEmail
|
||||
.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)
|
||||
child: buildDateTime(_context, _presentationEmail)),
|
||||
buildIconChevron()
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildSubjectAndContent() {
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
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)
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: _isSearchEnabled
|
||||
? RichTextBuilder(
|
||||
_presentationEmail.getPartialContent(),
|
||||
_searchQuery!.value,
|
||||
const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColor.colorContentEmail,
|
||||
fontWeight: FontWeight.normal),
|
||||
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,
|
||||
fontWeight: FontWeight.normal))
|
||||
)
|
||||
Container(
|
||||
constraints: BoxConstraints(maxWidth: constraints.maxWidth / 2),
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: buildEmailTitle(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery)),
|
||||
Expanded(child: Container(
|
||||
child: buildEmailPartialContent(
|
||||
_presentationEmail,
|
||||
_searchStatus,
|
||||
_searchQuery))
|
||||
),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildAvatarIcon({
|
||||
double? iconSize,
|
||||
EdgeInsets? paddingIconSelect,
|
||||
TextStyle? textStyle
|
||||
}) {
|
||||
if (isHoverIcon ||
|
||||
_presentationEmail.selectMode == SelectMode.ACTIVE ||
|
||||
(_responsiveUtils.isMobile(_context) &&
|
||||
_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),
|
||||
);
|
||||
Widget _buildAvatarIcon({double? iconSize, TextStyle? textStyle}) {
|
||||
if (isHoverIcon || _presentationEmail.selectMode == SelectMode.ACTIVE ||
|
||||
(responsiveUtils.isMobile(_context) && _selectModeAll == SelectMode.ACTIVE)) {
|
||||
return buildIconAvatarSelection(
|
||||
_context,
|
||||
_presentationEmail,
|
||||
iconSize: iconSize ?? 48,
|
||||
textStyle: textStyle);
|
||||
} else {
|
||||
return Container(
|
||||
width: iconSize ?? 48,
|
||||
height: iconSize ?? 48,
|
||||
alignment: Alignment.center,
|
||||
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)
|
||||
)
|
||||
);
|
||||
return buildIconAvatarText(
|
||||
_presentationEmail,
|
||||
iconSize: iconSize ?? 48,
|
||||
textStyle: textStyle);
|
||||
}
|
||||
}
|
||||
|
||||
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