TF-313 Apply new ui for subject, address, body EmailView
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
enum PrefixEmailAddress {
|
||||
from,
|
||||
to,
|
||||
cc,
|
||||
bcc
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/email/email_address_cache.dart';
|
||||
import 'package:core/core.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
extension EmailAddressExtension on EmailAddress {
|
||||
|
||||
@@ -33,4 +36,20 @@ extension EmailAddressExtension on EmailAddress {
|
||||
String get displayName => name ?? '';
|
||||
|
||||
EmailAddressCache toEmailAddressCache() => EmailAddressCache(displayName, emailAddress);
|
||||
|
||||
List<Color> get avatarColors {
|
||||
return AppColor.mapGradientColor[_generateIndex()];
|
||||
}
|
||||
|
||||
int _generateIndex() {
|
||||
if (emailAddress.isNotEmpty) {
|
||||
final codeUnits = emailAddress.codeUnits;
|
||||
if (codeUnits.isNotEmpty) {
|
||||
final sumCodeUnits = codeUnits.sum;
|
||||
final index = sumCodeUnits % AppColor.mapGradientColor.length;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,11 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
List<Color> get avatarColors {
|
||||
return AppColor.mapGradientColor[_generateIndexFromSender()];
|
||||
}
|
||||
|
||||
int _generateIndexFromSender() {
|
||||
if (from != null && from?.isNotEmpty == true) {
|
||||
final codeUnits = from?.first.email?.codeUnits ?? List.empty();
|
||||
if (codeUnits.isNotEmpty) {
|
||||
final sumCodeUnits = codeUnits.sum;
|
||||
final index = sumCodeUnits % AppColor.mapGradientColor.length;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return from?.first.avatarColors ?? AppColor.mapGradientColor.first;
|
||||
}
|
||||
|
||||
int numberOfAllEmailAddress() => to.numberEmailAddress() + cc.numberEmailAddress() + bcc.numberEmailAddress();
|
||||
|
||||
Reference in New Issue
Block a user