TF-1310: [Presentation] Refactor buildTree logic in TreeBuilder + BaseMailboxController

This commit is contained in:
HuyNguyen
2023-02-02 22:19:43 +07:00
committed by Dat Vu
parent d57bcd10dd
commit 10ba3867d8
30 changed files with 523 additions and 237 deletions
+49 -18
View File
@@ -12,8 +12,9 @@ abstract class BaseMailboxController extends BaseController {
BaseMailboxController(this._treeBuilder); BaseMailboxController(this._treeBuilder);
final folderMailboxTree = MailboxTree(MailboxNode.root()).obs; final personalMailboxTree = MailboxTree(MailboxNode.root()).obs;
final defaultMailboxTree = MailboxTree(MailboxNode.root()).obs; final defaultMailboxTree = MailboxTree(MailboxNode.root()).obs;
final teamMailboxesTree = MailboxTree(MailboxNode.root()).obs;
List<PresentationMailbox> allMailboxes = <PresentationMailbox>[]; List<PresentationMailbox> allMailboxes = <PresentationMailbox>[];
@@ -26,20 +27,27 @@ abstract class BaseMailboxController extends BaseController {
allMailbox, allMailbox,
mailboxIdSelected: mailboxIdSelected); mailboxIdSelected: mailboxIdSelected);
defaultMailboxTree.firstRebuild = true; defaultMailboxTree.firstRebuild = true;
folderMailboxTree.firstRebuild = true; personalMailboxTree.firstRebuild = true;
teamMailboxesTree.firstRebuild = true;
defaultMailboxTree.value = tupleTree.value1; defaultMailboxTree.value = tupleTree.value1;
folderMailboxTree.value = tupleTree.value2; personalMailboxTree.value = tupleTree.value2;
allMailboxes = tupleTree.value3; teamMailboxesTree.value = tupleTree.value3;
allMailboxes = tupleTree.value4;
} }
Future refreshTree(List<PresentationMailbox> allMailbox) async { Future refreshTree(List<PresentationMailbox> allMailbox) async {
allMailboxes = allMailbox; allMailboxes = allMailbox;
final tupleTree = await _treeBuilder.generateMailboxTreeInUIAfterRefreshChanges( final tupleTree = await _treeBuilder.generateMailboxTreeInUIAfterRefreshChanges(
allMailbox, defaultMailboxTree.value, folderMailboxTree.value); allMailbox,
defaultMailboxTree.value,
personalMailboxTree.value,
teamMailboxesTree.value);
defaultMailboxTree.firstRebuild = true; defaultMailboxTree.firstRebuild = true;
folderMailboxTree.firstRebuild = true; personalMailboxTree.firstRebuild = true;
teamMailboxesTree.firstRebuild = true;
defaultMailboxTree.value = tupleTree.value1; defaultMailboxTree.value = tupleTree.value1;
folderMailboxTree.value = tupleTree.value2; personalMailboxTree.value = tupleTree.value2;
teamMailboxesTree.value = tupleTree.value3;
} }
void toggleMailboxFolder(MailboxNode selectedMailboxNode) { void toggleMailboxFolder(MailboxNode selectedMailboxNode) {
@@ -52,9 +60,14 @@ abstract class BaseMailboxController extends BaseController {
defaultMailboxTree.refresh(); defaultMailboxTree.refresh();
} }
if (folderMailboxTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) { if (personalMailboxTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) {
log('toggleMailboxFolder() refresh folderMailboxTree'); log('toggleMailboxFolder() refresh folderMailboxTree');
folderMailboxTree.refresh(); personalMailboxTree.refresh();
}
if (teamMailboxesTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) {
log('toggleMailboxFolder() refresh teamMailboxesTree');
teamMailboxesTree.refresh();
} }
} }
@@ -68,31 +81,43 @@ abstract class BaseMailboxController extends BaseController {
defaultMailboxTree.refresh(); defaultMailboxTree.refresh();
} }
if (folderMailboxTree.value.updateSelectedNode(mailboxNodeSelected, newSelectMode) != null) { if (personalMailboxTree.value.updateSelectedNode(mailboxNodeSelected, newSelectMode) != null) {
log('selectMailboxNode() refresh folderMailboxTree'); log('selectMailboxNode() refresh folderMailboxTree');
folderMailboxTree.refresh(); personalMailboxTree.refresh();
}
if (teamMailboxesTree.value.updateSelectedNode(mailboxNodeSelected, newSelectMode) != null) {
log('selectMailboxNode() refresh folderMailboxTree');
teamMailboxesTree.refresh();
} }
} }
void unAllSelectedMailboxNode() { void unAllSelectedMailboxNode() {
defaultMailboxTree.value.updateNodesUIMode(selectMode: SelectMode.INACTIVE); defaultMailboxTree.value.updateNodesUIMode(selectMode: SelectMode.INACTIVE);
folderMailboxTree.value.updateNodesUIMode(selectMode: SelectMode.INACTIVE); personalMailboxTree.value.updateNodesUIMode(selectMode: SelectMode.INACTIVE);
teamMailboxesTree.value.updateNodesUIMode(selectMode: SelectMode.INACTIVE);
defaultMailboxTree.refresh(); defaultMailboxTree.refresh();
folderMailboxTree.refresh(); personalMailboxTree.refresh();
teamMailboxesTree.refresh();
} }
MailboxNode? findMailboxNodeById(MailboxId mailboxId) { MailboxNode? findMailboxNodeById(MailboxId mailboxId) {
final mailboxNode = defaultMailboxTree.value.findNode((node) => node.item.id == mailboxId); final mailboxNode = defaultMailboxTree.value.findNode((node) => node.item.id == mailboxId);
final mailboxPersonal = personalMailboxTree.value.findNode((node) => node.item.id == mailboxId);
if (mailboxNode != null) { if (mailboxNode != null) {
return mailboxNode; return mailboxNode;
} }
return folderMailboxTree.value.findNode((node) => node.item.id == mailboxId);
if (mailboxPersonal != null) {
return mailboxPersonal;
}
return teamMailboxesTree.value.findNode((node) => node.item.id == mailboxId);
} }
String? findNodePath(MailboxId mailboxId) { String? findNodePath(MailboxId mailboxId) {
var mailboxNodePath = defaultMailboxTree.value.getNodePath(mailboxId); var mailboxNodePath = defaultMailboxTree.value.getNodePath(mailboxId);
if (mailboxNodePath == null) { if (mailboxNodePath == null) {
return folderMailboxTree.value.getNodePath(mailboxId); return personalMailboxTree.value.getNodePath(mailboxId);
} }
return mailboxNodePath; return mailboxNodePath;
} }
@@ -120,10 +145,16 @@ abstract class BaseMailboxController extends BaseController {
bool get defaultMailboxHasChild => bool get defaultMailboxHasChild =>
defaultMailboxTree.value.root.childrenItems?.isNotEmpty ?? false; defaultMailboxTree.value.root.childrenItems?.isNotEmpty ?? false;
bool get folderMailboxHasChild => bool get personalMailboxHasChild =>
folderMailboxTree.value.root.childrenItems?.isNotEmpty ?? false; personalMailboxTree.value.root.childrenItems?.isNotEmpty ?? false;
bool get teamMailboxesHasChild =>
teamMailboxesTree.value.root.childrenItems?.isNotEmpty ?? false;
MailboxNode get defaultRootNode => defaultMailboxTree.value.root; MailboxNode get defaultRootNode => defaultMailboxTree.value.root;
MailboxNode get folderRootNode => folderMailboxTree.value.root; MailboxNode get personalRootNode => personalMailboxTree.value.root;
MailboxNode get teamMailboxesRootNode => teamMailboxesTree.value.root;
} }
@@ -110,6 +110,7 @@ class DestinationPickerController extends BaseMailboxController {
mailboxAction.value = arguments!.mailboxAction; mailboxAction.value = arguments!.mailboxAction;
mailboxIdSelected = arguments!.mailboxIdSelected; mailboxIdSelected = arguments!.mailboxIdSelected;
accountId = arguments!.accountId; accountId = arguments!.accountId;
_session = arguments!.session;
getAllMailboxAction(); getAllMailboxAction();
} }
} }
@@ -175,9 +176,9 @@ class DestinationPickerController extends BaseMailboxController {
mailboxCategoriesExpandMode.value.defaultMailbox = newExpandMode; mailboxCategoriesExpandMode.value.defaultMailbox = newExpandMode;
mailboxCategoriesExpandMode.refresh(); mailboxCategoriesExpandMode.refresh();
break; break;
case MailboxCategories.folders: case MailboxCategories.personalMailboxes:
final newExpandMode = mailboxCategoriesExpandMode.value.folderMailbox == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND; final newExpandMode = mailboxCategoriesExpandMode.value.personalMailboxes == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND;
mailboxCategoriesExpandMode.value.folderMailbox = newExpandMode; mailboxCategoriesExpandMode.value.personalMailboxes = newExpandMode;
mailboxCategoriesExpandMode.refresh(); mailboxCategoriesExpandMode.refresh();
break; break;
default: default:
@@ -235,7 +236,7 @@ class DestinationPickerController extends BaseMailboxController {
if (mailboxDestination.value == null || if (mailboxDestination.value == null ||
mailboxDestination.value == PresentationMailbox.unifiedMailbox) { mailboxDestination.value == PresentationMailbox.unifiedMailbox) {
final allChildrenAtMailboxLocation = (defaultMailboxTree.value.root.childrenItems ?? <MailboxNode>[]) + final allChildrenAtMailboxLocation = (defaultMailboxTree.value.root.childrenItems ?? <MailboxNode>[]) +
(folderMailboxTree.value.root.childrenItems ?? <MailboxNode>[]); (personalMailboxTree.value.root.childrenItems ?? <MailboxNode>[]);
if (allChildrenAtMailboxLocation.isNotEmpty) { if (allChildrenAtMailboxLocation.isNotEmpty) {
listMailboxNameAsStringExist = allChildrenAtMailboxLocation listMailboxNameAsStringExist = allChildrenAtMailboxLocation
.where((mailboxNode) => mailboxNode.nameNotEmpty) .where((mailboxNode) => mailboxNode.nameNotEmpty)
@@ -224,11 +224,11 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
actions, actions,
mailboxIdSelected) mailboxIdSelected)
: const SizedBox.shrink()), : const SizedBox.shrink()),
Obx(() => controller.folderMailboxHasChild Obx(() => controller.personalMailboxHasChild
? _buildMailboxCategory( ? _buildMailboxCategory(
context, context,
MailboxCategories.folders, MailboxCategories.personalMailboxes,
controller.folderRootNode, controller.personalRootNode,
actions, actions,
mailboxIdSelected) mailboxIdSelected)
: const SizedBox.shrink()), : const SizedBox.shrink()),
@@ -1,6 +1,7 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart'; import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
@@ -8,9 +9,18 @@ class DestinationPickerArguments with EquatableMixin {
final AccountId accountId; final AccountId accountId;
final MailboxActions mailboxAction; final MailboxActions mailboxAction;
final MailboxId? mailboxIdSelected; final MailboxId? mailboxIdSelected;
final Session? session;
DestinationPickerArguments(this.accountId, this.mailboxAction, {this.mailboxIdSelected}); DestinationPickerArguments(
this.accountId,
this.mailboxAction,
this.session,
{this.mailboxIdSelected});
@override @override
List<Object?> get props => [accountId, mailboxAction, mailboxIdSelected]; List<Object?> get props => [
accountId,
mailboxAction,
mailboxIdSelected,
session];
} }
@@ -576,9 +576,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void moveToMailbox(BuildContext context, PresentationEmail email) async { void moveToMailbox(BuildContext context, PresentationEmail email) async {
final currentMailbox = getMailboxContain(email); final currentMailbox = getMailboxContain(email);
final accountId = mailboxDashBoardController.accountId.value; final accountId = mailboxDashBoardController.accountId.value;
final _session = mailboxDashBoardController.sessionCurrent;
if (currentMailbox != null && accountId != null) { if (currentMailbox != null && accountId != null) {
final arguments = DestinationPickerArguments(accountId, MailboxActions.moveEmail); final arguments = DestinationPickerArguments(accountId, MailboxActions.moveEmail, _session);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
showDialogDestinationPicker( showDialogDestinationPicker(
context: context, context: context,
@@ -2,6 +2,7 @@
import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/core/id.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/mail/mailbox/mailbox.dart'; import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/namespace.dart';
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart'; import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart';
import 'package:tmail_ui_user/features/mailbox/data/extensions/mailbox_rights_cache_extension.dart'; import 'package:tmail_ui_user/features/mailbox/data/extensions/mailbox_rights_cache_extension.dart';
@@ -18,7 +19,8 @@ extension MailboxCacheExtension on MailboxCache {
totalThreads: totalThreads != null ? TotalThreads(UnsignedInt(totalThreads!)) : null, totalThreads: totalThreads != null ? TotalThreads(UnsignedInt(totalThreads!)) : null,
unreadThreads: unreadThreads != null ? UnreadThreads(UnsignedInt(unreadThreads!)) : null, unreadThreads: unreadThreads != null ? UnreadThreads(UnsignedInt(unreadThreads!)) : null,
myRights: myRights != null ? myRights!.toMailboxRights() : null, myRights: myRights != null ? myRights!.toMailboxRights() : null,
isSubscribed: isSubscribed != null ? IsSubscribed(isSubscribed!) : null isSubscribed: isSubscribed != null ? IsSubscribed(isSubscribed!) : null,
namespace: namespace != null ? Namespace(namespace!) : null
); );
} }
} }
@@ -16,7 +16,8 @@ extension MailboxExtension on Mailbox {
totalThreads: totalThreads?.value.value.round(), totalThreads: totalThreads?.value.value.round(),
unreadThreads: unreadThreads?.value.value.round(), unreadThreads: unreadThreads?.value.value.round(),
myRights: myRights != null ? myRights!.toMailboxRightsCache() : null, myRights: myRights != null ? myRights!.toMailboxRightsCache() : null,
isSubscribed: isSubscribed?.value isSubscribed: isSubscribed?.value,
namespace: namespace?.value
); );
} }
} }
@@ -45,6 +45,9 @@ class MailboxCache extends HiveObject with EquatableMixin {
@HiveField(11) @HiveField(11)
final DateTime? lastOpened; final DateTime? lastOpened;
@HiveField(12)
final String? namespace;
MailboxCache( MailboxCache(
this.id, this.id,
{ {
@@ -58,7 +61,8 @@ class MailboxCache extends HiveObject with EquatableMixin {
this.unreadThreads, this.unreadThreads,
this.myRights, this.myRights,
this.isSubscribed, this.isSubscribed,
this.lastOpened this.lastOpened,
this.namespace,
} }
); );
@@ -68,7 +72,13 @@ class MailboxCache extends HiveObject with EquatableMixin {
name, name,
parentId, parentId,
role, role,
totalEmails,
unreadEmails, unreadEmails,
totalThreads,
unreadThreads,
lastOpened, lastOpened,
myRights,
isSubscribed,
namespace,
]; ];
} }
@@ -47,7 +47,7 @@ class MailboxAPI with HandleSetErrorMixin {
final queryInvocation = jmapRequestBuilder.invocation(getMailboxCreated); final queryInvocation = jmapRequestBuilder.invocation(getMailboxCreated);
final capabilities = checkCapabilities(session, accountId); final capabilities = capabilitiesSupportedMailboxes(session, accountId);
final result = await (jmapRequestBuilder final result = await (jmapRequestBuilder
..usings(capabilities)) ..usings(capabilities))
@@ -61,17 +61,13 @@ class MailboxAPI with HandleSetErrorMixin {
return MailboxResponse(mailboxes: resultCreated?.list, state: resultCreated?.state); return MailboxResponse(mailboxes: resultCreated?.list, state: resultCreated?.state);
} }
Set<CapabilityIdentifier> checkCapabilities(Session session, AccountId accountId) { Set<CapabilityIdentifier> capabilitiesSupportedMailboxes(Session session, AccountId accountId) {
final getMailboxCreated = GetMailboxMethod(accountId); final getMailboxCreated = GetMailboxMethod(accountId);
try { try {
requireCapability( requireCapability(
session, session,
accountId, accountId,
[ [CapabilityIdentifier.jmapTeamMailboxes]);
CapabilityIdentifier.jmapCore,
CapabilityIdentifier.jmapMail,
CapabilityIdentifier.jmapTeamMailboxes
]);
return getMailboxCreated.requiredCapabilitiesSupportTeamMailboxes; return getMailboxCreated.requiredCapabilitiesSupportTeamMailboxes;
} catch (_) { } catch (_) {
return getMailboxCreated.requiredCapabilities; return getMailboxCreated.requiredCapabilities;
@@ -70,7 +70,7 @@ class MailboxRepositoryImpl extends MailboxRepository {
]); ]);
} }
} else { } else {
final mailboxResponse = await mapDataSource[DataSourceType.network]!.getAllMailbox(session, accountId,); final mailboxResponse = await mapDataSource[DataSourceType.network]!.getAllMailbox(session, accountId);
await Future.wait([ await Future.wait([
mapDataSource[DataSourceType.local]!.update(created: mailboxResponse.mailboxes), mapDataSource[DataSourceType.local]!.update(created: mailboxResponse.mailboxes),
@@ -25,8 +25,27 @@ extension PresentationMailboxExtension on PresentationMailbox {
default: default:
return imagePaths.icFolderMailbox; return imagePaths.icFolderMailbox;
} }
} else if (isChildOfTeamMailboxes) {
switch(name!.name.toLowerCase()) {
case 'inbox':
return imagePaths.icMailboxInbox;
case 'drafts':
return imagePaths.icMailboxDrafts;
case 'archive':
return imagePaths.icMailboxArchived;
case 'sent':
return imagePaths.icMailboxSent;
case 'trash':
return imagePaths.icMailboxTrash;
case 'spam':
return imagePaths.icMailboxSpam;
case 'templates':
return imagePaths.icMailboxTemplate;
default:
return imagePaths.icFolderMailbox;
}
} else { } else {
return imagePaths.icFolderMailbox; return imagePaths.icFolderMailbox;
} }
} }
} }
@@ -153,7 +153,7 @@ class MailboxController extends BaseMailboxController {
newState.map((success) async { newState.map((success) async {
if (success is GetAllMailboxSuccess) { if (success is GetAllMailboxSuccess) {
_currentMailboxState = success.currentMailboxState; _currentMailboxState = success.currentMailboxState;
await buildTree(success.mailboxList); _buildMailboxTreeHasSubscribed(success.mailboxList);
} else if (success is RefreshChangesAllMailboxSuccess) { } else if (success is RefreshChangesAllMailboxSuccess) {
_currentMailboxState = success.currentMailboxState; _currentMailboxState = success.currentMailboxState;
await refreshTree(success.mailboxList); await refreshTree(success.mailboxList);
@@ -292,7 +292,8 @@ class MailboxController extends BaseMailboxController {
&& (_responsiveUtils.isMobile(currentContext!) || _responsiveUtils.isTablet(currentContext!))) { && (_responsiveUtils.isMobile(currentContext!) || _responsiveUtils.isTablet(currentContext!))) {
mailboxCategoriesExpandMode.value = MailboxCategoriesExpandMode( mailboxCategoriesExpandMode.value = MailboxCategoriesExpandMode(
defaultMailbox: ExpandMode.COLLAPSE, defaultMailbox: ExpandMode.COLLAPSE,
folderMailbox: ExpandMode.COLLAPSE); personalMailboxes: ExpandMode.COLLAPSE,
teamMailboxes: ExpandMode.COLLAPSE);
} else { } else {
mailboxCategoriesExpandMode.value = MailboxCategoriesExpandMode.initial(); mailboxCategoriesExpandMode.value = MailboxCategoriesExpandMode.initial();
} }
@@ -496,9 +497,11 @@ class MailboxController extends BaseMailboxController {
final accountId = mailboxDashBoardController.accountId.value; final accountId = mailboxDashBoardController.accountId.value;
if (accountId != null) { if (accountId != null) {
final arguments = MailboxCreatorArguments( final arguments = MailboxCreatorArguments(
accountId, accountId,
defaultMailboxTree.value, defaultMailboxTree.value,
folderMailboxTree.value); personalMailboxTree.value,
teamMailboxesTree.value,
mailboxDashBoardController.sessionCurrent!);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
showDialogMailboxCreator( showDialogMailboxCreator(
@@ -656,10 +659,13 @@ class MailboxController extends BaseMailboxController {
final defaultMailboxSelected = defaultMailboxTree.value final defaultMailboxSelected = defaultMailboxTree.value
.findNodes((node) => node.selectMode == SelectMode.ACTIVE); .findNodes((node) => node.selectMode == SelectMode.ACTIVE);
final folderMailboxSelected = folderMailboxTree.value final folderMailboxSelected = personalMailboxTree.value
.findNodes((node) => node.selectMode == SelectMode.ACTIVE); .findNodes((node) => node.selectMode == SelectMode.ACTIVE);
return [defaultMailboxSelected, folderMailboxSelected] final teamMailboxesSelected = teamMailboxesTree.value
.findNodes((node) => node.selectMode == SelectMode.ACTIVE);
return [defaultMailboxSelected, folderMailboxSelected, teamMailboxesSelected]
.expand((node) => node) .expand((node) => node)
.map((node) => node.item) .map((node) => node.item)
.toList(); .toList();
@@ -736,7 +742,7 @@ class MailboxController extends BaseMailboxController {
final tupleMap = MailboxUtils.generateMapDescendantIdsAndMailboxIdList( final tupleMap = MailboxUtils.generateMapDescendantIdsAndMailboxIdList(
[presentationMailbox], [presentationMailbox],
defaultMailboxTree.value, defaultMailboxTree.value,
folderMailboxTree.value); personalMailboxTree.value);
final mapDescendantIds = tupleMap.value1; final mapDescendantIds = tupleMap.value1;
final listMailboxId = tupleMap.value2; final listMailboxId = tupleMap.value2;
@@ -816,7 +822,7 @@ class MailboxController extends BaseMailboxController {
final tupleMap = MailboxUtils.generateMapDescendantIdsAndMailboxIdList( final tupleMap = MailboxUtils.generateMapDescendantIdsAndMailboxIdList(
selectedMailboxList, selectedMailboxList,
defaultMailboxTree.value, defaultMailboxTree.value,
folderMailboxTree.value); personalMailboxTree.value);
final mapDescendantIds = tupleMap.value1; final mapDescendantIds = tupleMap.value1;
final listMailboxId = tupleMap.value2; final listMailboxId = tupleMap.value2;
consumeState(_deleteMultipleMailboxInteractor.execute( consumeState(_deleteMultipleMailboxInteractor.execute(
@@ -947,10 +953,12 @@ class MailboxController extends BaseMailboxController {
void _moveMailboxAction(BuildContext context, PresentationMailbox mailboxSelected) async { void _moveMailboxAction(BuildContext context, PresentationMailbox mailboxSelected) async {
final accountId = mailboxDashBoardController.accountId.value; final accountId = mailboxDashBoardController.accountId.value;
final _session = mailboxDashBoardController.sessionCurrent;
if (accountId != null) { if (accountId != null) {
final arguments = DestinationPickerArguments( final arguments = DestinationPickerArguments(
accountId, accountId,
MailboxActions.move, MailboxActions.move,
_session,
mailboxIdSelected: mailboxSelected.id); mailboxIdSelected: mailboxSelected.id);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
@@ -1039,7 +1047,10 @@ class MailboxController extends BaseMailboxController {
void _createListMailboxNameAsStringInMailboxParent(PresentationMailbox mailboxRenamed) { void _createListMailboxNameAsStringInMailboxParent(PresentationMailbox mailboxRenamed) {
if (mailboxRenamed.parentId == null) { if (mailboxRenamed.parentId == null) {
final allChildrenAtMailboxLocation = (defaultMailboxTree.value.root.childrenItems ?? <MailboxNode>[]) + (folderMailboxTree.value.root.childrenItems ?? <MailboxNode>[]); final allChildrenAtMailboxLocation = (
defaultMailboxTree.value.root.childrenItems ?? <MailboxNode>[])
+ (personalMailboxTree.value.root.childrenItems ?? <MailboxNode>[])
+ (teamMailboxesTree.value.root.childrenItems ?? <MailboxNode>[]);
if (allChildrenAtMailboxLocation.isNotEmpty) { if (allChildrenAtMailboxLocation.isNotEmpty) {
listMailboxNameAsStringExist = allChildrenAtMailboxLocation listMailboxNameAsStringExist = allChildrenAtMailboxLocation
.where((mailboxNode) => mailboxNode.nameNotEmpty) .where((mailboxNode) => mailboxNode.nameNotEmpty)
@@ -1071,9 +1082,14 @@ class MailboxController extends BaseMailboxController {
mailboxCategoriesExpandMode.value.defaultMailbox = newExpandMode; mailboxCategoriesExpandMode.value.defaultMailbox = newExpandMode;
mailboxCategoriesExpandMode.refresh(); mailboxCategoriesExpandMode.refresh();
break; break;
case MailboxCategories.folders: case MailboxCategories.personalMailboxes:
final newExpandMode = mailboxCategoriesExpandMode.value.folderMailbox == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND; final newExpandMode = mailboxCategoriesExpandMode.value.personalMailboxes == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND;
mailboxCategoriesExpandMode.value.folderMailbox = newExpandMode; mailboxCategoriesExpandMode.value.personalMailboxes = newExpandMode;
mailboxCategoriesExpandMode.refresh();
break;
case MailboxCategories.teamMailboxes:
final newExpandMode = mailboxCategoriesExpandMode.value.teamMailboxes == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND;
mailboxCategoriesExpandMode.value.teamMailboxes = newExpandMode;
mailboxCategoriesExpandMode.refresh(); mailboxCategoriesExpandMode.refresh();
break; break;
case MailboxCategories.appGrid: case MailboxCategories.appGrid:
@@ -1185,4 +1201,9 @@ class MailboxController extends BaseMailboxController {
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
curve: Curves.fastOutSlowIn); curve: Curves.fastOutSlowIn);
} }
void _buildMailboxTreeHasSubscribed(List<PresentationMailbox> mailboxList) async {
final _mailboxList = mailboxList.where((mailbox) => mailbox.isSubscribed?.value == true).toList();
await buildTree(_mailboxList);
}
} }
@@ -187,19 +187,6 @@ class MailboxView extends GetWidget<MailboxController> {
]); ]);
} }
Widget _buildSearchBarWidget(BuildContext context) {
return Padding(
padding: EdgeInsets.only(
top: _responsiveUtils.isDesktop(context) ? 16 : 12,
bottom: 16,
left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 16,
right: 16),
child: SearchBarView(
_imagePaths,
hintTextSearch: AppLocalizations.of(context).hint_search_mailboxes,
onOpenSearchViewAction: controller.enableSearch));
}
Widget _buildLoadingView() { Widget _buildLoadingView() {
return Obx(() => controller.viewState.value.fold( return Obx(() => controller.viewState.value.fold(
(failure) => const SizedBox.shrink(), (failure) => const SizedBox.shrink(),
@@ -231,15 +218,54 @@ class MailboxView extends GetWidget<MailboxController> {
} }
return _buildUserInformation(context); return _buildUserInformation(context);
}), }),
_buildSearchBarWidget(context),
_buildLoadingView(), _buildLoadingView(),
Obx(() => controller.defaultMailboxTree.value.root.childrenItems?.isNotEmpty ?? false Obx(() => controller.defaultMailboxTree.value.root.childrenItems?.isNotEmpty ?? false
? _buildMailboxCategory(context, MailboxCategories.exchange, controller.defaultMailboxTree.value.root) ? _buildMailboxCategory(context, MailboxCategories.exchange, controller.defaultMailboxTree.value.root)
: const SizedBox.shrink()), : const SizedBox.shrink()),
const Divider(color: AppColor.colorDividerMailbox, height: 0.5, thickness: 0.2),
const SizedBox(height: 12), const SizedBox(height: 12),
Obx(() => controller.folderMailboxTree.value.root.childrenItems?.isNotEmpty ?? false Container(
? _buildMailboxCategory(context, MailboxCategories.folders, controller.folderMailboxTree.value.root) margin: EdgeInsets.only(
: const SizedBox.shrink()), left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 8,
right: 16),
padding: const EdgeInsets.only(left: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(AppLocalizations.of(context).mailBoxes,
style: const TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.bold)),
Row(
children: [
buildIconWeb(
iconSize: 20,
minSize: 40,
iconPadding: EdgeInsets.zero,
splashRadius: 15,
icon: SvgPicture.asset(_imagePaths.icSearchBar, color: AppColor.colorTextButton, fit: BoxFit.fill),
onTap: () => controller.enableSearch()),
buildIconWeb(
minSize: 40,
iconSize: 20,
iconPadding: EdgeInsets.zero,
splashRadius: 15,
icon: SvgPicture.asset(_imagePaths.icAddNewFolder, color: AppColor.colorTextButton, fit: BoxFit.fill),
tooltip: AppLocalizations.of(context).new_mailbox,
onTap: () => controller.goToCreateNewMailboxView(context)),
],
),
]),
),
const SizedBox(height: 8),
Obx(() => controller.personalMailboxTree.value.root.childrenItems?.isNotEmpty ?? false
? _buildMailboxCategory(context, MailboxCategories.personalMailboxes, controller.personalMailboxTree.value.root)
: const SizedBox.shrink()),
const SizedBox(height: 8),
Obx(() => controller.teamMailboxesTree.value.root.childrenItems?.isNotEmpty ?? false
? _buildMailboxCategory(context, MailboxCategories.teamMailboxes, controller.teamMailboxesTree.value.root)
: const SizedBox.shrink()),
Obx(() => controller.isMailboxListScrollable.isFalse Obx(() => controller.isMailboxListScrollable.isFalse
&& !controller.isSearchActive() && !controller.isSearchActive()
&& !controller.isSelectionEnabled() && !controller.isSelectionEnabled()
@@ -254,21 +280,25 @@ class MailboxView extends GetWidget<MailboxController> {
Widget _buildHeaderMailboxCategory(BuildContext context, MailboxCategories categories) { Widget _buildHeaderMailboxCategory(BuildContext context, MailboxCategories categories) {
return Padding( return Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: _responsiveUtils.isLandscapeMobile(context) ? 8 : 28, right: _responsiveUtils.isLandscapeMobile(context) ? 8 : 28,
right: 16), left: 16),
child: Row(children: [ child: Row(children: [
Expanded(child: Text(categories.getTitle(context), buildIconWeb(
maxLines: 1, minSize: 40,
overflow: TextOverflow.ellipsis, iconSize: 20,
style: const TextStyle(fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold))), iconPadding: EdgeInsets.zero,
buildIconWeb( splashRadius: 15,
icon: SvgPicture.asset( icon: SvgPicture.asset(
categories.getExpandMode(controller.mailboxCategoriesExpandMode.value) == ExpandMode.EXPAND categories.getExpandMode(controller.mailboxCategoriesExpandMode.value) == ExpandMode.EXPAND
? _imagePaths.icExpandFolder ? _imagePaths.icExpandFolder
: _imagePaths.icCollapseFolder, : _imagePaths.icCollapseFolder,
color: AppColor.primaryColor, fit: BoxFit.fill), color: AppColor.primaryColor, fit: BoxFit.fill),
tooltip: AppLocalizations.of(context).collapse, tooltip: AppLocalizations.of(context).collapse,
onTap: () => controller.toggleMailboxCategories(categories)) onTap: () => controller.toggleMailboxCategories(categories)),
Expanded(child: Text(categories.getTitle(context),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold))),
])); ]));
} }
@@ -276,7 +306,6 @@ class MailboxView extends GetWidget<MailboxController> {
final lastNode = mailboxNode.childrenItems?.last; final lastNode = mailboxNode.childrenItems?.last;
return Container( return Container(
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), color: Colors.white),
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 16, left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 16,
right: 16), right: 16),
@@ -132,14 +132,6 @@ class MailboxView extends GetWidget<MailboxController> with AppLoaderMixin, Popu
.build()); .build());
} }
Widget _buildSearchBarWidget(BuildContext context) {
return Padding(
padding: EdgeInsets.only(top: 16, bottom: 16, right: 4, left: _responsiveUtils.isDesktop(context) ? 0 : 12),
child: SearchBarView(
_imagePaths,
hintTextSearch: AppLocalizations.of(context).hint_search_mailboxes,
onOpenSearchViewAction: controller.enableSearch));
}
Widget _buildLoadingView() { Widget _buildLoadingView() {
return Obx(() => controller.viewState.value.fold( return Obx(() => controller.viewState.value.fold(
@@ -178,22 +170,49 @@ class MailboxView extends GetWidget<MailboxController> with AppLoaderMixin, Popu
: const SizedBox.shrink()), : const SizedBox.shrink()),
const SizedBox(height: 8), const SizedBox(height: 8),
const Divider(color: AppColor.colorDividerMailbox, height: 0.5, thickness: 0.2), const Divider(color: AppColor.colorDividerMailbox, height: 0.5, thickness: 0.2),
const SizedBox(height: 13),
Padding(
padding: EdgeInsets.only(left: _responsiveUtils.isDesktop(context) ? 0 : 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(AppLocalizations.of(context).mailBoxes,
style: const TextStyle(
fontSize: 17,
color: Colors.black,
fontWeight: FontWeight.bold)),
Padding(
padding: EdgeInsets.only(right: _responsiveUtils.isDesktop(context) ? 0 : 12),
child: Row(
children: [
buildIconWeb(
minSize: 40,
iconSize: 20,
iconPadding: EdgeInsets.zero,
splashRadius: 15,
icon: SvgPicture.asset(_imagePaths.icSearchBar, color: AppColor.colorTextButton, fit: BoxFit.fill),
onTap: () => controller.enableSearch()),
buildIconWeb(
minSize: 40,
iconSize: 20,
iconPadding: EdgeInsets.zero,
splashRadius: 15,
icon: SvgPicture.asset(_imagePaths.icAddNewFolder, color: AppColor.colorTextButton, fit: BoxFit.fill),
tooltip: AppLocalizations.of(context).new_mailbox,
onTap: () => controller.goToCreateNewMailboxView(context)),
],
)),
]),
),
const SizedBox(height: 8), const SizedBox(height: 8),
_buildHeaderMailboxCategory(context, MailboxCategories.folders), _buildHeaderMailboxCategory(context, MailboxCategories.personalMailboxes),
Row(children: [ Obx(() => controller.personalMailboxHasChild
Expanded(child: _buildSearchBarWidget(context)), ? _buildMailboxCategory(context, MailboxCategories.personalMailboxes, controller.personalRootNode)
Padding( : const SizedBox.shrink()),
padding: EdgeInsets.only(right: _responsiveUtils.isDesktop(context) ? 0 : 12), const SizedBox(height: 8),
child: buildIconWeb( _buildHeaderMailboxCategory(context, MailboxCategories.teamMailboxes),
minSize: 40, Obx(() => controller.teamMailboxesHasChild
iconPadding: EdgeInsets.zero, ? _buildMailboxCategory(context, MailboxCategories.teamMailboxes, controller.teamMailboxesRootNode)
splashRadius: 15,
icon: SvgPicture.asset(_imagePaths.icAddNewFolder, color: AppColor.colorTextButton, fit: BoxFit.fill),
tooltip: AppLocalizations.of(context).new_mailbox,
onTap: () => controller.goToCreateNewMailboxView(context))),
]),
Obx(() => controller.folderMailboxHasChild
? _buildMailboxCategory(context, MailboxCategories.folders, controller.folderRootNode)
: const SizedBox.shrink()), : const SizedBox.shrink()),
]) ])
), ),
@@ -6,8 +6,9 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
enum MailboxCategories { enum MailboxCategories {
exchange, exchange,
folders, personalMailboxes,
appGrid, appGrid,
teamMailboxes
} }
extension MailboxCategoriessExtension on MailboxCategories { extension MailboxCategoriessExtension on MailboxCategories {
@@ -16,10 +17,12 @@ extension MailboxCategoriessExtension on MailboxCategories {
switch(this) { switch(this) {
case MailboxCategories.exchange: case MailboxCategories.exchange:
return 'exchange'; return 'exchange';
case MailboxCategories.folders: case MailboxCategories.personalMailboxes:
return 'folders'; return 'personalMailboxes';
case MailboxCategories.appGrid: case MailboxCategories.appGrid:
return 'appGrid'; return 'appGrid';
case MailboxCategories.teamMailboxes:
return 'teamMailboxes';
} }
} }
@@ -27,10 +30,12 @@ extension MailboxCategoriessExtension on MailboxCategories {
switch(this) { switch(this) {
case MailboxCategories.exchange: case MailboxCategories.exchange:
return AppLocalizations.of(context).exchange; return AppLocalizations.of(context).exchange;
case MailboxCategories.folders: case MailboxCategories.personalMailboxes:
return AppLocalizations.of(context).myFolders; return AppLocalizations.of(context).personalMailboxes;
case MailboxCategories.appGrid: case MailboxCategories.appGrid:
return AppLocalizations.of(context).appGridTittle; return AppLocalizations.of(context).appGridTittle;
case MailboxCategories.teamMailboxes:
return AppLocalizations.of(context).teamMailBoxes;
} }
} }
@@ -38,8 +43,10 @@ extension MailboxCategoriessExtension on MailboxCategories {
switch(this) { switch(this) {
case MailboxCategories.exchange: case MailboxCategories.exchange:
return categoriesExpandMode.defaultMailbox; return categoriesExpandMode.defaultMailbox;
case MailboxCategories.folders: case MailboxCategories.personalMailboxes:
return categoriesExpandMode.folderMailbox; return categoriesExpandMode.personalMailboxes;
case MailboxCategories.teamMailboxes:
return categoriesExpandMode.teamMailboxes;
default: default:
return ExpandMode.COLLAPSE; return ExpandMode.COLLAPSE;
} }
@@ -4,14 +4,21 @@ import 'package:model/mailbox/expand_mode.dart';
class MailboxCategoriesExpandMode with EquatableMixin { class MailboxCategoriesExpandMode with EquatableMixin {
ExpandMode defaultMailbox; ExpandMode defaultMailbox;
ExpandMode folderMailbox; ExpandMode personalMailboxes;
ExpandMode teamMailboxes;
MailboxCategoriesExpandMode({required this.defaultMailbox, required this.folderMailbox}); MailboxCategoriesExpandMode({
required this.defaultMailbox,
required this.personalMailboxes,
required this.teamMailboxes});
factory MailboxCategoriesExpandMode.initial() { factory MailboxCategoriesExpandMode.initial() {
return MailboxCategoriesExpandMode(defaultMailbox: ExpandMode.EXPAND, folderMailbox: ExpandMode.EXPAND); return MailboxCategoriesExpandMode(
defaultMailbox: ExpandMode.EXPAND,
personalMailboxes: ExpandMode.EXPAND,
teamMailboxes: ExpandMode.EXPAND);
} }
@override @override
List<Object?> get props => [defaultMailbox, folderMailbox]; List<Object?> get props => [defaultMailbox, personalMailboxes, teamMailboxes];
} }
@@ -39,14 +39,16 @@ class TreeBuilder {
return tree; return tree;
} }
Future<Tuple3<MailboxTree, MailboxTree, List<PresentationMailbox>>> generateMailboxTreeInUI( Future<Tuple4<MailboxTree, MailboxTree, MailboxTree, List<PresentationMailbox>>> generateMailboxTreeInUI(
List<PresentationMailbox> allMailboxes, List<PresentationMailbox> allMailboxes,
{MailboxId? mailboxIdSelected} {MailboxId? mailboxIdSelected}
) async { ) async {
final Map<MailboxId, MailboxNode> mailboxDictionary = HashMap(); final Map<MailboxId, MailboxNode> mailboxDictionary = HashMap();
final defaultTree = MailboxTree(MailboxNode.root()); final defaultTree = MailboxTree(MailboxNode.root());
final folderTree = MailboxTree(MailboxNode.root()); final personalTree = MailboxTree(MailboxNode.root());
final teamMailboxes = MailboxTree(MailboxNode.root());
List<PresentationMailbox> listAllMailboxes = <PresentationMailbox>[]; List<PresentationMailbox> listAllMailboxes = <PresentationMailbox>[];
for (var mailbox in allMailboxes) { for (var mailbox in allMailboxes) {
@@ -81,7 +83,14 @@ class TreeBuilder {
} else { } else {
listAllMailboxes.add(node.item); listAllMailboxes.add(node.item);
var tree = mailbox.hasRole() ? defaultTree : folderTree; MailboxTree tree;
if (mailbox.hasRole()) {
tree = defaultTree;
} else if(mailbox.isPersonal) {
tree = personalTree;
} else {
tree = teamMailboxes;
}
tree.root.addChildNode(node); tree.root.addChildNode(node);
tree.root.childrenItems?.sortByCompare<MailboxName?>( tree.root.childrenItems?.sortByCompare<MailboxName?>(
@@ -93,22 +102,25 @@ class TreeBuilder {
} }
defaultTree.root.childrenItems?.sort((thisMailbox, thatMailbox) => thisMailbox.compareTo(thatMailbox)); defaultTree.root.childrenItems?.sort((thisMailbox, thatMailbox) => thisMailbox.compareTo(thatMailbox));
return Tuple3(defaultTree, folderTree, listAllMailboxes); return Tuple4(defaultTree, personalTree, teamMailboxes, listAllMailboxes);
} }
Future<Tuple2<MailboxTree, MailboxTree>> generateMailboxTreeInUIAfterRefreshChanges( Future<Tuple3<MailboxTree, MailboxTree, MailboxTree>> generateMailboxTreeInUIAfterRefreshChanges(
List<PresentationMailbox> allMailboxes, List<PresentationMailbox> allMailboxes,
MailboxTree defaultTreeBeforeChanges, MailboxTree defaultTreeBeforeChanges,
MailboxTree folderTreeBeforeChanges, MailboxTree personalTreeBeforeChanges,
MailboxTree teamMailboxesTreeBeforeChanges
) async { ) async {
final Map<MailboxId, MailboxNode> mailboxDictionary = HashMap(); final Map<MailboxId, MailboxNode> mailboxDictionary = HashMap();
final newDefaultTree = MailboxTree(MailboxNode.root()); final newDefaultTree = MailboxTree(MailboxNode.root());
final newFolderTree = MailboxTree(MailboxNode.root()); final newPersonalTree = MailboxTree(MailboxNode.root());
final newTeamMailboxes = MailboxTree(MailboxNode.root());
for (var mailbox in allMailboxes) { for (var mailbox in allMailboxes) {
final mailboxNodeBeforeChanges = defaultTreeBeforeChanges.findNode((node) => node.item.id == mailbox.id) ?? final mailboxNodeBeforeChanges = defaultTreeBeforeChanges.findNode((node) => node.item.id == mailbox.id)
folderTreeBeforeChanges.findNode((node) => node.item.id == mailbox.id); ?? personalTreeBeforeChanges.findNode((node) => node.item.id == mailbox.id)
?? teamMailboxesTreeBeforeChanges.findNode((node) => node.item.id == mailbox.id);
if (mailboxNodeBeforeChanges != null) { if (mailboxNodeBeforeChanges != null) {
mailboxDictionary[mailbox.id] = MailboxNode( mailboxDictionary[mailbox.id] = MailboxNode(
mailbox, mailbox,
@@ -131,7 +143,15 @@ class TreeBuilder {
(name, other) => name?.compareAlphabetically(other) ?? -1 (name, other) => name?.compareAlphabetically(other) ?? -1
); );
} else { } else {
var tree = mailbox.hasRole() ? newDefaultTree : newFolderTree;
MailboxTree tree;
if (mailbox.hasRole()) {
tree = newDefaultTree;
} else if(mailbox.isPersonal) {
tree = newPersonalTree;
} else {
tree = newTeamMailboxes;
}
tree.root.addChildNode(node); tree.root.addChildNode(node);
tree.root.childrenItems?.sortByCompare<MailboxName?>( tree.root.childrenItems?.sortByCompare<MailboxName?>(
@@ -143,6 +163,6 @@ class TreeBuilder {
} }
newDefaultTree.root.childrenItems?.sort((thisMailbox, thatMailbox) => thisMailbox.compareTo(thatMailbox)); newDefaultTree.root.childrenItems?.sort((thisMailbox, thatMailbox) => thisMailbox.compareTo(thatMailbox));
return Tuple2(newDefaultTree, newFolderTree); return Tuple3(newDefaultTree, newPersonalTree, newTeamMailboxes);
} }
} }
@@ -105,12 +105,16 @@ class MailBoxFolderTileBuilder {
color: backgroundColorItem), color: backgroundColorItem),
padding: const EdgeInsets.only(left: 4, right: 4, top: 8, bottom: 8), padding: const EdgeInsets.only(left: 4, right: 4, top: 8, bottom: 8),
margin: const EdgeInsets.only(bottom: 4), margin: const EdgeInsets.only(bottom: 4),
child: Row(children: [ child: Row(
_buildLeadingMailboxItem(), crossAxisAlignment: _mailboxNode.item.isTeamMailboxes
const SizedBox(width: 4), ? CrossAxisAlignment.start
Expanded(child: _buildTitleFolderItem()), : CrossAxisAlignment.center,
const SizedBox(width: 8), children: [
_buildTrailingMailboxItem() _buildLeadingMailboxItem(),
const SizedBox(width: 4),
Expanded(child: _buildTitleFolderItem()),
const SizedBox(width: 8),
_buildTrailingMailboxItem()
]) ])
), ),
); );
@@ -131,27 +135,27 @@ class MailBoxFolderTileBuilder {
: _onOpenMailboxFolderClick?.call(_mailboxNode), : _onOpenMailboxFolderClick?.call(_mailboxNode),
child: ClipRRect( child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(14)), borderRadius: const BorderRadius.all(Radius.circular(14)),
child: Container( child: Column(
color: Colors.white, mainAxisSize: MainAxisSize.min,
child: Column( mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min, children: [
mainAxisAlignment: MainAxisAlignment.center, Padding(
children: [ padding: EdgeInsets.symmetric(
Padding( vertical: _mailboxNode.hasChildren() ? 8 : 15),
padding: EdgeInsets.symmetric( child: Row(
vertical: _mailboxNode.hasChildren() ? 8 : 15), crossAxisAlignment: _mailboxNode.item.isTeamMailboxes
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ ? CrossAxisAlignment.start
_buildLeadingMailboxItem(), : CrossAxisAlignment.center,
const SizedBox(width: 8), children: [
Expanded(child: _buildTitleFolderItem()), _buildLeadingMailboxItem(),
_buildSelectedIcon(), const SizedBox(width: 8),
const SizedBox(width: 8), Expanded(child: _buildTitleFolderItem()),
_buildTrailingMailboxItem() _buildSelectedIcon(),
]), const SizedBox(width: 8),
), _buildTrailingMailboxItem()
_buildDivider(), ]),
] ),
) ]
) )
), ),
), ),
@@ -193,33 +197,69 @@ class MailBoxFolderTileBuilder {
if (mailboxDisplayed == MailboxDisplayed.mailbox) { if (mailboxDisplayed == MailboxDisplayed.mailbox) {
return Row(mainAxisSize: MainAxisSize.min, children: [ return Row(mainAxisSize: MainAxisSize.min, children: [
if (_mailboxNode.hasChildren()) if (_mailboxNode.hasChildren())
buildIconWeb( Row(
icon: SvgPicture.asset( children: [
_mailboxNode.expandMode == ExpandMode.EXPAND const SizedBox(width: 8),
? _imagePaths.icExpandFolder buildIconWeb(
: _imagePaths.icCollapseFolder, icon: SvgPicture.asset(
color: _mailboxNode.expandMode == ExpandMode.EXPAND _mailboxNode.expandMode == ExpandMode.EXPAND
? AppColor.colorExpandMailbox ? _imagePaths.icExpandFolder
: AppColor.colorCollapseMailbox, : _imagePaths.icCollapseFolder,
fit: BoxFit.fill), color: _mailboxNode.expandMode == ExpandMode.EXPAND
minSize: 12, ? AppColor.colorExpandMailbox
splashRadius: 10, : AppColor.colorCollapseMailbox,
iconPadding: EdgeInsets.zero, fit: BoxFit.fill),
tooltip: _mailboxNode.expandMode == ExpandMode.EXPAND minSize: 12,
? AppLocalizations.of(_context).collapse splashRadius: 10,
: AppLocalizations.of(_context).expand, iconPadding: EdgeInsets.zero,
onTap: () => _onExpandFolderActionClick?.call(_mailboxNode)) tooltip: _mailboxNode.expandMode == ExpandMode.EXPAND
? AppLocalizations.of(_context).collapse
: AppLocalizations.of(_context).expand,
onTap: () => _onExpandFolderActionClick?.call(_mailboxNode)),
const SizedBox(width: 4),
],
)
else else
const SizedBox(width: 24), SizedBox(width:_mailboxNode.item.hasRole() ? 0 : 24),
Transform( Transform(
transform: Matrix4.translationValues(-4.0, 0.0, 0.0), transform: Matrix4.translationValues(-4.0, 0.0, 0.0),
child: _buildLeadingIcon()) child: _buildLeadingIcon()),
]); ]);
} else { } else {
return _buildLeadingIcon(); return _buildLeadingIcon();
} }
} else { } else {
return _buildLeadingIcon(); if (mailboxDisplayed == MailboxDisplayed.mailbox) {
return Row(mainAxisSize: MainAxisSize.min, children: [
if (_mailboxNode.hasChildren())
Row(
children: [
const SizedBox(width: 12),
buildIconWeb(
icon: SvgPicture.asset(
_mailboxNode.expandMode == ExpandMode.EXPAND
? _imagePaths.icExpandFolder
: _imagePaths.icCollapseFolder,
color: _mailboxNode.expandMode == ExpandMode.EXPAND
? AppColor.colorExpandMailbox
: AppColor.colorCollapseMailbox,
fit: BoxFit.fill),
minSize: 12,
splashRadius: 10,
iconPadding: EdgeInsets.zero,
tooltip: _mailboxNode.expandMode == ExpandMode.EXPAND
? AppLocalizations.of(_context).collapse
: AppLocalizations.of(_context).expand,
onTap: () => _onExpandFolderActionClick?.call(_mailboxNode)),
],
)
else
SizedBox(width: _mailboxNode.item.hasRole() ? 0 : 36),
_buildLeadingIcon(),
]);
} else {
return _buildLeadingIcon();
}
} }
} }
@@ -259,30 +299,13 @@ class MailBoxFolderTileBuilder {
} else { } else {
if (_mailboxNode.hasChildren()) { if (_mailboxNode.hasChildren()) {
return Padding( return Padding(
padding: const EdgeInsets.only(right: 4), padding: const EdgeInsets.only(right: 12),
child: Row( child: Row(
children: [ children: [
if (_mailboxNode.item.getCountUnReadEmails().isNotEmpty if (_mailboxNode.item.getCountUnReadEmails().isNotEmpty
&& _mailboxNode.item.matchCountingRules() && _mailboxNode.item.matchCountingRules()
&& mailboxDisplayed == MailboxDisplayed.mailbox) && mailboxDisplayed == MailboxDisplayed.mailbox)
_buildCounter(), _buildCounter(),
buildIconWeb(
icon: SvgPicture.asset(
_mailboxNode.expandMode == ExpandMode.EXPAND
? _imagePaths.icExpandFolder
: _imagePaths.icCollapseFolder,
color: _mailboxNode.expandMode == ExpandMode.EXPAND
? AppColor.colorExpandMailbox
: AppColor.colorCollapseMailbox,
fit: BoxFit.fill),
splashRadius: mailboxDisplayed == MailboxDisplayed.mailbox ? 20 : 20,
iconPadding: EdgeInsets.zero,
minSize: mailboxDisplayed == MailboxDisplayed.mailbox ? 40 : 24,
tooltip: _mailboxNode.expandMode == ExpandMode.EXPAND
? AppLocalizations.of(_context).collapse
: AppLocalizations.of(_context).expand,
onTap: () => _onExpandFolderActionClick?.call(_mailboxNode)
),
], ],
), ),
); );
@@ -290,35 +313,67 @@ class MailBoxFolderTileBuilder {
&& _mailboxNode.item.matchCountingRules() && _mailboxNode.item.matchCountingRules()
&& mailboxDisplayed == MailboxDisplayed.mailbox) { && mailboxDisplayed == MailboxDisplayed.mailbox) {
return Padding( return Padding(
padding: const EdgeInsets.only(right: 20), padding: const EdgeInsets.only(right: 12),
child: _buildCounter(), child: _buildCounter(),
); );
} else { } else {
return const SizedBox(width: 20); return const SizedBox();
} }
} }
} }
Widget _buildLeadingIcon() { Widget _buildLeadingIcon() {
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
return _buildMailboxIcon(); return _buildLeadingIconTeamMailboxes();
} else { } else {
return allSelectMode == SelectMode.ACTIVE return allSelectMode == SelectMode.ACTIVE
? _buildSelectModeIcon() ? _buildSelectModeIcon()
: _buildMailboxIcon(); : _buildLeadingIconTeamMailboxes();
}
}
Widget _buildLeadingIconTeamMailboxes() {
if(!_mailboxNode.item.isPersonal) {
return _buildLeadingIconForChildOfTeamMailboxes();
} else {
return _buildMailboxIcon();
}
}
Widget _buildLeadingIconForChildOfTeamMailboxes() {
if(_mailboxNode.item.hasParentId()) {
return _buildMailboxIcon();
} else {
return const SizedBox();
} }
} }
Widget _buildTitleFolderItem() { Widget _buildTitleFolderItem() {
return Text( return Column(
_mailboxNode.item.name?.name ?? '', crossAxisAlignment: CrossAxisAlignment.start,
maxLines: 1, children: [
softWrap: CommonTextStyle.defaultSoftWrap, Text(
overflow: CommonTextStyle.defaultTextOverFlow, _mailboxNode.item.name?.name ?? '',
style: const TextStyle( maxLines: 1,
fontSize: 15, softWrap: CommonTextStyle.defaultSoftWrap,
color: AppColor.colorNameEmail, overflow: CommonTextStyle.defaultTextOverFlow,
fontWeight: FontWeight.normal), style: TextStyle(
fontSize: _mailboxNode.item.isTeamMailboxes ? 16 : 15,
color: _mailboxNode.item.isTeamMailboxes ? Colors.black : AppColor.colorNameEmail,
fontWeight: _mailboxNode.item.isTeamMailboxes ? FontWeight.bold : FontWeight.normal),
),
if(_mailboxNode.item.isTeamMailboxes)
Text(
_mailboxNode.item.nameTeamMailBoxes ?? '',
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
style: const TextStyle(
fontSize: 13,
color: AppColor.colorEmailAddressFull,
fontWeight: FontWeight.w400),
),
],
); );
} }
@@ -335,8 +390,7 @@ class MailBoxFolderTileBuilder {
} }
Widget _buildMailboxIcon() { Widget _buildMailboxIcon() {
return SvgPicture.asset( return SvgPicture.asset(_mailboxNode.item.getMailboxIcon(_imagePaths),
_mailboxNode.item.getMailboxIcon(_imagePaths),
width: BuildUtils.isWeb ? 20 : 24, width: BuildUtils.isWeb ? 20 : 24,
height: BuildUtils.isWeb ? 20 : 24, height: BuildUtils.isWeb ? 20 : 24,
fit: BoxFit.fill); fit: BoxFit.fill);
@@ -395,20 +449,6 @@ class MailBoxFolderTileBuilder {
} }
} }
Widget _buildDivider() {
if (lastNode?.item.id != _mailboxNode.item.id) {
return const Padding(
padding: EdgeInsets.only(left: 30),
child: Divider(
color: AppColor.lineItemListColor,
height: 0.5,
thickness: 0.2
)
);
}
return const SizedBox.shrink();
}
Widget _buildSelectedIcon() { Widget _buildSelectedIcon() {
if (_mailboxNode.item.id == mailboxIdAlreadySelected && if (_mailboxNode.item.id == mailboxIdAlreadySelected &&
mailboxDisplayed == MailboxDisplayed.destinationPicker && mailboxDisplayed == MailboxDisplayed.destinationPicker &&
@@ -3,6 +3,7 @@ import 'package:core/core.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:model/model.dart'; import 'package:model/model.dart';
import 'package:tmail_ui_user/features/base/base_controller.dart'; import 'package:tmail_ui_user/features/base/base_controller.dart';
@@ -34,8 +35,10 @@ class MailboxCreatorController extends BaseController {
MailboxCreatorArguments? arguments; MailboxCreatorArguments? arguments;
AccountId? accountId; AccountId? accountId;
MailboxTree? folderMailboxTree; Session? _session;
MailboxTree? defaultMailboxTree; MailboxTree? defaultMailboxTree;
MailboxTree? personalMailboxTree;
MailboxTree? teamMailboxesTre;
OnCreatedMailboxCallback? onCreatedMailboxCallback; OnCreatedMailboxCallback? onCreatedMailboxCallback;
VoidCallback? onDismissMailboxCreator; VoidCallback? onDismissMailboxCreator;
@@ -56,9 +59,11 @@ class MailboxCreatorController extends BaseController {
void onReady() { void onReady() {
super.onReady(); super.onReady();
if (arguments != null) { if (arguments != null) {
folderMailboxTree = arguments!.folderMailboxTree; personalMailboxTree = arguments!.personalMailboxTree;
defaultMailboxTree = arguments!.defaultMailboxTree; defaultMailboxTree = arguments!.defaultMailboxTree;
teamMailboxesTre = arguments!.teamMailboxesTree;
accountId = arguments!.accountId; accountId = arguments!.accountId;
_session = arguments!.session;
_createListMailboxNameAsStringInMailboxLocation(); _createListMailboxNameAsStringInMailboxLocation();
} }
} }
@@ -89,13 +94,17 @@ class MailboxCreatorController extends BaseController {
final mailboxNode = defaultMailboxTree?.findNode((node) => node.item.id == mailboxId); final mailboxNode = defaultMailboxTree?.findNode((node) => node.item.id == mailboxId);
if (mailboxNode != null) { if (mailboxNode != null) {
return mailboxNode; return mailboxNode;
} else if(mailboxNode!.item.isTeamMailboxes) {
return teamMailboxesTre?.findNode((node) => node.item.id == mailboxId);
} }
return folderMailboxTree?.findNode((node) => node.item.id == mailboxId); return personalMailboxTree?.findNode((node) => node.item.id == mailboxId);
} }
void _createListMailboxNameAsStringInMailboxLocation() { void _createListMailboxNameAsStringInMailboxLocation() {
if (selectedMailbox.value == null) { if (selectedMailbox.value == null) {
final allChildrenAtMailboxLocation = (defaultMailboxTree?.root.childrenItems ?? <MailboxNode>[]) + (folderMailboxTree?.root.childrenItems ?? <MailboxNode>[]); final allChildrenAtMailboxLocation = (defaultMailboxTree?.root.childrenItems ?? <MailboxNode>[])
+ (personalMailboxTree?.root.childrenItems ?? <MailboxNode>[])
+ (teamMailboxesTre?.root.childrenItems ?? <MailboxNode>[]);
if (allChildrenAtMailboxLocation.isNotEmpty) { if (allChildrenAtMailboxLocation.isNotEmpty) {
listMailboxNameAsStringExist = allChildrenAtMailboxLocation listMailboxNameAsStringExist = allChildrenAtMailboxLocation
.where((mailboxNode) => mailboxNode.nameNotEmpty) .where((mailboxNode) => mailboxNode.nameNotEmpty)
@@ -150,6 +159,7 @@ class MailboxCreatorController extends BaseController {
final arguments = DestinationPickerArguments( final arguments = DestinationPickerArguments(
accountId!, accountId!,
MailboxActions.create, MailboxActions.create,
_session,
mailboxIdSelected: selectedMailbox.value?.id); mailboxIdSelected: selectedMailbox.value?.id);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
@@ -1,15 +1,28 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree.dart'; import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree.dart';
class MailboxCreatorArguments with EquatableMixin{ class MailboxCreatorArguments with EquatableMixin{
final AccountId accountId; final AccountId accountId;
final MailboxTree folderMailboxTree; final MailboxTree personalMailboxTree;
final MailboxTree defaultMailboxTree; final MailboxTree defaultMailboxTree;
final MailboxTree teamMailboxesTree;
final Session session;
MailboxCreatorArguments(this.accountId, this.defaultMailboxTree, this.folderMailboxTree); MailboxCreatorArguments(
this.accountId,
this.defaultMailboxTree,
this.personalMailboxTree,
this.teamMailboxesTree,
this.session);
@override @override
List<Object?> get props => [accountId, defaultMailboxTree, folderMailboxTree]; List<Object?> get props => [
accountId,
defaultMailboxTree,
personalMailboxTree,
teamMailboxesTree,
session];
} }
@@ -137,10 +137,12 @@ class AdvancedFilterController extends BaseController {
void selectedMailBox(BuildContext context) async { void selectedMailBox(BuildContext context) async {
final accountId = _mailboxDashBoardController.accountId.value; final accountId = _mailboxDashBoardController.accountId.value;
final _session = _mailboxDashBoardController.sessionCurrent;
if (accountId != null) { if (accountId != null) {
final arguments = DestinationPickerArguments( final arguments = DestinationPickerArguments(
accountId, accountId,
MailboxActions.select, MailboxActions.select,
_session,
mailboxIdSelected: searchController.searchEmailFilter.value.mailbox?.id); mailboxIdSelected: searchController.searchEmailFilter.value.mailbox?.id);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
@@ -733,7 +733,10 @@ class MailboxDashBoardController extends ReloadableController {
PresentationMailbox currentMailbox PresentationMailbox currentMailbox
) async { ) async {
if (accountId.value != null) { if (accountId.value != null) {
final arguments = DestinationPickerArguments(accountId.value!, MailboxActions.moveEmail); final arguments = DestinationPickerArguments(
accountId.value!,
MailboxActions.moveEmail,
sessionCurrent);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
showDialogDestinationPicker( showDialogDestinationPicker(
@@ -234,7 +234,8 @@ class RulesFilterCreatorController extends BaseMailboxController {
if (_accountId != null) { if (_accountId != null) {
final arguments = DestinationPickerArguments( final arguments = DestinationPickerArguments(
_accountId!, _accountId!,
MailboxActions.selectForRuleAction); MailboxActions.selectForRuleAction,
_session);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
showDialogDestinationPicker( showDialogDestinationPicker(
@@ -462,6 +462,7 @@ class SearchEmailController extends BaseController
final arguments = DestinationPickerArguments( final arguments = DestinationPickerArguments(
mailboxDashBoardController.accountId.value!, mailboxDashBoardController.accountId.value!,
MailboxActions.select, MailboxActions.select,
mailboxDashBoardController.sessionCurrent,
mailboxIdSelected: mailbox?.id); mailboxIdSelected: mailbox?.id);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
@@ -110,9 +110,10 @@ mixin EmailActionController on ViewAsDialogActionMixin {
{PresentationMailbox? mailboxContain} {PresentationMailbox? mailboxContain}
) async { ) async {
final accountId = mailboxDashBoardController.accountId.value; final accountId = mailboxDashBoardController.accountId.value;
final _session = mailboxDashBoardController.sessionCurrent;
if (mailboxContain != null && accountId != null) { if (mailboxContain != null && accountId != null) {
final arguments = DestinationPickerArguments(accountId, MailboxActions.moveEmail); final arguments = DestinationPickerArguments(accountId, MailboxActions.moveEmail, _session);
if (BuildUtils.isWeb) { if (BuildUtils.isWeb) {
showDialogDestinationPicker( showDialogDestinationPicker(
+21 -3
View File
@@ -117,10 +117,10 @@ class AppLocalizations {
); );
} }
String get myFolders { String get personalMailboxes {
return Intl.message( return Intl.message(
'My Folders', 'Personal mailboxes',
name: 'myFolders', name: 'personalMailboxes',
); );
} }
@@ -2754,4 +2754,22 @@ class AppLocalizations {
name: 'saveEmailAsDraftFailureWithSetErrorTypeOverQuota', name: 'saveEmailAsDraftFailureWithSetErrorTypeOverQuota',
); );
} }
String get mailBoxes {
return Intl.message(
'Mailboxes',
name: 'mailBoxes');
}
String get teamMailBoxes {
return Intl.message(
'Team-mailboxes',
name: 'teamMailBoxes');
}
String get hideMailBoxes {
return Intl.message(
'Hide mailbox',
name: 'hideMailBoxes');
}
} }
@@ -19,6 +19,7 @@ extension MailboxExtension on Mailbox {
unreadThreads: unreadThreads, unreadThreads: unreadThreads,
myRights: myRights, myRights: myRights,
isSubscribed: isSubscribed, isSubscribed: isSubscribed,
namespace: namespace,
); );
} }
@@ -35,6 +36,7 @@ extension MailboxExtension on Mailbox {
unreadThreads: updatedProperties.contain(MailboxProperty.unreadThreads) ? newMailbox.unreadThreads : unreadThreads, unreadThreads: updatedProperties.contain(MailboxProperty.unreadThreads) ? newMailbox.unreadThreads : unreadThreads,
myRights: updatedProperties.contain(MailboxProperty.myRights) ? newMailbox.myRights : myRights, myRights: updatedProperties.contain(MailboxProperty.myRights) ? newMailbox.myRights : myRights,
isSubscribed: updatedProperties.contain(MailboxProperty.isSubscribed) ? newMailbox.isSubscribed : isSubscribed, isSubscribed: updatedProperties.contain(MailboxProperty.isSubscribed) ? newMailbox.isSubscribed : isSubscribed,
namespace: updatedProperties.contain(MailboxProperty.namespace) ? newMailbox.namespace : namespace,
); );
} }
@@ -51,6 +53,7 @@ extension MailboxExtension on Mailbox {
unreadThreads: unreadThreads, unreadThreads: unreadThreads,
myRights: myRights, myRights: myRights,
isSubscribed: isSubscribed, isSubscribed: isSubscribed,
namespace: namespace,
); );
} }
} }
@@ -18,7 +18,8 @@ extension PresentationMailboxExtension on PresentationMailbox {
isSubscribed: isSubscribed, isSubscribed: isSubscribed,
selectMode: selectMode, selectMode: selectMode,
mailboxPath: mailboxPath, mailboxPath: mailboxPath,
state: state state: state,
namespace: namespace,
); );
} }
@@ -37,7 +38,8 @@ extension PresentationMailboxExtension on PresentationMailbox {
isSubscribed: isSubscribed, isSubscribed: isSubscribed,
selectMode: selectMode, selectMode: selectMode,
mailboxPath: mailboxPath, mailboxPath: mailboxPath,
state: newMailboxState state: newMailboxState,
namespace: namespace,
); );
} }
@@ -53,7 +55,8 @@ extension PresentationMailboxExtension on PresentationMailbox {
totalThreads: totalThreads, totalThreads: totalThreads,
unreadThreads: unreadThreads, unreadThreads: unreadThreads,
myRights: myRights, myRights: myRights,
isSubscribed: isSubscribed isSubscribed: isSubscribed,
namespace: namespace,
); );
} }
@@ -72,7 +75,8 @@ extension PresentationMailboxExtension on PresentationMailbox {
isSubscribed: isSubscribed, isSubscribed: isSubscribed,
mailboxPath: mailboxPath, mailboxPath: mailboxPath,
selectMode: selectMode == SelectMode.INACTIVE ? SelectMode.ACTIVE : SelectMode.INACTIVE, selectMode: selectMode == SelectMode.INACTIVE ? SelectMode.ACTIVE : SelectMode.INACTIVE,
state: state state: state,
namespace: namespace,
); );
} }
@@ -91,7 +95,8 @@ extension PresentationMailboxExtension on PresentationMailbox {
isSubscribed: isSubscribed, isSubscribed: isSubscribed,
mailboxPath: mailboxPath, mailboxPath: mailboxPath,
selectMode: selectMode, selectMode: selectMode,
state: state state: state,
namespace: namespace,
); );
} }
} }
+1
View File
@@ -11,4 +11,5 @@ class MailboxProperty {
static const String unreadThreads = 'unreadThreads'; static const String unreadThreads = 'unreadThreads';
static const String myRights = 'myRights'; static const String myRights = 'myRights';
static const String isSubscribed = 'isSubscribed'; static const String isSubscribed = 'isSubscribed';
static const String namespace = 'namespace';
} }
@@ -2,6 +2,7 @@ import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox_rights.dart'; import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox_rights.dart';
import 'package:jmap_dart_client/jmap/mail/mailbox/namespace.dart';
import 'package:model/mailbox/mailbox_state.dart'; import 'package:model/mailbox/mailbox_state.dart';
import 'package:model/mailbox/select_mode.dart'; import 'package:model/mailbox/select_mode.dart';
@@ -34,6 +35,7 @@ class PresentationMailbox with EquatableMixin {
final SelectMode selectMode; final SelectMode selectMode;
final String? mailboxPath; final String? mailboxPath;
final MailboxState? state; final MailboxState? state;
final Namespace? namespace;
PresentationMailbox( PresentationMailbox(
this.id, this.id,
@@ -51,6 +53,7 @@ class PresentationMailbox with EquatableMixin {
this.selectMode = SelectMode.INACTIVE, this.selectMode = SelectMode.INACTIVE,
this.mailboxPath, this.mailboxPath,
this.state = MailboxState.activated, this.state = MailboxState.activated,
this.namespace,
} }
); );
@@ -60,6 +63,12 @@ class PresentationMailbox with EquatableMixin {
bool hasRole() => role != null && role!.value.isNotEmpty; bool hasRole() => role != null && role!.value.isNotEmpty;
bool get isPersonal => namespace == Namespace('Personal');
bool get isTeamMailboxes => !isPersonal && !hasParentId();
bool get isChildOfTeamMailboxes => !isPersonal && hasParentId();
String getCountUnReadEmails() { String getCountUnReadEmails() {
if (unreadEmails == null || unreadEmails!.value.value <= 0) { if (unreadEmails == null || unreadEmails!.value.value <= 0) {
return ''; return '';
@@ -88,6 +97,10 @@ class PresentationMailbox with EquatableMixin {
} }
} }
String? get nameTeamMailBoxes => namespace?.value.substring(
(namespace?.value.indexOf('[') ?? 0) + 1,
namespace?.value.indexOf(']'));
@override @override
List<Object?> get props => [ List<Object?> get props => [
id, id,
@@ -104,5 +117,6 @@ class PresentationMailbox with EquatableMixin {
selectMode, selectMode,
mailboxPath, mailboxPath,
state, state,
namespace,
]; ];
} }