TF-2311 Sync use variables in BaseController to avoid wasting memory
Signed-off-by: dab246 <tdvu@linagora.com> Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit 21ac80615f7bc9e832fd72cb8ae6875c967d3cea)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
@@ -9,7 +10,8 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
class ManageAccountMenuController extends GetxController {
|
||||
|
||||
final dashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
final listAccountMenuItem = RxList<AccountMenuItem>([
|
||||
AccountMenuItem.profiles,
|
||||
@@ -46,7 +48,7 @@ class ManageAccountMenuController extends GetxController {
|
||||
listAccountMenuItem.value = newListMenuSetting;
|
||||
|
||||
if (listAccountMenuItem.isNotEmpty) {
|
||||
if (currentContext != null && _responsiveUtils.isWebDesktop(currentContext!)) {
|
||||
if (currentContext != null && responsiveUtils.isWebDesktop(currentContext!)) {
|
||||
selectAccountMenuItem(listAccountMenuItem.first);
|
||||
} else {
|
||||
selectAccountMenuItem(AccountMenuItem.none);
|
||||
|
||||
@@ -10,21 +10,18 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
ManageAccountMenuView({Key? key}) : super(key: key);
|
||||
const ManageAccountMenuView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
elevation: _responsiveUtils.isDesktop(context) ? 0 : 16.0,
|
||||
elevation: controller.responsiveUtils.isDesktop(context) ? 0 : 16.0,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: SafeArea(right: false, bottom: false,
|
||||
child: Column(
|
||||
children: [
|
||||
if (!_responsiveUtils.isWebDesktop(context))
|
||||
if (!controller.responsiveUtils.isWebDesktop(context))
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 16, left: 16),
|
||||
@@ -34,7 +31,7 @@ class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
text: AppLocalizations.of(context).app_name,
|
||||
textAlign: TextAlign.center,
|
||||
textStyle: const TextStyle(color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold),
|
||||
logoSVG: _imagePaths.icTMailLogo
|
||||
logoSVG: controller.imagePaths.icTMailLogo
|
||||
),
|
||||
Obx(() {
|
||||
if (controller.dashBoardController.appInformation.value != null) {
|
||||
@@ -52,10 +49,10 @@ class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
}),
|
||||
])
|
||||
),
|
||||
if (!_responsiveUtils.isWebDesktop(context))
|
||||
if (!controller.responsiveUtils.isWebDesktop(context))
|
||||
const Divider(color: AppColor.colorDividerMailbox, height: 1),
|
||||
Expanded(child: Container(
|
||||
color: _responsiveUtils.isWebDesktop(context) ? AppColor.colorBgDesktop : Colors.white,
|
||||
color: controller.responsiveUtils.isWebDesktop(context) ? AppColor.colorBgDesktop : Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -65,8 +62,8 @@ class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
key: const Key('back_to_dashboard_button'),
|
||||
text: AppLocalizations.of(context).back,
|
||||
icon: DirectionUtils.isDirectionRTLByLanguage(context)
|
||||
? _imagePaths.icArrowRight
|
||||
: _imagePaths.icBack,
|
||||
? controller.imagePaths.icArrowRight
|
||||
: controller.imagePaths.icBack,
|
||||
borderRadius: 10,
|
||||
backgroundColor: AppColor.colorBgMailboxSelected,
|
||||
iconColor: AppColor.colorTextButton,
|
||||
@@ -133,7 +130,7 @@ class ManageAccountMenuView extends GetWidget<ManageAccountMenuController> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Row(children: [
|
||||
SvgPicture.asset(_imagePaths.icSignOut, fit: BoxFit.fill),
|
||||
SvgPicture.asset(controller.imagePaths.icSignOut, fit: BoxFit.fill),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Text(
|
||||
AppLocalizations.of(context).sign_out,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
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:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
@@ -6,6 +8,8 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/setting
|
||||
|
||||
class SettingsController extends GetxController {
|
||||
final manageAccountDashboardController = Get.find<ManageAccountDashBoardController>();
|
||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
void selectSettings(AccountMenuItem accountMenuItem) {
|
||||
log('SettingsController::selectSettings(): $accountMenuItem');
|
||||
|
||||
+23
-28
@@ -1,6 +1,4 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/user_information_widget.dart';
|
||||
@@ -11,10 +9,7 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/account
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
||||
SettingsFirstLevelView({Key? key}) : super(key: key);
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
const SettingsFirstLevelView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -22,40 +17,40 @@ class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
||||
child: Column(children: [
|
||||
Obx(() => UserInformationWidget(
|
||||
userProfile: controller.manageAccountDashboardController.userProfile.value,
|
||||
padding: SettingsUtils.getPaddingInFirstLevel(context, _responsiveUtils),
|
||||
padding: SettingsUtils.getPaddingInFirstLevel(context, controller.responsiveUtils),
|
||||
titlePadding: const EdgeInsetsDirectional.only(start: 16))),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
SettingFirstLevelTileBuilder(
|
||||
AppLocalizations.of(context).profiles,
|
||||
AccountMenuItem.profiles.getIcon(_imagePaths),
|
||||
AccountMenuItem.profiles.getIcon(controller.imagePaths),
|
||||
subtitle: AppLocalizations.of(context).profilesSettingExplanation,
|
||||
() => controller.selectSettings(AccountMenuItem.profiles)
|
||||
),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
Obx(() {
|
||||
if (controller.manageAccountDashboardController.isRuleFilterCapabilitySupported) {
|
||||
return Column(children: [
|
||||
SettingFirstLevelTileBuilder(
|
||||
AccountMenuItem.emailRules.getName(context),
|
||||
AccountMenuItem.emailRules.getIcon(_imagePaths),
|
||||
AccountMenuItem.emailRules.getIcon(controller.imagePaths),
|
||||
subtitle: AppLocalizations.of(context).emailRuleSettingExplanation,
|
||||
() => controller.selectSettings(AccountMenuItem.emailRules)
|
||||
),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
]);
|
||||
} else {
|
||||
@@ -67,15 +62,15 @@ class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
||||
return Column(children: [
|
||||
SettingFirstLevelTileBuilder(
|
||||
AccountMenuItem.forward.getName(context),
|
||||
AccountMenuItem.forward.getIcon(_imagePaths),
|
||||
AccountMenuItem.forward.getIcon(controller.imagePaths),
|
||||
subtitle: AppLocalizations.of(context).forwardingSettingExplanation,
|
||||
() => controller.selectSettings(AccountMenuItem.forward)
|
||||
),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
]);
|
||||
} else {
|
||||
@@ -87,15 +82,15 @@ class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
||||
return Column(children: [
|
||||
SettingFirstLevelTileBuilder(
|
||||
AccountMenuItem.vacation.getName(context),
|
||||
AccountMenuItem.vacation.getIcon(_imagePaths),
|
||||
AccountMenuItem.vacation.getIcon(controller.imagePaths),
|
||||
subtitle: AppLocalizations.of(context).vacationSettingExplanation,
|
||||
() => controller.selectSettings(AccountMenuItem.vacation)
|
||||
),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
]);
|
||||
} else {
|
||||
@@ -105,31 +100,31 @@ class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
||||
Column(children: [
|
||||
SettingFirstLevelTileBuilder(
|
||||
AccountMenuItem.mailboxVisibility.getName(context),
|
||||
AccountMenuItem.mailboxVisibility.getIcon(_imagePaths),
|
||||
AccountMenuItem.mailboxVisibility.getIcon(controller.imagePaths),
|
||||
subtitle: AppLocalizations.of(context).folderVisibilitySubtitle,
|
||||
() => controller.selectSettings(AccountMenuItem.mailboxVisibility)
|
||||
),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
]),
|
||||
SettingFirstLevelTileBuilder(
|
||||
AccountMenuItem.languageAndRegion.getName(context),
|
||||
AccountMenuItem.languageAndRegion.getIcon(_imagePaths),
|
||||
AccountMenuItem.languageAndRegion.getIcon(controller.imagePaths),
|
||||
() => controller.selectSettings(AccountMenuItem.languageAndRegion)
|
||||
),
|
||||
Divider(
|
||||
color: AppColor.colorDividerComposer,
|
||||
height: 1,
|
||||
indent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, _responsiveUtils)
|
||||
indent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils),
|
||||
endIndent: SettingsUtils.getHorizontalPadding(context, controller.responsiveUtils)
|
||||
),
|
||||
SettingFirstLevelTileBuilder(
|
||||
AppLocalizations.of(context).sign_out,
|
||||
_imagePaths.icSignOut,
|
||||
controller.imagePaths.icSignOut,
|
||||
() => controller.manageAccountDashboardController.logout(
|
||||
controller.manageAccountDashboardController.sessionCurrent,
|
||||
controller.manageAccountDashboardController.accountId.value)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:core/presentation/utils/style_utils.dart';
|
||||
import 'package:core/presentation/views/button/icon_button_web.dart';
|
||||
import 'package:core/utils/direction_utils.dart';
|
||||
@@ -27,10 +25,8 @@ import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
typedef CloseSettingsViewAction = void Function();
|
||||
|
||||
class SettingsView extends GetWidget<SettingsController> {
|
||||
SettingsView({Key? key, this.closeAction}) : super(key: key);
|
||||
const SettingsView({Key? key, this.closeAction}) : super(key: key);
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final CloseSettingsViewAction? closeAction;
|
||||
|
||||
@override
|
||||
@@ -44,7 +40,7 @@ class SettingsView extends GetWidget<SettingsController> {
|
||||
SizedBox.fromSize(
|
||||
size: const Size.fromHeight(52),
|
||||
child: Padding(
|
||||
padding: SettingsUtils.getPaddingAppBar(context, _responsiveUtils),
|
||||
padding: SettingsUtils.getPaddingAppBar(context, controller.responsiveUtils),
|
||||
child: _buildAppbar(context))),
|
||||
const Divider(color: AppColor.colorDividerComposer, height: 1),
|
||||
Obx(() {
|
||||
@@ -138,8 +134,8 @@ class SettingsView extends GetWidget<SettingsController> {
|
||||
child: Row(mainAxisSize: MainAxisSize.min, children: [
|
||||
SvgPicture.asset(
|
||||
DirectionUtils.isDirectionRTLByLanguage(context)
|
||||
? _imagePaths.icCollapseFolder
|
||||
: _imagePaths.icBack,
|
||||
? controller.imagePaths.icCollapseFolder
|
||||
: controller.imagePaths.icBack,
|
||||
colorFilter: AppColor.colorTextButton.asFilter(),
|
||||
fit: BoxFit.fill),
|
||||
Container(
|
||||
@@ -179,7 +175,7 @@ class SettingsView extends GetWidget<SettingsController> {
|
||||
|
||||
Widget _buildCloseSettingButton(BuildContext context) {
|
||||
return buildIconWeb(
|
||||
icon: SvgPicture.asset(_imagePaths.icClose, width: 28, height: 28, fit: BoxFit.fill),
|
||||
icon: SvgPicture.asset(controller.imagePaths.icClose, width: 28, height: 28, fit: BoxFit.fill),
|
||||
tooltip: AppLocalizations.of(context).close,
|
||||
onTap: closeAction);
|
||||
}
|
||||
@@ -188,7 +184,7 @@ class SettingsView extends GetWidget<SettingsController> {
|
||||
return Obx(() {
|
||||
switch (controller.manageAccountDashboardController.settingsPageLevel.value) {
|
||||
case SettingsPageLevel.universal:
|
||||
return SettingsFirstLevelView();
|
||||
return const SettingsFirstLevelView();
|
||||
case SettingsPageLevel.level1:
|
||||
return _viewDisplayedOfAccountMenuItem();
|
||||
}
|
||||
@@ -201,7 +197,7 @@ class SettingsView extends GetWidget<SettingsController> {
|
||||
case AccountMenuItem.profiles:
|
||||
return ProfilesView();
|
||||
case AccountMenuItem.languageAndRegion:
|
||||
return LanguageAndRegionView();
|
||||
return const LanguageAndRegionView();
|
||||
case AccountMenuItem.emailRules:
|
||||
if (controller.manageAccountDashboardController.isRuleFilterCapabilitySupported) {
|
||||
return EmailRulesView();
|
||||
|
||||
Reference in New Issue
Block a user