diff --git a/lib/features/mailbox/presentation/mailbox_controller.dart b/lib/features/mailbox/presentation/mailbox_controller.dart index 2e743ded2..8ff58a67b 100644 --- a/lib/features/mailbox/presentation/mailbox_controller.dart +++ b/lib/features/mailbox/presentation/mailbox_controller.dart @@ -190,6 +190,43 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM ); } + @override + Future toggleMailboxFolder(MailboxNode selectedMailboxNode) async { + final newExpandMode = selectedMailboxNode.expandMode == ExpandMode.COLLAPSE + ? ExpandMode.EXPAND + : ExpandMode.COLLAPSE; + + if (personalMailboxTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) { + log('toggleMailboxFolder() refresh folderMailboxTree'); + personalMailboxTree.refresh(); + final _childrenItems = personalMailboxTree.value.root.childrenItems ?? []; + _triggerScrollWhenExpandMailboxFolder(_childrenItems, selectedMailboxNode); + } + + if (teamMailboxesTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) { + log('toggleMailboxFolder() refresh teamMailboxesTree'); + teamMailboxesTree.refresh(); + final _childrenItems = teamMailboxesTree.value.root.childrenItems ?? []; + _triggerScrollWhenExpandMailboxFolder(_childrenItems, selectedMailboxNode); + } + } + + void _triggerScrollWhenExpandMailboxFolder(List childrenItems, MailboxNode selectedMailboxNode) async { + await Future.delayed(const Duration(milliseconds: 500)); + final _lastItem = childrenItems.last; + if (_lastItem.mailboxNameAsString.contains(selectedMailboxNode.mailboxNameAsString)) { + mailboxListScrollController.animateTo( + mailboxListScrollController.position.maxScrollExtent, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInToLinear); + } else { + mailboxListScrollController.animateTo( + mailboxListScrollController.offset + 100, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInToLinear); + } + } + void handleScrollEnable() { isMailboxListScrollable.value = mailboxListScrollController.hasClients && mailboxListScrollController.position.maxScrollExtent > 0; } @@ -847,7 +884,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM } } - void toggleMailboxCategories(MailboxCategories categories) { + void toggleMailboxCategories(MailboxCategories categories) async { switch(categories) { case MailboxCategories.exchange: final newExpandMode = mailboxCategoriesExpandMode.value.defaultMailbox == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND; @@ -858,11 +895,17 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM final newExpandMode = mailboxCategoriesExpandMode.value.personalMailboxes == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND; mailboxCategoriesExpandMode.value.personalMailboxes = newExpandMode; mailboxCategoriesExpandMode.refresh(); + if (personalMailboxTree.value.root.hasChildren()) { + _triggerToggleMailboxCategories(); + } break; case MailboxCategories.teamMailboxes: final newExpandMode = mailboxCategoriesExpandMode.value.teamMailboxes == ExpandMode.EXPAND ? ExpandMode.COLLAPSE : ExpandMode.EXPAND; mailboxCategoriesExpandMode.value.teamMailboxes = newExpandMode; mailboxCategoriesExpandMode.refresh(); + if (personalMailboxTree.value.root.hasChildren()) { + _triggerToggleMailboxCategories(); + } break; case MailboxCategories.appGrid: final currentExpandMode = mailboxDashBoardController.appGridDashboardController.appDashboardExpandMode.value; @@ -875,6 +918,14 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM } } + void _triggerToggleMailboxCategories() async { + await Future.delayed(const Duration(milliseconds: 500)); + mailboxListScrollController.animateTo( + mailboxListScrollController.offset + 100, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInToLinear); + } + void _handleNavigationRouteParameters(Map? parameters) { log('MailboxController::_handleNavigationRouteParameters(): parameters: $parameters'); if (parameters != null) { diff --git a/lib/features/mailbox/presentation/mailbox_view.dart b/lib/features/mailbox/presentation/mailbox_view.dart index 6fc36208f..683b6ee65 100644 --- a/lib/features/mailbox/presentation/mailbox_view.dart +++ b/lib/features/mailbox/presentation/mailbox_view.dart @@ -68,8 +68,7 @@ class MailboxView extends GetWidget }), ]), ), - Obx(() => controller.isMailboxListScrollable.isTrue - && !controller.isSelectionEnabled() + Obx(() => !controller.isSelectionEnabled() ? const QuotasFooterWidget() : const SizedBox.shrink(), ), @@ -264,13 +263,6 @@ class MailboxView extends GetWidget return const SizedBox.shrink(); } }), - Obx(() { - if (controller.isMailboxListScrollable.isFalse) { - return const QuotasFooterWidget(); - } else { - return const SizedBox.shrink(); - } - }), ]) ), );