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:
@@ -26,7 +26,6 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
class VacationController extends BaseController {
|
||||
|
||||
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
final _appToast = Get.find<AppToast>();
|
||||
final _settingController = Get.find<SettingsController>();
|
||||
|
||||
final GetAllVacationInteractor _getAllVacationInteractor;
|
||||
@@ -242,7 +241,7 @@ class VacationController extends BaseController {
|
||||
final fromDate = vacationPresentation.value.fromDate;
|
||||
if (fromDate == null) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastErrorMessage(
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).errorMessageWhenStartDateVacationIsEmpty);
|
||||
}
|
||||
@@ -253,7 +252,7 @@ class VacationController extends BaseController {
|
||||
final toDate = vacationPresentation.value.toDate;
|
||||
if (vacationStopEnabled && toDate != null && toDate.isBefore(fromDate)) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastErrorMessage(
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).errorMessageWhenEndDateVacationIsInValid);
|
||||
}
|
||||
@@ -263,7 +262,7 @@ class VacationController extends BaseController {
|
||||
final messageHtmlText = (PlatformInfo.isWeb ? _vacationMessageHtmlText : await _getMessageHtmlText()) ?? '';
|
||||
if (messageHtmlText.isEmpty && context.mounted) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastErrorMessage(
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).errorMessageWhenMessageVacationIsEmpty);
|
||||
}
|
||||
@@ -299,7 +298,7 @@ class VacationController extends BaseController {
|
||||
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastSuccessMessage(
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).vacationSettingSaved);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ import 'package:tmail_ui_user/main/utils/app_utils.dart';
|
||||
|
||||
class VacationView extends GetWidget<VacationController> with RichTextButtonMixin {
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
VacationView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -52,18 +49,18 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
|
||||
Widget _buildVacationFormView(BuildContext context) {
|
||||
return SettingDetailViewBuilder(
|
||||
responsiveUtils: _responsiveUtils,
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
onTapGestureDetector: () => controller.clearFocusEditor(context),
|
||||
child: SingleChildScrollView(
|
||||
physics: const ClampingScrollPhysics(),
|
||||
controller: controller.scrollController,
|
||||
child: Padding(
|
||||
padding: VacationUtils.getPaddingView(context, _responsiveUtils),
|
||||
padding: VacationUtils.getPaddingView(context, controller.responsiveUtils),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (_responsiveUtils.isWebDesktop(context))
|
||||
if (controller.responsiveUtils.isWebDesktop(context))
|
||||
...[
|
||||
Text(
|
||||
AppLocalizations.of(context).vacation,
|
||||
@@ -94,7 +91,9 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
controller.updateVacationPresentation(newStatus: newStatus);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
controller.isVacationDeactivated ? _imagePaths.icSwitchOff : _imagePaths.icSwitchOn,
|
||||
controller.isVacationDeactivated
|
||||
? controller.imagePaths.icSwitchOff
|
||||
: controller.imagePaths.icSwitchOn,
|
||||
fit: BoxFit.fill,
|
||||
width: 24,
|
||||
height: 24
|
||||
@@ -121,7 +120,7 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: Opacity(
|
||||
opacity: controller.isVacationDeactivated ? 0.3 : 1.0,
|
||||
child: _responsiveUtils.isPortraitMobile(context)
|
||||
child: controller.responsiveUtils.isPortraitMobile(context)
|
||||
? Column(children: [
|
||||
BorderButtonField<DateTime>(
|
||||
label: AppLocalizations.of(context).startDate,
|
||||
@@ -175,8 +174,8 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
controller.vacationPresentation.value.vacationStopEnabled
|
||||
? _imagePaths.icSwitchOn
|
||||
: _imagePaths.icSwitchOff,
|
||||
? controller.imagePaths.icSwitchOn
|
||||
: controller.imagePaths.icSwitchOff,
|
||||
fit: BoxFit.fill,
|
||||
width: 24,
|
||||
height: 24
|
||||
@@ -201,7 +200,7 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
absorbing: !controller.canChangeEndDate,
|
||||
child: Opacity(
|
||||
opacity: !controller.canChangeEndDate ? 0.3 : 1.0,
|
||||
child: _responsiveUtils.isPortraitMobile(context)
|
||||
child: controller.responsiveUtils.isPortraitMobile(context)
|
||||
? Column(children: [
|
||||
BorderButtonField<DateTime>(
|
||||
label: AppLocalizations.of(context).endDate,
|
||||
@@ -245,7 +244,7 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
const SizedBox(height: 24),
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isVacationDeactivated,
|
||||
child: _responsiveUtils.isPortraitMobile(context)
|
||||
child: controller.responsiveUtils.isPortraitMobile(context)
|
||||
? Opacity(
|
||||
opacity: controller.isVacationDeactivated ? 0.3 : 1.0,
|
||||
child: TextInputFieldBuilder(
|
||||
@@ -289,7 +288,7 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
}
|
||||
|
||||
Widget _buildListButtonAction(BuildContext context) {
|
||||
if (_responsiveUtils.isWebDesktop(context)) {
|
||||
if (controller.responsiveUtils.isWebDesktop(context)) {
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: buildTextButton(
|
||||
@@ -305,7 +304,7 @@ class VacationView extends GetWidget<VacationController> with RichTextButtonMixi
|
||||
onTap: () => controller.saveVacation(context)),
|
||||
);
|
||||
} else {
|
||||
if (_responsiveUtils.isPortraitMobile(context)) {
|
||||
if (controller.responsiveUtils.isPortraitMobile(context)) {
|
||||
return Row(children: [
|
||||
Expanded(
|
||||
child: buildTextButton(
|
||||
|
||||
Reference in New Issue
Block a user