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,7 +1,6 @@
|
||||
|
||||
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';
|
||||
@@ -40,13 +39,9 @@ import 'package:tmail_ui_user/features/thread/presentation/model/search_state.da
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class DestinationPickerController extends BaseMailboxController {
|
||||
|
||||
final _uuid = Get.find<Uuid>();
|
||||
final _appToast = Get.find<AppToast>();
|
||||
|
||||
final SearchMailboxInteractor _searchMailboxInteractor;
|
||||
final CreateNewMailboxInteractor _createNewMailboxInteractor;
|
||||
|
||||
@@ -310,7 +305,7 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
|
||||
void openCreateNewMailboxView(BuildContext context) async {
|
||||
if (mailboxDestination.value == null) {
|
||||
_appToast.showToastErrorMessage(
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(context).toastMessageErrorNotSelectedFolderWhenCreateNewMailbox);
|
||||
} else {
|
||||
@@ -346,7 +341,7 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
if (exception is ErrorMethodResponse) {
|
||||
messageError = exception.description ?? AppLocalizations.of(currentContext!).createNewFolderFailure;
|
||||
}
|
||||
_appToast.showToastErrorMessage(currentOverlayContext!, messageError);
|
||||
appToast.showToastErrorMessage(currentOverlayContext!, messageError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +374,7 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
KeyboardUtils.hideKeyboard(context);
|
||||
|
||||
if (mailboxDestination.value == null) {
|
||||
_appToast.showToastErrorMessage(
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(context).toastMessageErrorNotSelectedFolderWhenCreateNewMailbox);
|
||||
return;
|
||||
@@ -392,7 +387,7 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
|
||||
final nameMailbox = newNameMailbox.value;
|
||||
if (nameMailbox != null && nameMailbox.isNotEmpty) {
|
||||
final generateCreateId = Id(_uuid.v1());
|
||||
final generateCreateId = Id(uuid.v1());
|
||||
final parentId = mailboxDestination.value == PresentationMailbox.unifiedMailbox
|
||||
? null
|
||||
: mailboxDestination.value?.id;
|
||||
|
||||
@@ -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:core/presentation/views/button/icon_button_web.dart';
|
||||
import 'package:core/presentation/views/list/tree_view.dart';
|
||||
@@ -38,8 +36,6 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
MailboxWidgetMixin {
|
||||
|
||||
final _maxHeight = 656.0;
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
@override
|
||||
final controller = Get.find<DestinationPickerController>();
|
||||
@@ -59,7 +55,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
borderOnForeground: false,
|
||||
color: Colors.transparent,
|
||||
child: SafeArea(
|
||||
top: PlatformInfo.isMobile && _responsiveUtils.isPortraitMobile(context),
|
||||
top: PlatformInfo.isMobile && controller.responsiveUtils.isPortraitMobile(context),
|
||||
bottom: false,
|
||||
left: false,
|
||||
right: false,
|
||||
@@ -90,8 +86,8 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
left: PlatformInfo.isMobile && _responsiveUtils.isLandscapeMobile(context),
|
||||
right: PlatformInfo.isMobile && _responsiveUtils.isLandscapeMobile(context),
|
||||
left: PlatformInfo.isMobile && controller.responsiveUtils.isLandscapeMobile(context),
|
||||
right: PlatformInfo.isMobile && controller.responsiveUtils.isLandscapeMobile(context),
|
||||
child: Column(children: [
|
||||
Obx(() => TopBarDestinationPickerBuilder(
|
||||
controller.mailboxAction.value,
|
||||
@@ -201,7 +197,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
if (actions?.canSearch() == true &&
|
||||
controller.destinationScreenType.value == DestinationScreenType.destinationPicker)
|
||||
SearchBarView(
|
||||
_imagePaths,
|
||||
controller.imagePaths,
|
||||
margin: const EdgeInsets.all(16),
|
||||
hintTextSearch: AppLocalizations.of(context).hintSearchFolders,
|
||||
onOpenSearchViewAction: controller.enableSearch
|
||||
@@ -294,8 +290,8 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
children: [
|
||||
buildHeaderMailboxCategory(
|
||||
context,
|
||||
_responsiveUtils,
|
||||
_imagePaths,
|
||||
controller.responsiveUtils,
|
||||
controller.imagePaths,
|
||||
categories,
|
||||
controller,
|
||||
toggleMailboxCategories: controller.toggleMailboxCategories,
|
||||
@@ -404,8 +400,8 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemBuilder: (context, index) {
|
||||
return Obx(() => DestinationPickerSearchMailboxItemBuilder(
|
||||
_imagePaths,
|
||||
_responsiveUtils,
|
||||
controller.imagePaths,
|
||||
controller.responsiveUtils,
|
||||
controller.listMailboxSearched[index],
|
||||
mailboxActions: actions,
|
||||
mailboxIdAlreadySelected: mailboxIdSelected,
|
||||
@@ -443,7 +439,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
: Colors.transparent,
|
||||
child: Row(children: [
|
||||
SvgPicture.asset(
|
||||
_imagePaths.icFolderMailbox,
|
||||
controller.imagePaths.icFolderMailbox,
|
||||
width: PlatformInfo.isWeb ? 20 : 24,
|
||||
height: PlatformInfo.isWeb ? 20 : 24,
|
||||
fit: BoxFit.fill
|
||||
@@ -469,7 +465,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
left: AppUtils.isDirectionRTL(context) ? 30 : 0.0,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
_imagePaths.icFilterSelected,
|
||||
controller.imagePaths.icFilterSelected,
|
||||
width: 20,
|
||||
height: 20,
|
||||
fit: BoxFit.fill
|
||||
@@ -528,12 +524,12 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
),
|
||||
child: buildIconWeb(
|
||||
icon: SvgPicture.asset(
|
||||
_imagePaths.icBack,
|
||||
controller.imagePaths.icBack,
|
||||
colorFilter: AppColor.colorTextButton.asFilter(),
|
||||
fit: BoxFit.fill),
|
||||
onTap: () => controller.disableSearch(context))),
|
||||
Expanded(child: SearchAppBarWidget(
|
||||
imagePaths: _imagePaths,
|
||||
imagePaths: controller.imagePaths,
|
||||
searchQuery: controller.searchQuery.value,
|
||||
searchFocusNode: controller.searchFocus,
|
||||
searchInputController: controller.searchInputController,
|
||||
@@ -547,7 +543,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
color: AppColor.colorBgSearchBar),
|
||||
iconClearText: SvgPicture.asset(
|
||||
_imagePaths.icClearTextSearch,
|
||||
controller.imagePaths.icClearTextSearch,
|
||||
width: 18,
|
||||
height: 18,
|
||||
fit: BoxFit.fill),
|
||||
@@ -562,9 +558,9 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
}
|
||||
|
||||
BorderRadius _getRadiusDestinationPicker(BuildContext context) {
|
||||
if (PlatformInfo.isMobile && _responsiveUtils.isLandscapeMobile(context)) {
|
||||
if (PlatformInfo.isMobile && controller.responsiveUtils.isLandscapeMobile(context)) {
|
||||
return BorderRadius.zero;
|
||||
} else if (_responsiveUtils.isMobile(context)) {
|
||||
} else if (controller.responsiveUtils.isMobile(context)) {
|
||||
return const BorderRadius.only(
|
||||
topRight: Radius.circular(16),
|
||||
topLeft: Radius.circular(16));
|
||||
@@ -575,14 +571,14 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
|
||||
double _getWidthDestinationPicker(BuildContext context) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
if (_responsiveUtils.isMobile(context)) {
|
||||
if (controller.responsiveUtils.isMobile(context)) {
|
||||
return double.infinity;
|
||||
} else {
|
||||
return 556;
|
||||
}
|
||||
} else {
|
||||
if (_responsiveUtils.isLandscapeMobile(context) ||
|
||||
_responsiveUtils.isPortraitMobile(context)) {
|
||||
if (controller.responsiveUtils.isLandscapeMobile(context) ||
|
||||
controller.responsiveUtils.isPortraitMobile(context)) {
|
||||
return double.infinity;
|
||||
} else {
|
||||
return 556;
|
||||
@@ -592,21 +588,21 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
|
||||
double _getHeightDestinationPicker(BuildContext context) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
if (_responsiveUtils.isMobile(context)) {
|
||||
if (controller.responsiveUtils.isMobile(context)) {
|
||||
return double.infinity;
|
||||
} else {
|
||||
if (_responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
if (controller.responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
return _maxHeight;
|
||||
} else {
|
||||
return double.infinity;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_responsiveUtils.isLandscapeMobile(context) ||
|
||||
_responsiveUtils.isPortraitMobile(context)) {
|
||||
if (controller.responsiveUtils.isLandscapeMobile(context) ||
|
||||
controller.responsiveUtils.isPortraitMobile(context)) {
|
||||
return double.infinity;
|
||||
} else {
|
||||
if (_responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
if (controller.responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
return _maxHeight;
|
||||
} else {
|
||||
return double.infinity;
|
||||
@@ -618,21 +614,21 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
|
||||
|
||||
EdgeInsets _getMarginDestinationPicker(BuildContext context) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
if (_responsiveUtils.isMobile(context)) {
|
||||
if (controller.responsiveUtils.isMobile(context)) {
|
||||
return EdgeInsets.zero;
|
||||
} else {
|
||||
if (_responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
if (controller.responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
return const EdgeInsets.symmetric(vertical: 12);
|
||||
} else {
|
||||
return const EdgeInsets.symmetric(vertical: 50);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_responsiveUtils.isLandscapeMobile(context) ||
|
||||
_responsiveUtils.isPortraitMobile(context)) {
|
||||
if (controller.responsiveUtils.isLandscapeMobile(context) ||
|
||||
controller.responsiveUtils.isPortraitMobile(context)) {
|
||||
return EdgeInsets.zero;
|
||||
} else {
|
||||
if (_responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
if (controller.responsiveUtils.getSizeScreenHeight(context) > _maxHeight) {
|
||||
return const EdgeInsets.symmetric(vertical: 12);
|
||||
} else {
|
||||
return const EdgeInsets.symmetric(vertical: 50);
|
||||
|
||||
Reference in New Issue
Block a user