TF-233 Create mailbox location
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/state/get_all_mailboxes_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/usecases/get_all_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_action.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_tree_builder.dart';
|
||||
@@ -21,8 +23,8 @@ class DestinationPickerController extends BaseController {
|
||||
MailboxTree folderMailboxTree = MailboxTree(MailboxNode.root());
|
||||
final defaultMailboxList = <PresentationMailbox>[].obs;
|
||||
final folderMailboxNodeList = <MailboxNode>[].obs;
|
||||
|
||||
DestinationPickerArguments? destinationPickerArguments;
|
||||
final mailboxAction = Rxn<MailboxAction>();
|
||||
AccountId? accountId;
|
||||
|
||||
DestinationPickerController(
|
||||
this._getAllMailboxInteractor,
|
||||
@@ -32,8 +34,10 @@ class DestinationPickerController extends BaseController {
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
if (Get.arguments != null && Get.arguments is DestinationPickerArguments) {
|
||||
destinationPickerArguments = Get.arguments;
|
||||
final arguments = Get.arguments;
|
||||
if (arguments != null && arguments is DestinationPickerArguments) {
|
||||
mailboxAction.value = arguments.mailboxAction;
|
||||
accountId = arguments.accountId;
|
||||
getAllMailboxAction();
|
||||
}
|
||||
}
|
||||
@@ -61,9 +65,8 @@ class DestinationPickerController extends BaseController {
|
||||
void onError(error) {}
|
||||
|
||||
void getAllMailboxAction() {
|
||||
final accountId = destinationPickerArguments?.accountId;
|
||||
if (accountId != null) {
|
||||
consumeState(_getAllMailboxInteractor.execute(accountId));
|
||||
consumeState(_getAllMailboxInteractor.execute(accountId!));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/destination_picker_controller.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/widgets/app_bar_destination_picker_builder.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/state/get_all_mailboxes_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_action.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_displayed.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_node.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/mailbox_folder_tile_builder.dart';
|
||||
@@ -17,44 +19,130 @@ class DestinationPickerView extends GetWidget<DestinationPickerController> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => controller.closeDestinationPicker(),
|
||||
child: Card(
|
||||
margin: EdgeInsets.zero,
|
||||
borderOnForeground: false,
|
||||
color: Colors.transparent,
|
||||
child: Container(
|
||||
margin: _getMarginDestinationPicker(context),
|
||||
child: ClipRRect(
|
||||
borderRadius: _radiusDestinationPicker(context, 20),
|
||||
child: GestureDetector(
|
||||
onTap: () => {},
|
||||
child: SafeArea(
|
||||
top: _responsiveUtils.isMobile(context) ? true : false,
|
||||
bottom: false,
|
||||
right: false,
|
||||
left: false,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildAppBar(context),
|
||||
Expanded(child:
|
||||
Container(
|
||||
color: AppColor.colorBgMailbox,
|
||||
child: _buildBodyDestinationPicker(context)))
|
||||
],
|
||||
DestinationPickerArguments? _destinationPickerArguments;
|
||||
final arguments = Get.arguments;
|
||||
if (arguments != null && arguments is DestinationPickerArguments) {
|
||||
_destinationPickerArguments = arguments;
|
||||
}
|
||||
|
||||
if (_destinationPickerArguments?.mailboxAction == MailboxAction.create) {
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
borderOnForeground: false,
|
||||
color: Colors.transparent,
|
||||
child: GestureDetector(
|
||||
onTap: () => controller.closeDestinationPicker(),
|
||||
child: ResponsiveWidget(
|
||||
responsiveUtils: _responsiveUtils,
|
||||
mobile: Container(
|
||||
child: _buildBody(context),
|
||||
width: _responsiveUtils.getSizeWidthScreen(context)),
|
||||
tablet: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex: 1, child: Container(color: Colors.transparent)),
|
||||
Expanded(flex: 1, child: _buildBody(context)),
|
||||
]
|
||||
)
|
||||
),
|
||||
tabletLarge: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex: 7, child: Container(color: Colors.transparent)),
|
||||
Expanded(flex: 13, child: _buildBody(context)),
|
||||
]
|
||||
)
|
||||
),
|
||||
desktop: Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex: 1, child: Container(color: Colors.transparent)),
|
||||
Expanded(flex: 3, child: _buildBody(context)),
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return GestureDetector(
|
||||
onTap: () => controller.closeDestinationPicker(),
|
||||
child: Card(
|
||||
margin: EdgeInsets.zero,
|
||||
borderOnForeground: false,
|
||||
color: Colors.transparent,
|
||||
child: Container(
|
||||
margin: _getMarginDestinationPicker(context),
|
||||
child: ClipRRect(
|
||||
borderRadius: _radiusDestinationPicker(context, 14),
|
||||
child: GestureDetector(
|
||||
onTap: () => {},
|
||||
child: SafeArea(
|
||||
top: _responsiveUtils.isMobile(context) ? true : false,
|
||||
bottom: false,
|
||||
right: false,
|
||||
left: false,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildAppBar(context),
|
||||
Expanded(child:
|
||||
Container(
|
||||
color: AppColor.colorBgMailbox,
|
||||
child: _buildBodyDestinationPicker(context)))
|
||||
],
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context) {
|
||||
return SafeArea(
|
||||
top: _responsiveUtils.isMobile(context) ? true : false,
|
||||
bottom: false,
|
||||
left: false,
|
||||
right: false,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(_responsiveUtils.isMobile(context) ? 14 : 0),
|
||||
topLeft: Radius.circular(_responsiveUtils.isMobile(context) ? 14 : 0)),
|
||||
child: Drawer(
|
||||
child: Container(
|
||||
color: AppColor.colorBgMailbox,
|
||||
width: double.infinity,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
left: _responsiveUtils.isMobileDevice(context) ? true : false,
|
||||
right: _responsiveUtils.isMobileDevice(context) ? true : false,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildAppBar(context),
|
||||
Expanded(child:
|
||||
Container(
|
||||
color: AppColor.colorBgMailbox,
|
||||
child: _buildBodyDestinationPicker(context)))
|
||||
]
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
return (AppBarDestinationPickerBuilder(context, _imagePaths, _responsiveUtils)
|
||||
return Obx(() => (AppBarDestinationPickerBuilder(
|
||||
context,
|
||||
_imagePaths,
|
||||
_responsiveUtils,
|
||||
controller.mailboxAction.value)
|
||||
..addCloseActionClick(() => controller.closeDestinationPicker()))
|
||||
.build();
|
||||
.build());
|
||||
}
|
||||
|
||||
Widget _buildBodyDestinationPicker(BuildContext context) {
|
||||
|
||||
+5
-7
@@ -1,16 +1,14 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_action.dart';
|
||||
|
||||
class DestinationPickerArguments with EquatableMixin{
|
||||
class DestinationPickerArguments with EquatableMixin {
|
||||
final AccountId accountId;
|
||||
final List<EmailId> emailIds;
|
||||
final PresentationMailbox currentMailbox;
|
||||
final MailboxAction mailboxAction;
|
||||
|
||||
DestinationPickerArguments(this.accountId, this.emailIds, this.currentMailbox);
|
||||
DestinationPickerArguments(this.accountId, this.mailboxAction);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [accountId, emailIds, currentMailbox];
|
||||
List<Object?> get props => [accountId, mailboxAction];
|
||||
}
|
||||
+37
-14
@@ -2,7 +2,7 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_action.dart';
|
||||
|
||||
typedef OnCloseActionClick = void Function();
|
||||
|
||||
@@ -12,8 +12,14 @@ class AppBarDestinationPickerBuilder {
|
||||
final BuildContext _context;
|
||||
final ImagePaths _imagePaths;
|
||||
final ResponsiveUtils _responsiveUtils;
|
||||
final MailboxAction? _mailboxAction;
|
||||
|
||||
AppBarDestinationPickerBuilder(this._context, this._imagePaths, this._responsiveUtils);
|
||||
AppBarDestinationPickerBuilder(
|
||||
this._context,
|
||||
this._imagePaths,
|
||||
this._responsiveUtils,
|
||||
this._mailboxAction,
|
||||
);
|
||||
|
||||
void addCloseActionClick(OnCloseActionClick onCloseActionClick) {
|
||||
_onCloseActionClick = onCloseActionClick;
|
||||
@@ -23,7 +29,7 @@ class AppBarDestinationPickerBuilder {
|
||||
return Container(
|
||||
key: Key('app_bar_destination_picker'),
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)),
|
||||
color: Colors.white),
|
||||
@@ -34,7 +40,7 @@ class AppBarDestinationPickerBuilder {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
_buildBackButton(),
|
||||
Expanded(child: _buildCountItemSelected())
|
||||
Expanded(child: _buildTitle())
|
||||
]
|
||||
)
|
||||
)
|
||||
@@ -45,24 +51,41 @@ class AppBarDestinationPickerBuilder {
|
||||
return Material(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
color: AppColor.baseTextColor,
|
||||
icon: SvgPicture.asset(_imagePaths.icComposerClose, fit: BoxFit.fill),
|
||||
onPressed: () => _onCloseActionClick?.call()
|
||||
)
|
||||
child: _responsiveUtils.isMobile(_context)
|
||||
? IconButton(
|
||||
color: _mailboxAction == MailboxAction.create ? AppColor.colorTextButton : AppColor.baseTextColor,
|
||||
icon: _getBackIcon(),
|
||||
onPressed: () => _onCloseActionClick?.call())
|
||||
: SizedBox(width: 40, height: 40)
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCountItemSelected() {
|
||||
Widget _buildTitle() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12,
|
||||
right: _responsiveUtils.isMobile(_context) ? 0 : 47),
|
||||
right: 47),
|
||||
child: Text(
|
||||
AppLocalizations.of(_context).move_to_mailbox,
|
||||
_mailboxAction?.getTitle(_context) ?? '',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: _responsiveUtils.isMobile(_context) ? TextAlign.start : TextAlign.center,
|
||||
style: TextStyle(fontSize: 18, color: AppColor.nameUserColor, fontWeight: FontWeight.w500)));
|
||||
textAlign: _getAlignTitle(),
|
||||
style: TextStyle(fontSize: 17, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700)));
|
||||
}
|
||||
|
||||
TextAlign _getAlignTitle() {
|
||||
if (_mailboxAction == MailboxAction.create) {
|
||||
return TextAlign.center;
|
||||
} else {
|
||||
return _responsiveUtils.isMobile(_context) ? TextAlign.start : TextAlign.center;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _getBackIcon() {
|
||||
if (_mailboxAction == MailboxAction.create) {
|
||||
return SvgPicture.asset(_imagePaths.icBack, fit: BoxFit.fill);
|
||||
} else {
|
||||
return SvgPicture.asset(_imagePaths.icComposerClose, fit: BoxFit.fill);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user