TF-599 Handle move mailbox action for mailbox
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_mailbox_controller.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
|
||||
@@ -30,6 +31,7 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
final searchQuery = SearchQuery.initial().obs;
|
||||
final mailboxCategoriesExpandMode = MailboxCategoriesExpandMode.initial().obs;
|
||||
|
||||
MailboxId? mailboxIdSelected;
|
||||
AccountId? accountId;
|
||||
final searchInputController = TextEditingController();
|
||||
final searchFocus = FocusNode();
|
||||
@@ -46,6 +48,7 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
final arguments = Get.arguments;
|
||||
if (arguments != null && arguments is DestinationPickerArguments) {
|
||||
mailboxAction.value = arguments.mailboxAction;
|
||||
mailboxIdSelected = arguments.mailboxIdSelected;
|
||||
accountId = arguments.accountId;
|
||||
getAllMailboxAction();
|
||||
}
|
||||
@@ -56,7 +59,14 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
super.onData(newState);
|
||||
newState.map((success) {
|
||||
if (success is GetAllMailboxSuccess) {
|
||||
buildTree(success.mailboxList);
|
||||
if (mailboxAction.value == MailboxActions.move && mailboxIdSelected != null) {
|
||||
final newMailboxList = success.mailboxList
|
||||
.where((mailbox) => mailbox.id != mailboxIdSelected)
|
||||
.toList();
|
||||
buildTree(newMailboxList);
|
||||
} else {
|
||||
buildTree(success.mailboxList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
Widget _buildSearchBarWidget(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: _responsiveUtils.isScreenWithShortestSide(context) || kIsWeb ? 12 : 0,
|
||||
top: _responsiveUtils.isScreenWithShortestSide(context) || BuildUtils.isWeb ? 12 : 0,
|
||||
left: _responsiveUtils.isLandscapeMobile(context) ? 0 : 16,
|
||||
right: 16),
|
||||
child: (SearchBarView(_imagePaths)
|
||||
@@ -174,17 +174,19 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
primary: false,
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
if (actions == MailboxActions.moveEmail) _buildSearchBarWidget(context),
|
||||
if (actions == MailboxActions.moveEmail || actions == MailboxActions.move)
|
||||
_buildSearchBarWidget(context),
|
||||
_buildLoadingView(),
|
||||
if (actions == MailboxActions.create && !BuildUtils.isWeb && _responsiveUtils.isScreenWithShortestSide(context))
|
||||
const SizedBox(height: 12),
|
||||
if (actions == MailboxActions.create) _buildUnifiedMailbox(context),
|
||||
if (actions == MailboxActions.create || actions == MailboxActions.move)
|
||||
_buildUnifiedMailbox(context, actions),
|
||||
const SizedBox(height: 12),
|
||||
Obx(() => controller.defaultMailboxHasChild
|
||||
? _buildMailboxCategory(context, MailboxCategories.exchange, controller.defaultRootNode, actions)
|
||||
: const SizedBox.shrink()),
|
||||
if (actions == MailboxActions.create) const SizedBox(height: 12),
|
||||
if (actions != MailboxActions.create && !kIsWeb)
|
||||
if (actions != MailboxActions.create && !BuildUtils.isWeb)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 60),
|
||||
child: Divider(color: AppColor.lineItemListColor, height: 0.5, thickness: 0.2)),
|
||||
@@ -197,7 +199,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
}
|
||||
|
||||
Widget _buildMailboxCategory(BuildContext context, MailboxCategories categories, MailboxNode mailboxNode, MailboxActions? actions) {
|
||||
if (actions == MailboxActions.moveEmail) {
|
||||
if (actions == MailboxActions.moveEmail || actions == MailboxActions.move) {
|
||||
return _buildBodyMailboxCategory(context, categories, mailboxNode, actions);
|
||||
}
|
||||
return Column(children: [
|
||||
@@ -237,12 +239,18 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
return Container(
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), color: Colors.white),
|
||||
margin: EdgeInsets.only(
|
||||
left: actions == MailboxActions.moveEmail ? 8 : _responsiveUtils.isLandscapeMobile(context) ? 0 : 16,
|
||||
right: actions == MailboxActions.moveEmail ? 0 : 16),
|
||||
left: actions == MailboxActions.moveEmail
|
||||
|| actions == MailboxActions.move
|
||||
|| _responsiveUtils.isLandscapeMobile(context)
|
||||
? 0
|
||||
: 16,
|
||||
right: actions == MailboxActions.moveEmail || actions == MailboxActions.move
|
||||
? 0
|
||||
: 16),
|
||||
padding: EdgeInsets.only(
|
||||
top: _responsiveUtils.isDesktop(context) && actions == MailboxActions.create ? 8 : 0,
|
||||
bottom: _responsiveUtils.isDesktop(context) && actions == MailboxActions.create ? 8 : 0,
|
||||
left: _responsiveUtils.isDesktop(context) ? 0 : 12,
|
||||
left: _responsiveUtils.isDesktop(context) || actions != MailboxActions.create ? 0 : 12,
|
||||
right: actions == MailboxActions.create ? 8 : 16),
|
||||
child: TreeView(
|
||||
key: Key('${categories.keyValue}_mailbox_list'),
|
||||
@@ -297,12 +305,43 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildUnifiedMailbox(BuildContext context) {
|
||||
Widget _buildUnifiedMailbox(BuildContext context, MailboxActions? actions) {
|
||||
if (actions == MailboxActions.move) {
|
||||
return InkWell(
|
||||
onTap: () => controller.selectMailboxAction(null),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(14)),
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.only(left: 16, top: 16),
|
||||
child: Row(children: [
|
||||
SvgPicture.asset(
|
||||
_imagePaths.icFolderMailbox,
|
||||
width: BuildUtils.isWeb ? 20 : 24,
|
||||
height: BuildUtils.isWeb ? 20 : 24,
|
||||
fit: BoxFit.fill),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(
|
||||
AppLocalizations.of(context).default_mailbox,
|
||||
maxLines: 1,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: AppColor.colorNameEmail,
|
||||
fontWeight: FontWeight.normal),
|
||||
)),
|
||||
const SizedBox(width: 8),
|
||||
])
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
margin: EdgeInsets.only(
|
||||
left: !_responsiveUtils.isLandscapeMobile(context) ? 16 : 0,
|
||||
top: kIsWeb ? 16 : 0,
|
||||
top: BuildUtils.isWeb ? 16 : 0,
|
||||
right: 16),
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(14), color: Colors.white),
|
||||
child: MediaQuery(
|
||||
@@ -323,7 +362,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
Expanded(child: Text(
|
||||
AppLocalizations.of(context).default_mailbox,
|
||||
maxLines: 1,
|
||||
overflow:TextOverflow.ellipsis,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 15, color: AppColor.colorNameEmail),
|
||||
))
|
||||
]
|
||||
|
||||
+4
-2
@@ -1,14 +1,16 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
||||
|
||||
class DestinationPickerArguments with EquatableMixin {
|
||||
final AccountId accountId;
|
||||
final MailboxActions mailboxAction;
|
||||
final MailboxId? mailboxIdSelected;
|
||||
|
||||
DestinationPickerArguments(this.accountId, this.mailboxAction);
|
||||
DestinationPickerArguments(this.accountId, this.mailboxAction, {this.mailboxIdSelected});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [accountId, mailboxAction];
|
||||
List<Object?> get props => [accountId, mailboxAction, mailboxIdSelected];
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ class AppBarDestinationPickerBuilder {
|
||||
}
|
||||
|
||||
Widget _buildCancelButton() {
|
||||
if (_mailboxAction == MailboxActions.moveEmail) {
|
||||
if (_mailboxAction == MailboxActions.moveEmail || _mailboxAction == MailboxActions.move) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Material(
|
||||
|
||||
Reference in New Issue
Block a user