TF-1831 Handle system back button in setting view
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit 5f00c1adcb1bc45ec47b1cff1eb738228264dee1)
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/views/button/icon_button_web.dart';
|
||||
import 'package:flex_color_picker/flex_color_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
|
||||
typedef SelectColorActionCallback = Function(Color? colorSelected);
|
||||
@@ -11,7 +12,6 @@ class ColorPickerDialogBuilder {
|
||||
final SelectColorActionCallback? setColorActionCallback;
|
||||
final VoidCallback? cancelActionCallback;
|
||||
final VoidCallback? resetToDefaultActionCallback;
|
||||
final BuildContext _context;
|
||||
final Color defaultColor;
|
||||
final ValueNotifier<Color> _currentColor;
|
||||
final String? title;
|
||||
@@ -24,7 +24,6 @@ class ColorPickerDialogBuilder {
|
||||
Color _colorCode = Colors.black;
|
||||
|
||||
ColorPickerDialogBuilder(
|
||||
this._context,
|
||||
this._currentColor,
|
||||
{
|
||||
this.onSelected,
|
||||
@@ -39,9 +38,9 @@ class ColorPickerDialogBuilder {
|
||||
}
|
||||
);
|
||||
|
||||
Future show() async {
|
||||
await showDialog(context: _context, builder: (BuildContext context) {
|
||||
return PointerInterceptor(
|
||||
Future<dynamic> show() async {
|
||||
return Get.dialog(
|
||||
PointerInterceptor(
|
||||
child: AlertDialog(
|
||||
title: Text(
|
||||
title ?? '',
|
||||
@@ -151,8 +150,8 @@ class ColorPickerDialogBuilder {
|
||||
})
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget _itemColorWidget(BuildContext context, Color color) {
|
||||
|
||||
@@ -5,10 +5,10 @@ import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:html/parser.dart' show parse;
|
||||
import 'package:model/email/attachment.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:html/parser.dart' show parse;
|
||||
|
||||
abstract class BaseRichTextController extends GetxController {
|
||||
|
||||
@@ -21,7 +21,6 @@ abstract class BaseRichTextController extends GetxController {
|
||||
}
|
||||
) async {
|
||||
await ColorPickerDialogBuilder(
|
||||
context,
|
||||
ValueNotifier<Color>(currentColor),
|
||||
title: AppLocalizations.of(context).chooseAColor,
|
||||
textActionSetColor: AppLocalizations.of(context).setColor,
|
||||
|
||||
@@ -1065,7 +1065,7 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
|
||||
}
|
||||
|
||||
void _replaceBrowserHistory() {
|
||||
log('MailboxController::_updateSelectedMailboxRouteOnBrowser:selectedMailbox: ${selectedMailbox?.id}');
|
||||
log('MailboxController::_replaceBrowserHistory:selectedMailbox: ${selectedMailbox?.id}');
|
||||
if (PlatformInfo.isWeb) {
|
||||
final selectedMailboxId = selectedMailbox?.id;
|
||||
final route = RouteUtils.createUrlWebLocationBar(
|
||||
|
||||
+67
-9
@@ -140,6 +140,7 @@ import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/dialog_router.dart';
|
||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
|
||||
@@ -259,7 +260,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
@override
|
||||
void onInit() {
|
||||
_registerStreamListener();
|
||||
BackButtonInterceptor.add(onBackButtonInterceptor);
|
||||
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.dashboard);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@@ -1409,11 +1410,13 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
|
||||
void goToSettings() async {
|
||||
closeMailboxMenuDrawer();
|
||||
BackButtonInterceptor.removeByName(AppRoutes.dashboard);
|
||||
final result = await push(
|
||||
AppRoutes.settings,
|
||||
arguments: ManageAccountArguments(sessionCurrent)
|
||||
);
|
||||
|
||||
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.dashboard);
|
||||
if (result is VacationResponse) {
|
||||
vacationResponse.value = result;
|
||||
dispatchMailboxUIAction(RefreshChangeMailboxAction(null));
|
||||
@@ -1468,11 +1471,16 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
|
||||
void goToVacationSetting() async {
|
||||
final result = await push(AppRoutes.settings,
|
||||
arguments: ManageAccountArguments(
|
||||
sessionCurrent,
|
||||
menuSettingCurrent: AccountMenuItem.vacation));
|
||||
BackButtonInterceptor.removeByName(AppRoutes.dashboard);
|
||||
final result = await push(
|
||||
AppRoutes.settings,
|
||||
arguments: ManageAccountArguments(
|
||||
sessionCurrent,
|
||||
menuSettingCurrent: AccountMenuItem.vacation
|
||||
)
|
||||
);
|
||||
|
||||
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.dashboard);
|
||||
if (result is VacationResponse) {
|
||||
vacationResponse.value = result;
|
||||
}
|
||||
@@ -2224,8 +2232,42 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
setSelectedEmail(email.toPresentationEmail());
|
||||
}
|
||||
|
||||
bool onBackButtonInterceptor(bool stopDefaultButtonEvent, RouteInfo routeInfo) {
|
||||
log('MailboxDashBoardController::onBackButtonInterceptor:stopDefaultButtonEvent: $stopDefaultButtonEvent | routeInfo: ${routeInfo.routeWhenAdded}');
|
||||
void _replaceBrowserHistory() {
|
||||
if (PlatformInfo.isWeb) {
|
||||
final selectedMailboxId = selectedMailbox.value?.id;
|
||||
final selectedEmailId = selectedEmail.value?.id;
|
||||
final isSearchRunning = searchController.isSearchEmailRunning;
|
||||
String title = '';
|
||||
if (selectedEmail.value != null) {
|
||||
title = 'Email-${selectedEmailId?.asString ?? ''}';
|
||||
} else if (isSearchRunning) {
|
||||
title = 'SearchEmail';
|
||||
} else {
|
||||
title = 'Mailbox-${selectedMailboxId?.asString}';
|
||||
}
|
||||
RouteUtils.replaceBrowserHistory(
|
||||
title: title,
|
||||
url: RouteUtils.createUrlWebLocationBar(
|
||||
AppRoutes.dashboard,
|
||||
router: NavigationRouter(
|
||||
emailId: selectedEmail.value?.id,
|
||||
mailboxId: isSearchRunning
|
||||
? null
|
||||
: selectedMailboxId,
|
||||
dashboardType: isSearchRunning
|
||||
? DashboardType.search
|
||||
: DashboardType.normal,
|
||||
searchQuery: isSearchRunning
|
||||
? searchController.searchQuery
|
||||
: null
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool _navigateToScreen() {
|
||||
log('MailboxDashBoardController::_navigateToScreen: dashboardRoute: $dashboardRoute');
|
||||
switch(dashboardRoute.value) {
|
||||
case DashboardRoutes.emailDetailed:
|
||||
dispatchEmailUIAction(CloseEmailDetailedViewAction());
|
||||
@@ -2255,8 +2297,24 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
dispatchAction(CloseSearchEmailViewAction());
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool get _isDialogViewOpen => Get.isOverlaysOpen == true;
|
||||
|
||||
bool _onBackButtonInterceptor(bool stopDefaultButtonEvent, RouteInfo routeInfo) {
|
||||
log('MailboxDashBoardController::_onBackButtonInterceptor:currentRoute: ${Get.currentRoute} | _isDialogViewOpen: $_isDialogViewOpen');
|
||||
if (_isDialogViewOpen) {
|
||||
popBack();
|
||||
_replaceBrowserHistory();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Get.currentRoute.startsWith(AppRoutes.dashboard)) {
|
||||
return _navigateToScreen();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2270,7 +2328,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
_refreshActionEventController.close();
|
||||
_notificationManager.closeStream();
|
||||
_fcmService.closeStream();
|
||||
BackButtonInterceptor.remove(onBackButtonInterceptor);
|
||||
BackButtonInterceptor.removeByName(AppRoutes.dashboard);
|
||||
MailboxDashBoardBindings().deleteController();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
+113
-13
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:forward/forward/capability_forward.dart';
|
||||
@@ -31,6 +32,7 @@ import 'package:tmail_ui_user/features/manage_account/presentation/vacation/vaca
|
||||
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
|
||||
@@ -48,6 +50,13 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
final dashboardSettingAction = Rxn<UIAction>();
|
||||
|
||||
Session? sessionCurrent;
|
||||
bool? isVacationDateDialogDisplayed;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.settings);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
@@ -74,16 +83,17 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
|
||||
@override
|
||||
void handleReloaded(Session session) {
|
||||
log('ManageAccountDashBoardController::handleReloaded:');
|
||||
sessionCurrent = session;
|
||||
accountId.value = session.personalAccount.accountId;
|
||||
_getUserProfile();
|
||||
_bindingInteractorForMenuItemView(sessionCurrent, accountId.value);
|
||||
_getVacationResponse();
|
||||
_getParametersRouter();
|
||||
}
|
||||
|
||||
void _getArguments() {
|
||||
final arguments = Get.arguments;
|
||||
log('ManageAccountDashBoardController::_getArguments(): $arguments');
|
||||
if (arguments is ManageAccountArguments) {
|
||||
sessionCurrent = arguments.session;
|
||||
accountId.value = arguments.session?.personalAccount.accountId;
|
||||
@@ -91,13 +101,28 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
_bindingInteractorForMenuItemView(sessionCurrent, accountId.value);
|
||||
_getVacationResponse();
|
||||
if (arguments.menuSettingCurrent != null) {
|
||||
_goToSettingMenuCurrent(arguments.menuSettingCurrent!);
|
||||
selectAccountMenuItem(arguments.menuSettingCurrent!);
|
||||
}
|
||||
} else if (PlatformInfo.isWeb) {
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
void _getParametersRouter() {
|
||||
final parameters = Get.parameters;
|
||||
log('ManageAccountDashBoardController::_getParametersRouter:parameters: $parameters');
|
||||
final navigationRouter = RouteUtils.parsingRouteParametersToNavigationRouter(parameters);
|
||||
log('ManageAccountDashBoardController::_getParametersRouter:navigationRouter: $navigationRouter');
|
||||
if (navigationRouter.accountMenuItem == AccountMenuItem.none &&
|
||||
currentContext != null &&
|
||||
responsiveUtils.isWebDesktop(currentContext!)
|
||||
) {
|
||||
selectAccountMenuItem(AccountMenuItem.profiles);
|
||||
} else {
|
||||
selectAccountMenuItem(navigationRouter.accountMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
void _initialPageLevel() {
|
||||
if (currentContext != null && responsiveUtils.isWebDesktop(currentContext!)) {
|
||||
settingsPageLevel.value = SettingsPageLevel.level1;
|
||||
@@ -154,6 +179,7 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
clearInputFormView();
|
||||
_bindingControllerMenuItemView(newAccountMenuItem);
|
||||
accountMenuItemSelected.value = newAccountMenuItem;
|
||||
_replaceBrowserHistory();
|
||||
}
|
||||
|
||||
void _bindingControllerMenuItemView(AccountMenuItem item) {
|
||||
@@ -189,17 +215,15 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
}
|
||||
}
|
||||
|
||||
void _goToSettingMenuCurrent(AccountMenuItem accountMenuItem) {
|
||||
selectAccountMenuItem(accountMenuItem);
|
||||
}
|
||||
|
||||
void goToSettings() {
|
||||
popAndPush(AppRoutes.settings,
|
||||
arguments: ManageAccountArguments(sessionCurrent));
|
||||
popAndPush(
|
||||
AppRoutes.settings,
|
||||
arguments: ManageAccountArguments(sessionCurrent)
|
||||
);
|
||||
}
|
||||
|
||||
void backToMailboxDashBoard(BuildContext context) {
|
||||
if (canBack(context)) {
|
||||
void backToMailboxDashBoard({BuildContext? context}) {
|
||||
if (context != null && canBack(context)) {
|
||||
popBack(result: vacationResponse.value);
|
||||
} else {
|
||||
log('ManageAccountDashBoardController::backToMailboxDashBoard(): canBack: FALSE');
|
||||
@@ -269,10 +293,86 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> backButtonPressedCallbackAction(BuildContext context) async {
|
||||
if (PlatformInfo.isMobile) {
|
||||
backToMailboxDashBoard(context);
|
||||
void selectSettings(AccountMenuItem accountMenuItem) {
|
||||
log('ManageAccountDashBoardController::selectSettings(): $accountMenuItem');
|
||||
selectAccountMenuItem(accountMenuItem);
|
||||
settingsPageLevel.value = SettingsPageLevel.level1;
|
||||
}
|
||||
|
||||
void backToUniversalSettings() {
|
||||
log('ManageAccountDashBoardController::backToUniversalSettings()');
|
||||
clearInputFormView();
|
||||
selectAccountMenuItem(AccountMenuItem.none);
|
||||
settingsPageLevel.value = SettingsPageLevel.universal;
|
||||
_replaceBrowserHistory();
|
||||
}
|
||||
|
||||
void _replaceBrowserHistory() {
|
||||
if (PlatformInfo.isWeb) {
|
||||
RouteUtils.replaceBrowserHistory(
|
||||
title: accountMenuItemSelected.value == AccountMenuItem.none
|
||||
? 'Setting'
|
||||
: 'Setting-${accountMenuItemSelected.value.getAliasBrowser()}',
|
||||
url: RouteUtils.createUrlWebLocationBar(
|
||||
AppRoutes.settings,
|
||||
router: NavigationRouter(accountMenuItem: accountMenuItemSelected.value)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool _navigateToScreen() {
|
||||
log('ManageAccountDashBoardController::_navigateToScreen: settingsPageLevel: $settingsPageLevel');
|
||||
if (PlatformInfo.isMobile) {
|
||||
switch(settingsPageLevel.value) {
|
||||
case SettingsPageLevel.level1:
|
||||
backToUniversalSettings();
|
||||
return true;
|
||||
case SettingsPageLevel.universal:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (currentContext != null && responsiveUtils.isWebDesktop(currentContext!)) {
|
||||
if (accountMenuItemSelected.value == AccountMenuItem.profiles) {
|
||||
backToMailboxDashBoard(context: currentContext);
|
||||
return true;
|
||||
} else {
|
||||
selectSettings(AccountMenuItem.profiles);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
switch(settingsPageLevel.value) {
|
||||
case SettingsPageLevel.level1:
|
||||
backToUniversalSettings();
|
||||
return true;
|
||||
case SettingsPageLevel.universal:
|
||||
backToMailboxDashBoard(context: currentContext);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool get _isDialogViewOpen => Get.isOverlaysOpen == true;
|
||||
|
||||
bool _onBackButtonInterceptor(bool stopDefaultButtonEvent, RouteInfo routeInfo) {
|
||||
log('ManageAccountDashBoardController::_onBackButtonInterceptor:currentRoute: ${Get.currentRoute} | _isDialogViewOpen: $_isDialogViewOpen');
|
||||
if (_isDialogViewOpen || isVacationDateDialogDisplayed == true) {
|
||||
popBack();
|
||||
_replaceBrowserHistory();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Get.currentRoute.startsWith(AppRoutes.settings)) {
|
||||
return _navigateToScreen();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
BackButtonInterceptor.removeByName(AppRoutes.settings);
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,19 @@ import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/mixin/user_setting_popup_menu_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/mailbox_visibility/mailbox_visibility_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings_utils.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/email_rules/email_rules_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/forward/forward_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/language_and_region/language_and_region_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/mailbox_visibility/mailbox_visibility_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/manage_account_menu_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings/settings_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings_utils.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/profiles_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/vacation_view.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
@@ -31,96 +31,93 @@ class ManageAccountDashBoardView extends GetWidget<ManageAccountDashBoardControl
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => controller.backButtonPressedCallbackAction.call(context),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
drawerEnableOpenDragGesture: false,
|
||||
body: GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: ResponsiveWidget(
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
desktop: Column(children: [
|
||||
Row(children: [
|
||||
Container(width: 256, color: Colors.white,
|
||||
padding: SettingsUtils.getPaddingHeaderSetting(context),
|
||||
child: Row(children: [
|
||||
SloganBuilder(
|
||||
sizeLogo: 24,
|
||||
text: AppLocalizations.of(context).app_name,
|
||||
textAlign: TextAlign.center,
|
||||
textStyle: const TextStyle(color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
logoSVG: controller.imagePaths.icTMailLogo,
|
||||
onTapCallback: () => controller.backToMailboxDashBoard(context),
|
||||
),
|
||||
Obx(() {
|
||||
if (controller.appInformation.value != null) {
|
||||
return Padding(padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
'v.${controller.appInformation.value!.version}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.w500),
|
||||
));
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
])
|
||||
),
|
||||
Expanded(child: Padding(
|
||||
padding: SettingsUtils.getPaddingRightHeaderSetting(context),
|
||||
child: _buildRightHeader(context)))
|
||||
]),
|
||||
Expanded(child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: ResponsiveUtils.defaultSizeMenu,
|
||||
child: ManageAccountMenuView()
|
||||
),
|
||||
Expanded(child: Container(
|
||||
color: AppColor.colorBgDesktop,
|
||||
child: Column(children: [
|
||||
Obx(() {
|
||||
if (controller.vacationResponse.value?.vacationResponderIsValid == true) {
|
||||
return VacationNotificationMessageWidget(
|
||||
margin: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: PlatformInfo.isWeb ? 24 : 16,
|
||||
right: PlatformInfo.isWeb ? 24 : 16),
|
||||
fromAccountDashBoard: true,
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
actionGotoVacationSetting: !controller.inVacationSettings()
|
||||
? () => controller.selectAccountMenuItem(AccountMenuItem.vacation)
|
||||
: null,
|
||||
actionEndNow: () => controller.disableVacationResponder());
|
||||
} else if ((controller.vacationResponse.value?.vacationResponderIsWaiting == true
|
||||
|| controller.vacationResponse.value?.vacationResponderIsStopped == true)
|
||||
&& controller.accountMenuItemSelected.value == AccountMenuItem.vacation) {
|
||||
return VacationNotificationMessageWidget(
|
||||
margin: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: PlatformInfo.isWeb ? 24 : 16,
|
||||
right: PlatformInfo.isWeb ? 24 : 16),
|
||||
fromAccountDashBoard: true,
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
leadingIcon: const Padding(
|
||||
padding: EdgeInsets.only(right: 16),
|
||||
child: Icon(Icons.timer, size: 20),
|
||||
));
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
Expanded(child: _viewDisplayedOfAccountMenuItem())
|
||||
]),
|
||||
))
|
||||
],
|
||||
))
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
drawerEnableOpenDragGesture: false,
|
||||
body: GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: ResponsiveWidget(
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
desktop: Column(children: [
|
||||
Row(children: [
|
||||
Container(width: 256, color: Colors.white,
|
||||
padding: SettingsUtils.getPaddingHeaderSetting(context),
|
||||
child: Row(children: [
|
||||
SloganBuilder(
|
||||
sizeLogo: 24,
|
||||
text: AppLocalizations.of(context).app_name,
|
||||
textAlign: TextAlign.center,
|
||||
textStyle: const TextStyle(color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
logoSVG: controller.imagePaths.icTMailLogo,
|
||||
onTapCallback: () => controller.backToMailboxDashBoard(context: context),
|
||||
),
|
||||
Obx(() {
|
||||
if (controller.appInformation.value != null) {
|
||||
return Padding(padding: const EdgeInsets.only(top: 6),
|
||||
child: Text(
|
||||
'v.${controller.appInformation.value!.version}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 13, color: AppColor.colorContentEmail, fontWeight: FontWeight.w500),
|
||||
));
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
])
|
||||
),
|
||||
Expanded(child: Padding(
|
||||
padding: SettingsUtils.getPaddingRightHeaderSetting(context),
|
||||
child: _buildRightHeader(context)))
|
||||
]),
|
||||
mobile: SettingsView(closeAction: () => controller.backToMailboxDashBoard(context))
|
||||
),
|
||||
Expanded(child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: ResponsiveUtils.defaultSizeMenu,
|
||||
child: ManageAccountMenuView()
|
||||
),
|
||||
Expanded(child: Container(
|
||||
color: AppColor.colorBgDesktop,
|
||||
child: Column(children: [
|
||||
Obx(() {
|
||||
if (controller.vacationResponse.value?.vacationResponderIsValid == true) {
|
||||
return VacationNotificationMessageWidget(
|
||||
margin: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: PlatformInfo.isWeb ? 24 : 16,
|
||||
right: PlatformInfo.isWeb ? 24 : 16),
|
||||
fromAccountDashBoard: true,
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
actionGotoVacationSetting: !controller.inVacationSettings()
|
||||
? () => controller.selectAccountMenuItem(AccountMenuItem.vacation)
|
||||
: null,
|
||||
actionEndNow: () => controller.disableVacationResponder());
|
||||
} else if ((controller.vacationResponse.value?.vacationResponderIsWaiting == true
|
||||
|| controller.vacationResponse.value?.vacationResponderIsStopped == true)
|
||||
&& controller.accountMenuItemSelected.value == AccountMenuItem.vacation) {
|
||||
return VacationNotificationMessageWidget(
|
||||
margin: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: PlatformInfo.isWeb ? 24 : 16,
|
||||
right: PlatformInfo.isWeb ? 24 : 16),
|
||||
fromAccountDashBoard: true,
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
leadingIcon: const Padding(
|
||||
padding: EdgeInsets.only(right: 16),
|
||||
child: Icon(Icons.timer, size: 20),
|
||||
));
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
Expanded(child: _viewDisplayedOfAccountMenuItem())
|
||||
]),
|
||||
))
|
||||
],
|
||||
))
|
||||
]),
|
||||
mobile: SettingsView(closeAction: () => controller.backToMailboxDashBoard(context: context))
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -61,6 +61,6 @@ class ManageAccountMenuController extends GetxController {
|
||||
}
|
||||
|
||||
void backToMailboxDashBoard(BuildContext context) {
|
||||
dashBoardController.backToMailboxDashBoard(context);
|
||||
dashBoardController.backToMailboxDashBoard(context: context);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/settings_page_level.dart';
|
||||
|
||||
class SettingsController extends GetxController {
|
||||
final manageAccountDashboardController = Get.find<ManageAccountDashBoardController>();
|
||||
@@ -13,18 +11,9 @@ class SettingsController extends GetxController {
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
final settingScrollController = ScrollController();
|
||||
|
||||
void selectSettings(AccountMenuItem accountMenuItem) {
|
||||
log('SettingsController::selectSettings(): $accountMenuItem');
|
||||
manageAccountDashboardController.selectAccountMenuItem(accountMenuItem);
|
||||
manageAccountDashboardController.settingsPageLevel.value = SettingsPageLevel.level1;
|
||||
}
|
||||
void selectSettings(AccountMenuItem accountMenuItem) => manageAccountDashboardController.selectSettings(accountMenuItem);
|
||||
|
||||
void backToUniversalSettings() {
|
||||
log('SettingsController::backToUniversalSettings()');
|
||||
manageAccountDashboardController.clearInputFormView();
|
||||
manageAccountDashboardController.selectAccountMenuItem(AccountMenuItem.none);
|
||||
manageAccountDashboardController.settingsPageLevel.value = SettingsPageLevel.universal;
|
||||
}
|
||||
void backToUniversalSettings() => manageAccountDashboardController.backToUniversalSettings();
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
|
||||
@@ -49,4 +49,23 @@ enum AccountMenuItem {
|
||||
return AppLocalizations.of(context).profiles;
|
||||
}
|
||||
}
|
||||
|
||||
String getAliasBrowser() {
|
||||
switch(this) {
|
||||
case AccountMenuItem.profiles:
|
||||
return 'profiles';
|
||||
case AccountMenuItem.languageAndRegion:
|
||||
return 'language-region';
|
||||
case AccountMenuItem.emailRules:
|
||||
return 'email-rules';
|
||||
case AccountMenuItem.forward:
|
||||
return 'forwarding';
|
||||
case AccountMenuItem.vacation:
|
||||
return 'vacation';
|
||||
case AccountMenuItem.mailboxVisibility:
|
||||
return 'folder-visibility';
|
||||
case AccountMenuItem.none:
|
||||
return 'profiles';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,7 @@ class VacationController extends BaseController {
|
||||
}
|
||||
|
||||
void selectDate(BuildContext context, DateType dateType, DateTime? currentDate) async {
|
||||
_accountDashBoardController.isVacationDateDialogDisplayed = true;
|
||||
final datePicked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: currentDate ?? DateTime.now(),
|
||||
@@ -161,17 +162,25 @@ class VacationController extends BaseController {
|
||||
lastDate: DateTime(2100),
|
||||
locale: Localizations.localeOf(context),
|
||||
builder: (context, child) {
|
||||
return Theme(
|
||||
return PointerInterceptor(
|
||||
child: Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: AppColor.primaryColor,
|
||||
onPrimary: Colors.white,
|
||||
onSurface: Colors.black),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(foregroundColor: AppColor.primaryColor))),
|
||||
child: child!);
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: AppColor.primaryColor,
|
||||
onPrimary: Colors.white,
|
||||
onSurface: Colors.black
|
||||
),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: AppColor.primaryColor
|
||||
)
|
||||
)
|
||||
),
|
||||
child: child!
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
).whenComplete(() => _accountDashBoardController.isVacationDateDialogDisplayed = false);
|
||||
|
||||
if (datePicked == null) {
|
||||
return;
|
||||
@@ -185,6 +194,7 @@ class VacationController extends BaseController {
|
||||
}
|
||||
|
||||
void selectTime(BuildContext context, DateType dateType, TimeOfDay? currentTime) async {
|
||||
_accountDashBoardController.isVacationDateDialogDisplayed = true;
|
||||
final timePicked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: currentTime ?? TimeOfDay.now(),
|
||||
@@ -204,7 +214,7 @@ class VacationController extends BaseController {
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
).whenComplete(() => _accountDashBoardController.isVacationDateDialogDisplayed = false);
|
||||
|
||||
if (timePicked == null) {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
|
||||
enum DashboardType {
|
||||
@@ -19,6 +20,7 @@ class NavigationRouter with EquatableMixin {
|
||||
final EmailAddress? emailAddress;
|
||||
final String? subject;
|
||||
final String? body;
|
||||
final AccountMenuItem accountMenuItem;
|
||||
|
||||
NavigationRouter({
|
||||
this.emailId,
|
||||
@@ -29,6 +31,7 @@ class NavigationRouter with EquatableMixin {
|
||||
this.emailAddress,
|
||||
this.subject,
|
||||
this.body,
|
||||
this.accountMenuItem = AccountMenuItem.none,
|
||||
});
|
||||
|
||||
factory NavigationRouter.initial() => NavigationRouter();
|
||||
@@ -43,5 +46,6 @@ class NavigationRouter with EquatableMixin {
|
||||
emailAddress,
|
||||
subject,
|
||||
body,
|
||||
accountMenuItem,
|
||||
];
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/service_path_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||
@@ -31,17 +32,23 @@ abstract class RouteUtils {
|
||||
|
||||
static String get baseOriginUrl => Uri.base.origin;
|
||||
|
||||
static String get baseUrl => Uri.base.path;
|
||||
static Uri get baseUri => Uri.base;
|
||||
|
||||
static String generateNavigationRoute(String route, {NavigationRouter? router}) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
return _createServicePath(route, router: router).path;
|
||||
if (route == AppRoutes.dashboard) {
|
||||
return _createDashboardServicePath(route, router: router).path;
|
||||
} else if (route == AppRoutes.settings) {
|
||||
return _createSettingServicePath(route, router: router).path;
|
||||
} else {
|
||||
return _createServicePath(route).path;
|
||||
}
|
||||
} else {
|
||||
return route;
|
||||
}
|
||||
}
|
||||
|
||||
static ServicePath _createServicePath(String route, {NavigationRouter? router}) {
|
||||
static ServicePath _createDashboardServicePath(String route, {NavigationRouter? router}) {
|
||||
ServicePath servicePath = ServicePath(route);
|
||||
if (router != null) {
|
||||
if (router.emailId != null) {
|
||||
@@ -62,9 +69,35 @@ abstract class RouteUtils {
|
||||
return servicePath;
|
||||
}
|
||||
|
||||
static ServicePath _createSettingServicePath(String route, {NavigationRouter? router}) {
|
||||
ServicePath servicePath = ServicePath(route);
|
||||
if (router != null && router.accountMenuItem != AccountMenuItem.none) {
|
||||
servicePath = servicePath.withQueryParameters([
|
||||
StringQueryParameter(paramType, router.accountMenuItem.getAliasBrowser())
|
||||
]);
|
||||
}
|
||||
return servicePath;
|
||||
}
|
||||
|
||||
static ServicePath _createServicePath(String route) {
|
||||
ServicePath servicePath = ServicePath(route);
|
||||
return servicePath;
|
||||
}
|
||||
|
||||
static Uri createUrlWebLocationBar(String route, {NavigationRouter? router}) {
|
||||
final servicePath = _createServicePath('$baseOriginUrl$route', router: router);
|
||||
return Uri.parse(servicePath.path);
|
||||
if (route == AppRoutes.dashboard) {
|
||||
final servicePath = _createDashboardServicePath(
|
||||
'$baseOriginUrl$route',
|
||||
router: router
|
||||
);
|
||||
return Uri.parse(servicePath.path);
|
||||
} else if (route == AppRoutes.settings) {
|
||||
final servicePath = _createSettingServicePath('$baseOriginUrl$route', router: router);
|
||||
return Uri.parse(servicePath.path);
|
||||
} else {
|
||||
final servicePath = _createServicePath('$baseOriginUrl$route');
|
||||
return Uri.parse(servicePath.path);
|
||||
}
|
||||
}
|
||||
|
||||
static NavigationRouter parsingRouteParametersToNavigationRouter(Map<String, String?> parameters) {
|
||||
@@ -80,9 +113,8 @@ abstract class RouteUtils {
|
||||
final emailId = idParam != null ? EmailId(Id(idParam)) : null;
|
||||
final mailboxId = contextPram != null ? MailboxId(Id(contextPram)) : null;
|
||||
final searchQuery = queryParam != null ? SearchQuery(queryParam) : null;
|
||||
final dashboardType = typeParam == DashboardType.search.name
|
||||
? DashboardType.search
|
||||
: DashboardType.normal;
|
||||
final dashboardType = DashboardType.values.firstWhereOrNull((type) => type.name == typeParam) ?? DashboardType.normal;
|
||||
final settingType = AccountMenuItem.values.firstWhereOrNull((type) => type.getAliasBrowser() == typeParam) ?? AccountMenuItem.none;
|
||||
final emailAddress = mailtoAddress != null && GetUtils.isEmail(mailtoAddress)
|
||||
? EmailAddress(null, mailtoAddress)
|
||||
: EmailAddress(null, INVALID_VALUE);
|
||||
@@ -96,6 +128,7 @@ abstract class RouteUtils {
|
||||
emailAddress: emailAddress,
|
||||
subject: subject,
|
||||
body: body,
|
||||
accountMenuItem: settingType,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user