TF-495 Implement linter for thread view

This commit is contained in:
dab246
2022-04-22 09:29:37 +07:00
committed by Dat H. Pham
parent 3b81962c3b
commit d8f236a89c
25 changed files with 419 additions and 434 deletions
@@ -48,14 +48,14 @@ class EmailTileBuilder {
Widget build() {
return Theme(
key: Key('thread_tile'),
key: const Key('thread_tile'),
data: ThemeData(splashColor: Colors.transparent, highlightColor: Colors.transparent),
child: ResponsiveWidget(
responsiveUtils: _responsiveUtils,
mobile: _buildListTile(),
desktop: Container(
margin: _selectModeAll == SelectMode.ACTIVE ? EdgeInsets.only(top: 3, left: 8, right: 8) : EdgeInsets.zero,
padding: _selectModeAll == SelectMode.ACTIVE ? EdgeInsets.symmetric(vertical: 8) : EdgeInsets.zero,
margin: _selectModeAll == SelectMode.ACTIVE ? const EdgeInsets.only(top: 3, left: 8, right: 8) : EdgeInsets.zero,
padding: _selectModeAll == SelectMode.ACTIVE ? const EdgeInsets.symmetric(vertical: 8) : EdgeInsets.zero,
decoration: _selectModeAll == SelectMode.ACTIVE && _presentationEmail.selectMode == SelectMode.ACTIVE
? BoxDecoration(
borderRadius: BorderRadius.circular(14),
@@ -70,7 +70,7 @@ class EmailTileBuilder {
Widget _buildListTile() {
return Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.only(bottom: 10, left: 16, right: 16),
padding: const EdgeInsets.only(bottom: 10, left: 16, right: 16),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(0), color: Colors.white),
alignment: Alignment.center,
child: Column(children: [
@@ -88,39 +88,33 @@ class EmailTileBuilder {
children: [
if (!_presentationEmail.hasRead)
Padding(
padding: EdgeInsets.only(right: 5),
padding: const EdgeInsets.only(right: 5),
child: SvgPicture.asset(_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: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
_searchQuery!.value,
const TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
const TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
: Text(
_getInformationSender(),
maxLines: 1,
overflow:TextOverflow.ellipsis,
style: TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
style: const TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
),
if (_presentationEmail.hasAttachment == true)
Padding(
padding: EdgeInsets.only(left: 8),
child: (ButtonBuilder(_imagePaths.icAttachment)
..paddingIcon(EdgeInsets.zero)
..size(16))
.build()),
padding: const EdgeInsets.only(left: 8),
child: SvgPicture.asset(_imagePaths.icAttachment, width: 16, height: 16, fit: BoxFit.fill)),
Padding(
padding: EdgeInsets.only(right: 4, left: 8),
padding: const EdgeInsets.only(right: 4, left: 8),
child: Text(
'${_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag())}',
_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag()),
maxLines: 1,
overflow:TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail))),
(ButtonBuilder(_imagePaths.icChevron)
..paddingIcon(EdgeInsets.zero)
..size(16))
.build(),
style: const TextStyle(fontSize: 13, color: AppColor.colorContentEmail))),
SvgPicture.asset(_imagePaths.icChevron, width: 16, height: 16, fit: BoxFit.fill),
],
),
subtitle: Transform(
@@ -136,52 +130,49 @@ class EmailTileBuilder {
children: [
Expanded(child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
? RichTextBuilder(
'${_presentationEmail.getEmailTitle()}',
'${_searchQuery!.value}',
TextStyle(fontSize: 13, color: AppColor.colorNameEmail),
TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
_presentationEmail.getEmailTitle(),
_searchQuery!.value,
const TextStyle(fontSize: 13, color: AppColor.colorNameEmail),
const TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
: Text(
'${_presentationEmail.getEmailTitle()}',
_presentationEmail.getEmailTitle(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: AppColor.colorNameEmail))
style: const TextStyle(fontSize: 13, color: AppColor.colorNameEmail))
),
if (_searchStatus == SearchStatus.ACTIVE && _presentationEmail.mailboxName.isNotEmpty)
Container(
margin: EdgeInsets.only(left: 8),
padding: EdgeInsets.only(left: 8, right: 8, top: 3, bottom: 3),
constraints: BoxConstraints(maxWidth: 100),
margin: const EdgeInsets.only(left: 8),
padding: const EdgeInsets.only(left: 8, right: 8, top: 3, bottom: 3),
constraints: const BoxConstraints(maxWidth: 100),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: AppColor.backgroundCounterMailboxColor),
child: Text(
'${_presentationEmail.mailboxName}',
_presentationEmail.mailboxName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
style: const TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
)
),
if (_presentationEmail.hasStarred)
(ButtonBuilder(_imagePaths.icStar)
..paddingIcon(EdgeInsets.zero)
..size(15))
.build(),
SvgPicture.asset(_imagePaths.icStar, width: 15, height: 15, fit: BoxFit.fill)
],
)),
Padding(
padding: EdgeInsets.only(top: 8),
padding: const EdgeInsets.only(top: 8),
child: Row(children: [
Expanded(child: _searchStatus == SearchStatus.ACTIVE && _searchQuery != null && _searchQuery!.value.isNotEmpty
? RichTextBuilder(
'${_presentationEmail.getPartialContent()}',
'${_searchQuery!.value}',
TextStyle(fontSize: 13, color: AppColor.colorContentEmail),
TextStyle(fontSize: 13, color: AppColor.colorContentEmail, backgroundColor: AppColor.bgWordSearch)).build()
_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()}',
_presentationEmail.getPartialContent(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail))
style: const TextStyle(fontSize: 13, color: AppColor.colorContentEmail))
),
])
),
@@ -189,7 +180,7 @@ class EmailTileBuilder {
)
),
),
Padding(
const Padding(
padding: EdgeInsets.only(top: 12, right: 12),
child: Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2)),
]),
@@ -203,11 +194,11 @@ class EmailTileBuilder {
child: Column(children: [
Row(children: [
Container(
padding: EdgeInsets.only(left: 16, right: 16),
padding: const EdgeInsets.only(left: 16, right: 16),
alignment: Alignment.center,
child: !_presentationEmail.hasRead
? SvgPicture.asset(_imagePaths.icUnreadStatus, width: 9, height: 9, fit: BoxFit.fill)
: SizedBox(width: 9)),
: const SizedBox(width: 9)),
buildIconWeb(
icon: SvgPicture.asset(
_presentationEmail.hasStarred ? _imagePaths.icStar : _imagePaths.icUnStar,
@@ -218,61 +209,58 @@ class EmailTileBuilder {
onTap: () => _emailActionClick?.call(
_presentationEmail.hasStarred ? EmailActionType.unMarkAsStarred : EmailActionType.markAsStarred,
_presentationEmail)),
if (_selectModeAll == SelectMode.INACTIVE) SizedBox(width: 8),
if (_selectModeAll == SelectMode.INACTIVE) const SizedBox(width: 8),
GestureDetector(
onTap: () => _emailActionClick?.call(
_selectModeAll == SelectMode.ACTIVE ? EmailActionType.selection : EmailActionType.preview,
_presentationEmail),
child: _buildAvatarIcon(
iconSize: 32,
textStyle: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white),
paddingIconSelect: EdgeInsets.all(5)),
textStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white),
paddingIconSelect: const EdgeInsets.all(5)),
),
if (_selectModeAll == SelectMode.INACTIVE) SizedBox(width: 10),
Container(
if (_selectModeAll == SelectMode.INACTIVE) const SizedBox(width: 10),
SizedBox(
width: 160,
child: _isSearchEnabled
? RichTextBuilder(
_getInformationSender(),
'${_searchQuery!.value}',
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
: Text('${_getInformationSender()}',
_searchQuery!.value,
const TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
const TextStyle(fontSize: 15, color: AppColor.colorNameEmail, backgroundColor: AppColor.bgWordSearch, fontWeight: FontWeight.w600)).build()
: Text(_getInformationSender(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600)),
style: const TextStyle(fontSize: 15, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600)),
),
SizedBox(width: 24),
const SizedBox(width: 24),
Expanded(child: _buildSubjectAndContent()),
SizedBox(width: 16),
const SizedBox(width: 16),
if (_searchStatus == SearchStatus.ACTIVE && _presentationEmail.mailboxName.isNotEmpty)
Container(
margin: EdgeInsets.only(left: 8),
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 3),
constraints: BoxConstraints(maxWidth: 80),
margin: const EdgeInsets.only(left: 8),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
constraints: const BoxConstraints(maxWidth: 80),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppColor.backgroundCounterMailboxColor),
child: Text('${_presentationEmail.mailboxName}',
child: Text(_presentationEmail.mailboxName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
style: const TextStyle(fontSize: 10, color: AppColor.mailboxTextColor, fontWeight: FontWeight.bold),
)
),
if (_presentationEmail.hasAttachment == true)
Padding(padding: EdgeInsets.only(left: 8),
child: (ButtonBuilder(_imagePaths.icAttachment)
..paddingIcon(EdgeInsets.zero)
..size(16))
.build()),
Padding(padding: const EdgeInsets.only(left: 8),
child: SvgPicture.asset(_imagePaths.icAttachment, width: 16, height: 16, fit: BoxFit.fill)),
Padding(
padding: EdgeInsets.only(right: 20, left: 8),
child: Text('${_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag())}',
padding: const EdgeInsets.only(right: 20, left: 8),
child: Text(_presentationEmail.getReceivedAt(Localizations.localeOf(_context).toLanguageTag()),
maxLines: 1,
textAlign: TextAlign.right,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal))),
style: const TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal))),
]),
if (_selectModeAll == SelectMode.INACTIVE)
Padding(
const Padding(
padding: EdgeInsets.only(top: 7.5, bottom: 7.5, left: 70),
child: Divider(color: AppColor.lineItemListColor, height: 1, thickness: 0.2)),
]),
@@ -286,28 +274,28 @@ class EmailTileBuilder {
constraints: BoxConstraints(maxWidth: constraints.maxWidth / 2),
child: _isSearchEnabled
? RichTextBuilder(
'${_presentationEmail.getEmailTitle()}',
'${_searchQuery!.value}',
TextStyle(fontSize: 13, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
: Text('${_presentationEmail.getEmailTitle()}',
_presentationEmail.getEmailTitle(),
_searchQuery!.value,
const TextStyle(fontSize: 13, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600),
const TextStyle(fontSize: 13, backgroundColor: AppColor.bgWordSearch, color: AppColor.colorNameEmail)).build()
: Text(_presentationEmail.getEmailTitle(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
style: const TextStyle(fontSize: 13, color: AppColor.colorNameEmail, fontWeight: FontWeight.w600))
),
if (_presentationEmail.getEmailTitle().isNotEmpty) SizedBox(width: 12),
if (_presentationEmail.getEmailTitle().isNotEmpty) const SizedBox(width: 12),
Expanded(
child: Container(
child: _isSearchEnabled
? RichTextBuilder(
'${_presentationEmail.getPartialContent()}',
'${_searchQuery!.value}',
TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal),
TextStyle(fontSize: 13, color: AppColor.colorContentEmail, backgroundColor: AppColor.bgWordSearch)).build()
: Text('${_presentationEmail.getPartialContent()}',
_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,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal))
style: const TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.normal))
)
),
]);
@@ -322,17 +310,29 @@ class EmailTileBuilder {
if (_selectModeAll == SelectMode.ACTIVE) {
return Tooltip(
child: Padding(
padding: EdgeInsets.all(12),
padding: const EdgeInsets.all(12),
child: SvgPicture.asset(_presentationEmail.selectMode == SelectMode.ACTIVE ? _imagePaths.icSelected : _imagePaths.icUnSelected, fit: BoxFit.fill)),
message: AppLocalizations.of(_context).select);
} else {
return (AvatarBuilder()
..text('${_presentationEmail.getAvatarText()}')
..size(iconSize ?? 56)
..textColor(Colors.white)
..addTextStyle(textStyle)
..avatarColor(_presentationEmail.avatarColors))
.build();
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)
)
);
}
}
@@ -340,9 +340,9 @@ class EmailTileBuilder {
if (_mailboxRole == PresentationMailbox.roleSent
|| _mailboxRole == PresentationMailbox.roleDrafts
|| _mailboxRole == PresentationMailbox.roleOutbox) {
return '${_presentationEmail.recipientsName()}';
return _presentationEmail.recipientsName();
}
return '${_presentationEmail.getSenderName()}';
return _presentationEmail.getSenderName();
}
bool get _isSearchEnabled => _searchStatus == SearchStatus.ACTIVE