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:
dab246
2023-11-14 17:33:17 +07:00
committed by Dat Vu
parent 4ff601b4fc
commit fb47832225
57 changed files with 727 additions and 958 deletions
@@ -1,8 +1,6 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/presentation/utils/keyboard_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:flutter/material.dart';
@@ -41,8 +39,6 @@ class ForwardController extends BaseController {
EditLocalCopyInForwardingInteractor? _editLocalCopyInForwardingInteractor;
final accountDashBoardController = Get.find<ManageAccountDashBoardController>();
final _imagePaths = Get.find<ImagePaths>();
final _appToast = Get.find<AppToast>();
final selectionMode = Rx<SelectMode>(SelectMode.INACTIVE);
final listRecipientForward = RxList<RecipientForward>();
@@ -120,7 +116,7 @@ class ForwardController extends BaseController {
AppLocalizations.of(context).remove,
onConfirmAction: () => _handleDeleteRecipientAction({emailAddress}),
showAsBottomSheet: true,
icon: SvgPicture.asset(_imagePaths.icDeleteDialogRecipients, fit: BoxFit.fill),
icon: SvgPicture.asset(imagePaths.icDeleteDialogRecipients, fit: BoxFit.fill),
titleStyle: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
@@ -153,7 +149,7 @@ class ForwardController extends BaseController {
void _handleDeleteRecipientSuccess(DeleteRecipientInForwardingSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastSuccessMessage(
appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMessageDeleteRecipientSuccessfully);
}
@@ -205,7 +201,7 @@ class ForwardController extends BaseController {
AppLocalizations.of(currentContext!).remove,
onConfirmAction: () => _handleDeleteRecipientAction(listEmailAddress),
showAsBottomSheet: true,
icon: SvgPicture.asset(_imagePaths.icDeleteDialogRecipients, fit: BoxFit.fill),
icon: SvgPicture.asset(imagePaths.icDeleteDialogRecipients, fit: BoxFit.fill),
titleStyle: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
@@ -255,7 +251,7 @@ class ForwardController extends BaseController {
void _handleAddRecipientsSuccess(AddRecipientsInForwardingSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastSuccessMessage(
appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).toastMessageAddRecipientsSuccessfully);
}
@@ -281,7 +277,7 @@ class ForwardController extends BaseController {
void _handleEditLocalCopySuccess(EditLocalCopyInForwardingSuccess success) {
if (currentOverlayContext != null && currentContext != null) {
_appToast.showToastSuccessMessage(
appToast.showToastSuccessMessage(
currentOverlayContext!,
success.forward.localCopy
? AppLocalizations.of(currentContext!).toastMessageLocalCopyEnable
@@ -306,11 +302,11 @@ class ForwardController extends BaseController {
void handleExceptionCallback(BuildContext context, bool isListEmailEmpty) {
if (isListEmailEmpty) {
_appToast.showToastErrorMessage(
appToast.showToastErrorMessage(
context,
AppLocalizations.of(context).emptyListEmailForward);
} else {
_appToast.showToastErrorMessage(
appToast.showToastErrorMessage(
context,
AppLocalizations.of(context).incorrectEmailFormat);
}
@@ -1,7 +1,5 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/utils/style_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -15,33 +13,31 @@ import 'package:tmail_ui_user/features/manage_account/presentation/menu/settings
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
final _responsiveUtils = Get.find<ResponsiveUtils>();
final _imagePaths = Get.find<ImagePaths>();
ForwardView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: SettingsUtils.getBackgroundColor(context, _responsiveUtils),
backgroundColor: SettingsUtils.getBackgroundColor(context, controller.responsiveUtils),
body: Container(
width: double.infinity,
height: double.infinity,
color: SettingsUtils.getContentBackgroundColor(context, _responsiveUtils),
decoration: SettingsUtils.getBoxDecorationForContent(context, _responsiveUtils),
margin: SettingsUtils.getMarginViewForForwardSettingDetails(context, _responsiveUtils),
color: SettingsUtils.getContentBackgroundColor(context, controller.responsiveUtils),
decoration: SettingsUtils.getBoxDecorationForContent(context, controller.responsiveUtils),
margin: SettingsUtils.getMarginViewForForwardSettingDetails(context, controller.responsiveUtils),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (_responsiveUtils.isWebDesktop(context))
if (controller.responsiveUtils.isWebDesktop(context))
...[
ForwardHeaderWidget(imagePaths: _imagePaths, responsiveUtils: _responsiveUtils),
ForwardHeaderWidget(imagePaths: controller.imagePaths, responsiveUtils: controller.responsiveUtils),
const Divider(height: 1, color: AppColor.colorDividerHeaderSetting)
],
Expanded(child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
if (!_responsiveUtils.isWebDesktop(context))
if (!controller.responsiveUtils.isWebDesktop(context))
_buildTitleHeader(context),
_buildKeepLocalSwitchButton(context),
Obx(() => controller.currentForward.value != null
@@ -51,7 +47,7 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
_buildLoadingView(),
Obx(() {
if (controller.listRecipientForward.isNotEmpty) {
return ListEmailForwardsWidget();
return const ListEmailForwardsWidget();
} else {
return const SizedBox.shrink();
}
@@ -68,7 +64,7 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
return Container(
color: Colors.transparent,
width: double.infinity,
padding: SettingsUtils.getPaddingTitleHeaderForwarding(context, _responsiveUtils),
padding: SettingsUtils.getPaddingTitleHeaderForwarding(context, controller.responsiveUtils),
child: Text(
AppLocalizations.of(context).forwardingSettingExplanation,
style: const TextStyle(
@@ -85,7 +81,7 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
return controller.listRecipientForward.isNotEmpty
? Container(
color: Colors.transparent,
padding: SettingsUtils.getPaddingKeepLocalSwitchButtonForwarding(context, _responsiveUtils),
padding: SettingsUtils.getPaddingKeepLocalSwitchButtonForwarding(context, controller.responsiveUtils),
child: Row(children: [
Padding(
padding: const EdgeInsets.only(right: 16),
@@ -93,8 +89,8 @@ class ForwardView extends GetWidget<ForwardController> with AppLoaderMixin {
onTap: controller.handleEditLocalCopy,
child: SvgPicture.asset(
controller.currentForwardLocalCopyState
? _imagePaths.icSwitchOn
: _imagePaths.icSwitchOff,
? controller.imagePaths.icSwitchOn
: controller.imagePaths.icSwitchOff,
fit: BoxFit.fill,
width: 36,
height: 24))),
@@ -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/views/button/icon_button_web.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -15,16 +13,13 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
class ListEmailForwardsWidget extends GetWidget<ForwardController> {
final _imagePaths = Get.find<ImagePaths>();
final _responsiveUtils = Get.find<ResponsiveUtils>();
ListEmailForwardsWidget({Key? key}) : super(key: key);
const ListEmailForwardsWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.transparent,
padding: SettingsUtils.getPaddingListRecipientForwarding(context, _responsiveUtils),
padding: SettingsUtils.getPaddingListRecipientForwarding(context, controller.responsiveUtils),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@@ -106,7 +101,7 @@ class ListEmailForwardsWidget extends GetWidget<ForwardController> {
children: [
buildIconWeb(
icon: SvgPicture.asset(
_imagePaths.icClose,
controller.imagePaths.icClose,
colorFilter: AppColor.colorTextButton.asFilter(),
fit: BoxFit.fill),
tooltip: AppLocalizations.of(context).cancel,