TF-2261 Fix app bar email view broken

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit 5e26472141f1f4562f4e7e75034c4566dcd9351b)
This commit is contained in:
dab246
2023-10-20 22:00:17 +07:00
committed by Dat H. Pham
parent 25f4677d42
commit c74ac62050
5 changed files with 237 additions and 191 deletions
+209 -187
View File
@@ -53,185 +53,217 @@ class EmailView extends GetWidget<SingleEmailController> {
onWillPop: () => controller.backButtonPressedCallbackAction.call(context), onWillPop: () => controller.backButtonPressedCallbackAction.call(context),
child: Scaffold( child: Scaffold(
backgroundColor: responsiveUtils.isWebDesktop(context) backgroundColor: responsiveUtils.isWebDesktop(context)
? AppColor.colorBgDesktop ? AppColor.colorBgDesktop
: Colors.white, : Colors.white,
body: Row(children: [ appBar: PlatformInfo.isIOS
if (_supportVerticalDivider(context)) ? PreferredSize(
const VerticalDivider( preferredSize: const Size(double.infinity, 100),
color: AppColor.lineItemListColor, child: Obx(() {
width: 12), if (controller.currentEmail != null) {
Expanded(child: SafeArea( return SafeArea(
right: responsiveUtils.isLandscapeMobile(context), top: false,
left: responsiveUtils.isLandscapeMobile(context), bottom: false,
bottom: !PlatformInfo.isIOS, child: EmailViewAppBarWidget(
child: Container( key: const Key('email_view_app_bar_widget'),
clipBehavior: Clip.antiAlias, presentationEmail: controller.currentEmail!,
decoration: responsiveUtils.isWebDesktop(context) mailboxContain: _getMailboxContain(controller.currentEmail!),
? BoxDecoration( isSearchActivated: controller.mailboxDashBoardController.searchController.isSearchEmailRunning,
borderRadius: BorderRadius.circular(20), onBackAction: () => controller.closeEmailView(context),
border: Border.all(color: AppColor.colorBorderBodyThread, width: 1), onEmailActionClick: (email, action) => controller.handleEmailAction(context, email, action),
color: Colors.white) onMoreActionClick: (email, position) {
: const BoxDecoration(color: Colors.white), if (position == null) {
margin: _getMarginEmailView(context), controller.openContextMenuAction(
child: Obx(() { context,
final currentEmail = controller.currentEmail; _emailActionMoreActionTile(context, email)
if (currentEmail != null) { );
return Column(children: [ } else {
Obx(() => EmailViewAppBarWidget( controller.openPopupMenuAction(
key: const Key('email_view_app_bar_widget'), context,
presentationEmail: currentEmail, position,
mailboxContain: _getMailboxContain(currentEmail), _popupMenuEmailActionTile(context, email)
isSearchActivated: controller.mailboxDashBoardController.searchController.isSearchEmailRunning, );
onBackAction: () => controller.closeEmailView(context), }
onEmailActionClick: (email, action) => controller.handleEmailAction(context, email, action), },
onMoreActionClick: (email, position) { ),
if (position == null) { );
controller.openContextMenuAction( } else {
context, return const SizedBox.shrink();
_emailActionMoreActionTile(context, email) }
); })
} else { )
controller.openPopupMenuAction( : null,
context, body: SafeArea(
position, right: responsiveUtils.isLandscapeMobile(context),
_popupMenuEmailActionTile(context, email) left: responsiveUtils.isLandscapeMobile(context),
); bottom: !PlatformInfo.isIOS,
} child: Container(
}, clipBehavior: Clip.antiAlias,
optionsWidget: PlatformInfo.isWeb && controller.emailSupervisorController.supportedPageView.isTrue decoration: responsiveUtils.isWebDesktop(context)
? _buildNavigatorPageViewWidgets(context) ? BoxDecoration(
: null, borderRadius: BorderRadius.circular(20),
)), border: Border.all(color: AppColor.colorBorderBodyThread, width: 1),
Obx(() { color: Colors.white)
final vacation = controller.mailboxDashBoardController.vacationResponse.value; : const BoxDecoration(color: Colors.white),
if (vacation?.vacationResponderIsValid == true && margin: _getMarginEmailView(context),
( child: Obx(() {
responsiveUtils.isMobile(context) || final currentEmail = controller.currentEmail;
responsiveUtils.isTablet(context) || if (currentEmail != null) {
responsiveUtils.isLandscapeMobile(context) return Column(children: [
) if (!PlatformInfo.isIOS)
) { Obx(() => EmailViewAppBarWidget(
return VacationNotificationMessageWidget( key: const Key('email_view_app_bar_widget'),
margin: const EdgeInsets.only(left: 12, right: 12, bottom: 5), presentationEmail: currentEmail,
vacationResponse: vacation!, mailboxContain: _getMailboxContain(currentEmail),
actionGotoVacationSetting: controller.mailboxDashBoardController.goToVacationSetting, isSearchActivated: controller.mailboxDashBoardController.searchController.isSearchEmailRunning,
actionEndNow: controller.mailboxDashBoardController.disableVacationResponder onBackAction: () => controller.closeEmailView(context),
); onEmailActionClick: (email, action) => controller.handleEmailAction(context, email, action),
} else { onMoreActionClick: (email, position) {
return const SizedBox.shrink(); if (position == null) {
} controller.openContextMenuAction(
}), context,
Expanded( _emailActionMoreActionTile(context, email)
child: Obx(() { );
if (controller.emailSupervisorController.supportedPageView.isTrue) { } else {
final currentListEmail = controller.emailSupervisorController.currentListEmail; controller.openPopupMenuAction(
return PageView.builder( context,
physics: controller.emailSupervisorController.scrollPhysicsPageView.value, position,
itemCount: currentListEmail.length, _popupMenuEmailActionTile(context, email)
allowImplicitScrolling: true, );
controller: controller.emailSupervisorController.pageController, }
onPageChanged: controller.emailSupervisorController.onPageChanged, },
itemBuilder: (context, index) { optionsWidget: PlatformInfo.isWeb && controller.emailSupervisorController.supportedPageView.isTrue
final currentEmail = currentListEmail[index]; ? _buildNavigatorPageViewWidgets(context)
if (PlatformInfo.isMobile) { : null,
return SingleChildScrollView( )),
physics : const ClampingScrollPhysics(), Obx(() {
child: Container( final vacation = controller.mailboxDashBoardController.vacationResponse.value;
width: double.infinity, if (vacation?.vacationResponderIsValid == true &&
alignment: Alignment.center, (
color: Colors.white, responsiveUtils.isMobile(context) ||
child: Obx(() => _buildEmailMessage( responsiveUtils.isTablet(context) ||
context: context, responsiveUtils.isLandscapeMobile(context)
presentationEmail: currentEmail, )
calendarEvent: controller.calendarEvent.value, ) {
)) return VacationNotificationMessageWidget(
) margin: const EdgeInsets.only(left: 12, right: 12, bottom: 5),
); vacationResponse: vacation!,
} else { actionGotoVacationSetting: controller.mailboxDashBoardController.goToVacationSetting,
return Obx(() { actionEndNow: controller.mailboxDashBoardController.disableVacationResponder
final calendarEvent = controller.calendarEvent.value; );
if (currentEmail.hasCalendarEvent && calendarEvent != null) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: calendarEvent,
emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(),
)
)
);
} else {
return _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
);
}
});
}
}
);
} else {
if (PlatformInfo.isMobile) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: Obx(() => _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: controller.calendarEvent.value,
))
)
);
} else {
return Obx(() {
final calendarEvent = controller.calendarEvent.value;
if (currentEmail.hasCalendarEvent && calendarEvent != null) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: calendarEvent,
emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(),
)
)
);
} else {
return _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
);
}
});
}
}
}),
),
EmailViewBottomBarWidget(
key: const Key('email_view_button_bar'),
presentationEmail: currentEmail,
emailActionCallback: controller.pressEmailAction
),
]);
} else { } else {
return const EmailViewEmptyWidget(); return const SizedBox.shrink();
} }
}) }),
) Expanded(
)) child: Obx(() {
]) if (controller.emailSupervisorController.supportedPageView.isTrue) {
final currentListEmail = controller.emailSupervisorController.currentListEmail;
return PageView.builder(
physics: controller.emailSupervisorController.scrollPhysicsPageView.value,
itemCount: currentListEmail.length,
allowImplicitScrolling: true,
controller: controller.emailSupervisorController.pageController,
onPageChanged: controller.emailSupervisorController.onPageChanged,
itemBuilder: (context, index) {
final currentEmail = currentListEmail[index];
if (PlatformInfo.isMobile) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: Obx(() => _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: controller.calendarEvent.value,
))
)
);
} else {
return Obx(() {
final calendarEvent = controller.calendarEvent.value;
if (currentEmail.hasCalendarEvent && calendarEvent != null) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: calendarEvent,
emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(),
)
)
);
} else {
return _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
);
}
});
}
}
);
} else {
if (PlatformInfo.isMobile) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: Obx(() => _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: controller.calendarEvent.value,
))
)
);
} else {
return Obx(() {
final calendarEvent = controller.calendarEvent.value;
if (currentEmail.hasCalendarEvent && calendarEvent != null) {
return SingleChildScrollView(
physics : const ClampingScrollPhysics(),
child: Container(
width: double.infinity,
alignment: Alignment.center,
color: Colors.white,
child: _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
calendarEvent: calendarEvent,
emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(),
)
)
);
} else {
return _buildEmailMessage(
context: context,
presentationEmail: currentEmail,
);
}
});
}
}
}),
),
EmailViewBottomBarWidget(
key: const Key('email_view_button_bar'),
presentationEmail: currentEmail,
emailActionCallback: controller.pressEmailAction
),
]);
} else {
return const EmailViewEmptyWidget();
}
})
)
)
) )
); );
} }
@@ -253,16 +285,6 @@ class EmailView extends GetWidget<SingleEmailController> {
} }
} }
bool _supportVerticalDivider(BuildContext context) {
if (PlatformInfo.isWeb) {
return responsiveUtils.isTabletLarge(context);
} else {
return responsiveUtils.isLandscapeTablet(context) ||
responsiveUtils.isDesktop(context) ||
responsiveUtils.isTabletLarge(context);
}
}
PresentationMailbox? _getMailboxContain(PresentationEmail currentEmail) { PresentationMailbox? _getMailboxContain(PresentationEmail currentEmail) {
return currentEmail.findMailboxContain(controller.mailboxDashBoardController.mapMailboxById); return currentEmail.findMailboxContain(controller.mailboxDashBoardController.mapMailboxById);
} }
@@ -1,6 +1,7 @@
import 'package:core/presentation/extensions/color_extension.dart'; import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/icon_utils.dart'; import 'package:core/presentation/utils/icon_utils.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class EmailViewAppBarWidgetStyles { class EmailViewAppBarWidgetStyles {
@@ -11,7 +12,13 @@ class EmailViewAppBarWidgetStyles {
static const double buttonIconSize = IconUtils.defaultIconSize; static const double buttonIconSize = IconUtils.defaultIconSize;
static const double deleteButtonIconSize = 20; static const double deleteButtonIconSize = 20;
static const double space = 5; static const double space = 5;
static double? heightIOS(BuildContext context, ResponsiveUtils responsiveUtils) {
if (responsiveUtils.isLandscapeMobile(context)) {
return 60;
} else {
return null;
}
}
static const Color bottomBorderColor = AppColor.colorDividerHorizontal; static const Color bottomBorderColor = AppColor.colorDividerHorizontal;
static const Color backgroundColor = Colors.white; static const Color backgroundColor = Colors.white;
static const Color emptyTrashButtonColor = AppColor.primaryColor; static const Color emptyTrashButtonColor = AppColor.primaryColor;
@@ -19,6 +26,15 @@ class EmailViewAppBarWidgetStyles {
static const Color buttonActivatedColor = AppColor.primaryColor; static const Color buttonActivatedColor = AppColor.primaryColor;
static const Color buttonDeactivatedColor = AppColor.colorAttachmentIcon; static const Color buttonDeactivatedColor = AppColor.colorAttachmentIcon;
static const EdgeInsetsGeometry padding = EdgeInsets.symmetric(horizontal: 16); static EdgeInsetsGeometry paddingIOS(BuildContext context, ResponsiveUtils responsiveUtils) {
if (responsiveUtils.isLandscapeMobile(context)) {
return EdgeInsets.zero;
} else if (responsiveUtils.isPortraitTablet(context) || responsiveUtils.isLandscapeTablet(context)) {
return const EdgeInsetsDirectional.only(top: 40, start: 16, end: 16, bottom: 4);
} else {
return const EdgeInsetsDirectional.only(top: 60, start: 16, end: 16, bottom: 4);
}
}
static const EdgeInsetsGeometry padding = EdgeInsetsDirectional.symmetric(horizontal: 16);
static const EdgeInsetsGeometry buttonPadding = EdgeInsets.all(5); static const EdgeInsetsGeometry buttonPadding = EdgeInsets.all(5);
} }
@@ -42,8 +42,12 @@ class EmailViewAppBarWidget extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) { return LayoutBuilder(builder: (context, constraints) {
return Container( return Container(
height: EmailViewAppBarWidgetStyles.height, height: PlatformInfo.isIOS
padding: EmailViewAppBarWidgetStyles.padding, ? EmailViewAppBarWidgetStyles.heightIOS(context, _responsiveUtils)
: EmailViewAppBarWidgetStyles.height,
padding: PlatformInfo.isIOS
? EmailViewAppBarWidgetStyles.paddingIOS(context, _responsiveUtils)
: EmailViewAppBarWidgetStyles.padding,
decoration: const BoxDecoration( decoration: const BoxDecoration(
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
@@ -25,6 +25,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
SizedBox( SizedBox(
width: ResponsiveUtils.defaultSizeLeftMenuMobile, width: ResponsiveUtils.defaultSizeLeftMenuMobile,
child: _buildScaffoldHaveDrawer(body: ThreadView())), child: _buildScaffoldHaveDrawer(body: ThreadView())),
const VerticalDivider(color: AppColor.lineItemListColor, width: 12),
Expanded(child: EmailView()), Expanded(child: EmailView()),
], ],
); );
@@ -62,6 +63,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
SizedBox( SizedBox(
width: ResponsiveUtils.defaultSizeLeftMenuMobile, width: ResponsiveUtils.defaultSizeLeftMenuMobile,
child: _buildScaffoldHaveDrawer(body: const SendingQueueView())), child: _buildScaffoldHaveDrawer(body: const SendingQueueView())),
const VerticalDivider(color: AppColor.lineItemListColor, width: 12),
Expanded(child: EmailView()), Expanded(child: EmailView()),
], ],
); );
@@ -184,6 +184,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
SizedBox( SizedBox(
width: ResponsiveUtils.defaultSizeLeftMenuMobile, width: ResponsiveUtils.defaultSizeLeftMenuMobile,
child: ThreadView()), child: ThreadView()),
const VerticalDivider(color: AppColor.lineItemListColor, width: 12),
Expanded(child: EmailView()), Expanded(child: EmailView()),
], ],
), ),
@@ -196,6 +197,7 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
SizedBox( SizedBox(
width: ResponsiveUtils.defaultSizeLeftMenuMobile, width: ResponsiveUtils.defaultSizeLeftMenuMobile,
child: ThreadView()), child: ThreadView()),
const VerticalDivider(color: AppColor.lineItemListColor, width: 12),
Expanded(child: EmailView()), Expanded(child: EmailView()),
], ],
), ),