TF-248 Change avatar of item list email
This commit is contained in:
@@ -61,5 +61,14 @@ extension AppColor on Color {
|
|||||||
static const backgroundCountAttachment = Color(0x681C1C1C);
|
static const backgroundCountAttachment = Color(0x681C1C1C);
|
||||||
static const bgStatusResultSearch = Color(0xFFF5F5F7);
|
static const bgStatusResultSearch = Color(0xFFF5F5F7);
|
||||||
static const bgWordSearch = Color(0xFFD7D6FC);
|
static const bgWordSearch = Color(0xFFD7D6FC);
|
||||||
|
|
||||||
|
static const mapGradientColor = [
|
||||||
|
[Color(0xFF21D4FD), Color(0xFFB721FF)],
|
||||||
|
[Color(0xFF43E97B), Color(0xFF38F9D7)],
|
||||||
|
[Color(0xFF11E6F0), Color(0xFF4FACFE)],
|
||||||
|
[Color(0xFFE88395), Color(0xFFEF9C8F)],
|
||||||
|
[Color(0xFF8DDAD5), Color(0xFF00CDAC)],
|
||||||
|
[Color(0xFFDE9AF5), Color(0xFFD670EE)],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,21 +10,20 @@ class AvatarBuilder {
|
|||||||
double? _size;
|
double? _size;
|
||||||
// String? _iconStatus;
|
// String? _iconStatus;
|
||||||
Color? _bgColor;
|
Color? _bgColor;
|
||||||
|
Color? _textColor;
|
||||||
OnTapAvatarActionClick? _onTapAvatarActionClick;
|
OnTapAvatarActionClick? _onTapAvatarActionClick;
|
||||||
|
List<Color>? _avatarColors;
|
||||||
|
|
||||||
AvatarBuilder key(Key key) {
|
void key(Key key) {
|
||||||
_key = key;
|
_key = key;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarBuilder size(double size) {
|
void size(double size) {
|
||||||
_size = size;
|
_size = size;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarBuilder text(String text) {
|
void text(String text) {
|
||||||
_text = text;
|
_text = text;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvatarBuilder iconStatus(String iconStatus) {
|
// AvatarBuilder iconStatus(String iconStatus) {
|
||||||
@@ -32,14 +31,20 @@ class AvatarBuilder {
|
|||||||
// return this;
|
// return this;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
AvatarBuilder backgroundColor(Color bgColor) {
|
void backgroundColor(Color bgColor) {
|
||||||
_bgColor = bgColor;
|
_bgColor = bgColor;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarBuilder addOnTapActionClick(OnTapAvatarActionClick onTapAvatarActionClick) {
|
void textColor(Color textColor) {
|
||||||
|
_textColor = textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void avatarColor(List<Color>? avatarColors) {
|
||||||
|
_avatarColors = avatarColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addOnTapActionClick(OnTapAvatarActionClick onTapAvatarActionClick) {
|
||||||
_onTapAvatarActionClick = onTapAvatarActionClick;
|
_onTapAvatarActionClick = onTapAvatarActionClick;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget build() {
|
Widget build() {
|
||||||
@@ -61,11 +66,17 @@ class AvatarBuilder {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular((_size ?? 40) / 2),
|
borderRadius: BorderRadius.circular((_size ?? 40) / 2),
|
||||||
border: Border.all(color: Colors.white),
|
border: Border.all(color: Colors.transparent),
|
||||||
|
gradient: _avatarColors?.isNotEmpty == true
|
||||||
|
? LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: _avatarColors ?? [])
|
||||||
|
: null,
|
||||||
color: _bgColor ?? AppColor.avatarColor),
|
color: _bgColor ?? AppColor.avatarColor),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${_text ?? ''}',
|
'${_text ?? ''}',
|
||||||
style: TextStyle(fontSize: 20, color: AppColor.avatarTextColor, fontWeight: FontWeight.w500))),
|
style: TextStyle(fontSize: 20, color: _textColor ?? AppColor.avatarTextColor, fontWeight: FontWeight.w500))),
|
||||||
// if (_iconStatus != null && _iconStatus!.isNotEmpty)
|
// if (_iconStatus != null && _iconStatus!.isNotEmpty)
|
||||||
// Align(
|
// Align(
|
||||||
// child: SvgPicture.asset(_iconStatus!, width: 12, height: 12, fit: BoxFit.fill),
|
// child: SvgPicture.asset(_iconStatus!, width: 12, height: 12, fit: BoxFit.fill),
|
||||||
|
|||||||
+3
-3
@@ -45,9 +45,9 @@ class SenderAndReceiverInformationTileBuilder {
|
|||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Transform(
|
leading: Transform(
|
||||||
transform: Matrix4.translationValues(-15.0, -8.0, 0.0),
|
transform: Matrix4.translationValues(-15.0, -8.0, 0.0),
|
||||||
child: AvatarBuilder()
|
child: (AvatarBuilder()
|
||||||
.text('${_presentationEmail!.getAvatarText()}')
|
..text('${_presentationEmail!.getAvatarText()}')
|
||||||
.size(40)
|
..size(40))
|
||||||
// .iconStatus(_imagePaths.icOffline)
|
// .iconStatus(_imagePaths.icOffline)
|
||||||
.build()),
|
.build()),
|
||||||
title: Transform(
|
title: Transform(
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ class UserInformationWidgetBuilder {
|
|||||||
_onOpenUserInformationActionClick!();
|
_onOpenUserInformationActionClick!();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leading: AvatarBuilder()
|
leading: (AvatarBuilder()
|
||||||
.text(_userProfile != null ? _userProfile!.getAvatarText() : '')
|
..text(_userProfile != null ? _userProfile!.getAvatarText() : '')
|
||||||
.size(40)
|
..size(40))
|
||||||
.build(),
|
.build(),
|
||||||
title: Transform(
|
title: Transform(
|
||||||
transform: Matrix4.translationValues(0.0, 0.0, 0.0),
|
transform: Matrix4.translationValues(0.0, 0.0, 0.0),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
@@ -63,6 +65,8 @@ class ThreadController extends BaseController {
|
|||||||
final emailListSearch = <PresentationEmail>[].obs;
|
final emailListSearch = <PresentationEmail>[].obs;
|
||||||
final currentSelectMode = SelectMode.INACTIVE.obs;
|
final currentSelectMode = SelectMode.INACTIVE.obs;
|
||||||
|
|
||||||
|
final random = Random();
|
||||||
|
|
||||||
bool canLoadMore = true;
|
bool canLoadMore = true;
|
||||||
bool canSearchMore = true;
|
bool canSearchMore = true;
|
||||||
MailboxId? _currentMailboxId;
|
MailboxId? _currentMailboxId;
|
||||||
@@ -207,7 +211,10 @@ class ThreadController extends BaseController {
|
|||||||
|
|
||||||
void _getAllEmailSuccess(GetAllEmailSuccess success) {
|
void _getAllEmailSuccess(GetAllEmailSuccess success) {
|
||||||
_currentEmailState = success.currentEmailState;
|
_currentEmailState = success.currentEmailState;
|
||||||
emailList.value = success.emailList;
|
final listEmailHaveAvatarGradientColor = success.emailList
|
||||||
|
.map((email) => email.asAvatarGradientColor(random))
|
||||||
|
.toList();
|
||||||
|
emailList.value = listEmailHaveAvatarGradientColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getAllEmailAction(AccountId accountId, {MailboxId? mailboxId}) {
|
void _getAllEmailAction(AccountId accountId, {MailboxId? mailboxId}) {
|
||||||
@@ -271,7 +278,10 @@ class ThreadController extends BaseController {
|
|||||||
|
|
||||||
void _loadMoreEmailsSuccess(LoadMoreEmailsSuccess success) {
|
void _loadMoreEmailsSuccess(LoadMoreEmailsSuccess success) {
|
||||||
if (success.emailList.isNotEmpty) {
|
if (success.emailList.isNotEmpty) {
|
||||||
emailList.addAll(success.emailList);
|
final listEmailHaveAvatarGradientColor = success.emailList
|
||||||
|
.map((email) => email.asAvatarGradientColor(random))
|
||||||
|
.toList();
|
||||||
|
emailList.addAll(listEmailHaveAvatarGradientColor);
|
||||||
} else {
|
} else {
|
||||||
canLoadMore = false;
|
canLoadMore = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ class AppBarThreadWidgetBuilder {
|
|||||||
}},
|
}},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
child: AvatarBuilder()
|
child: (AvatarBuilder()
|
||||||
.text(_userProfile != null ? _userProfile!.getAvatarText() : '')
|
..text(_userProfile != null ? _userProfile!.getAvatarText() : '')
|
||||||
.size(36)
|
..size(36))
|
||||||
.build()));
|
.build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class EmailTileBuilder {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
leading: Transform(
|
leading: Transform(
|
||||||
transform: Matrix4.translationValues(-10.0, -10.0, 0.0),
|
transform: Matrix4.translationValues(-10.0, -2.0, 0.0),
|
||||||
child: _buildAvatarIcon()),
|
child: _buildAvatarIcon()),
|
||||||
title: Transform(
|
title: Transform(
|
||||||
transform: Matrix4.translationValues(-10.0, 0.0, 0.0),
|
transform: Matrix4.translationValues(-10.0, 0.0, 0.0),
|
||||||
@@ -216,7 +216,7 @@ class EmailTileBuilder {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAvatarIcon () {
|
Widget _buildAvatarIcon() {
|
||||||
if (_selectModeAll == SelectMode.ACTIVE) {
|
if (_selectModeAll == SelectMode.ACTIVE) {
|
||||||
return AnimatedSwitcher(
|
return AnimatedSwitcher(
|
||||||
duration: Duration(milliseconds: 600),
|
duration: Duration(milliseconds: 600),
|
||||||
@@ -228,20 +228,24 @@ class EmailTileBuilder {
|
|||||||
_onSelectEmailActionClick!(_presentationEmail);
|
_onSelectEmailActionClick!(_presentationEmail);
|
||||||
}}))
|
}}))
|
||||||
.build()
|
.build()
|
||||||
: AvatarBuilder()
|
: (AvatarBuilder()
|
||||||
.text('${_presentationEmail.getAvatarText()}')
|
..text('${_presentationEmail.getAvatarText()}')
|
||||||
.size(40)
|
..size(56)
|
||||||
// .iconStatus(_imagePaths.icOffline)
|
..textColor(Colors.white)
|
||||||
.addOnTapActionClick(() {
|
..avatarColor(_presentationEmail.avatarColors)
|
||||||
if (_selectModeAll == SelectMode.ACTIVE && _onSelectEmailActionClick != null) {
|
// .iconStatus(_imagePaths.icOffline)
|
||||||
_onSelectEmailActionClick!(_presentationEmail);
|
..addOnTapActionClick(() {
|
||||||
}})
|
if (_selectModeAll == SelectMode.ACTIVE && _onSelectEmailActionClick != null) {
|
||||||
|
_onSelectEmailActionClick!(_presentationEmail);
|
||||||
|
}}))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return AvatarBuilder()
|
return (AvatarBuilder()
|
||||||
.text('${_presentationEmail.getAvatarText()}')
|
..text('${_presentationEmail.getAvatarText()}')
|
||||||
.size(40)
|
..size(56)
|
||||||
|
..textColor(Colors.white)
|
||||||
|
..avatarColor(_presentationEmail.avatarColors))
|
||||||
// .iconStatus(_imagePaths.icOffline)
|
// .iconStatus(_imagePaths.icOffline)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||||
@@ -26,6 +28,7 @@ class PresentationEmail with EquatableMixin {
|
|||||||
final Map<MailboxId, bool>? mailboxIds;
|
final Map<MailboxId, bool>? mailboxIds;
|
||||||
final List<MailboxName?>? mailboxNames;
|
final List<MailboxName?>? mailboxNames;
|
||||||
final SelectMode selectMode;
|
final SelectMode selectMode;
|
||||||
|
final List<Color>? avatarColors;
|
||||||
|
|
||||||
PresentationEmail(
|
PresentationEmail(
|
||||||
this.id,
|
this.id,
|
||||||
@@ -44,7 +47,8 @@ class PresentationEmail with EquatableMixin {
|
|||||||
this.replyTo,
|
this.replyTo,
|
||||||
this.mailboxIds,
|
this.mailboxIds,
|
||||||
this.mailboxNames,
|
this.mailboxNames,
|
||||||
this.selectMode = SelectMode.INACTIVE
|
this.selectMode = SelectMode.INACTIVE,
|
||||||
|
this.avatarColors,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -52,9 +56,26 @@ class PresentationEmail with EquatableMixin {
|
|||||||
|
|
||||||
String getAvatarText() {
|
String getAvatarText() {
|
||||||
if (getSenderName().isNotEmpty) {
|
if (getSenderName().isNotEmpty) {
|
||||||
final regexLetter = RegExp("([A-Za-z])");
|
final listWord = getSenderName().split(' ');
|
||||||
final firstLetter = regexLetter.firstMatch(getSenderName().trim())?.group(0);
|
if (listWord.length > 1) {
|
||||||
return firstLetter != null ? firstLetter.toUpperCase() : '';
|
final regexLetter = RegExp("([A-Za-z])");
|
||||||
|
final firstLetterOfFirstWord = regexLetter.firstMatch(listWord[0].trim())?.group(0);
|
||||||
|
final firstLetterOfSecondWord = regexLetter.firstMatch(listWord[1].trim())?.group(0);
|
||||||
|
|
||||||
|
if (firstLetterOfFirstWord != null && firstLetterOfSecondWord != null) {
|
||||||
|
return '${firstLetterOfFirstWord.toUpperCase()}${firstLetterOfSecondWord.toUpperCase()}';
|
||||||
|
} else if (firstLetterOfFirstWord != null && firstLetterOfSecondWord == null) {
|
||||||
|
return '${firstLetterOfFirstWord.toUpperCase()}${firstLetterOfFirstWord.toUpperCase()}';
|
||||||
|
} else if (firstLetterOfFirstWord == null && firstLetterOfSecondWord != null) {
|
||||||
|
return '${firstLetterOfSecondWord.toUpperCase()}${firstLetterOfSecondWord.toUpperCase()}';
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
final regexLetter = RegExp("([A-Za-z])");
|
||||||
|
final firstLetter = regexLetter.firstMatch(getSenderName().trim())?.group(0);
|
||||||
|
return firstLetter != null ? '${firstLetter.toUpperCase()}${firstLetter.toUpperCase()}' : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
@@ -136,7 +138,32 @@ extension PresentationEmailExtension on PresentationEmail {
|
|||||||
replyTo: replyTo,
|
replyTo: replyTo,
|
||||||
mailboxIds: mailboxIds,
|
mailboxIds: mailboxIds,
|
||||||
mailboxNames: listMailboxName,
|
mailboxNames: listMailboxName,
|
||||||
selectMode: selectMode
|
selectMode: selectMode,
|
||||||
|
avatarColors: avatarColors
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PresentationEmail asAvatarGradientColor(Random random) {
|
||||||
|
final newAvatarColors = AppColor.mapGradientColor[random.nextInt(AppColor.mapGradientColor.length)];
|
||||||
|
|
||||||
|
return PresentationEmail(
|
||||||
|
this.id,
|
||||||
|
keywords: keywords,
|
||||||
|
size: size,
|
||||||
|
receivedAt: receivedAt,
|
||||||
|
hasAttachment: hasAttachment,
|
||||||
|
preview: preview,
|
||||||
|
subject: subject,
|
||||||
|
sentAt: sentAt,
|
||||||
|
from: from,
|
||||||
|
to: to,
|
||||||
|
cc: cc,
|
||||||
|
bcc: bcc,
|
||||||
|
replyTo: replyTo,
|
||||||
|
mailboxIds: mailboxIds,
|
||||||
|
mailboxNames: mailboxNames,
|
||||||
|
selectMode: selectMode,
|
||||||
|
avatarColors: avatarColors ?? newAvatarColors,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user