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:
+9
-17
@@ -1,10 +1,7 @@
|
||||
|
||||
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/responsive_utils.dart';
|
||||
import 'package:core/presentation/views/dialog/confirmation_dialog_builder.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -42,9 +39,6 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
class IdentitiesController extends BaseController {
|
||||
|
||||
final _accountDashBoardController = Get.find<ManageAccountDashBoardController>();
|
||||
final _appToast = Get.find<AppToast>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
final GetAllIdentitiesInteractor _getAllIdentitiesInteractor;
|
||||
final CreateNewIdentityInteractor _createNewIdentityInteractor;
|
||||
@@ -179,7 +173,7 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
void _createNewIdentitySuccess(CreateNewIdentitySuccess success) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastSuccessMessage(
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).you_have_created_a_new_identity);
|
||||
}
|
||||
@@ -189,7 +183,7 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
void _createNewDefaultIdentitySuccess(CreateNewDefaultIdentitySuccess success) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastSuccessMessage(
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).you_have_created_a_new_default_identity);
|
||||
}
|
||||
@@ -202,8 +196,8 @@ class IdentitiesController extends BaseController {
|
||||
context: context,
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
builder: (BuildContext context) => DeleteIdentityDialogBuilder(
|
||||
responsiveUtils: _responsiveUtils,
|
||||
imagePaths: _imagePaths,
|
||||
responsiveUtils: responsiveUtils,
|
||||
imagePaths: imagePaths,
|
||||
onDeleteIdentityAction: () => _deleteIdentityAction(identity),
|
||||
));
|
||||
}
|
||||
@@ -220,10 +214,10 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
void _deleteIdentitySuccess(DeleteIdentitySuccess success) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastSuccessMessage(
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).identity_has_been_deleted,
|
||||
leadingSVGIcon: _imagePaths.icDeleteToast);
|
||||
leadingSVGIcon: imagePaths.icDeleteToast);
|
||||
}
|
||||
|
||||
_refreshAllIdentities();
|
||||
@@ -234,10 +228,10 @@ class IdentitiesController extends BaseController {
|
||||
showDialog(
|
||||
context: currentContext!,
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
builder: (BuildContext context) => (ConfirmDialogBuilder(_imagePaths)
|
||||
builder: (BuildContext context) => (ConfirmDialogBuilder(imagePaths)
|
||||
..key(const Key('dialog_message_delete_identity_failed'))
|
||||
..title(AppLocalizations.of(context).delete_failed)
|
||||
..addIcon(SvgPicture.asset(_imagePaths.icDeleteDialogFailed, fit: BoxFit.fill))
|
||||
..addIcon(SvgPicture.asset(imagePaths.icDeleteDialogFailed, fit: BoxFit.fill))
|
||||
..marginIcon(EdgeInsets.zero)
|
||||
..styleTitle(const TextStyle(fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -291,7 +285,7 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
void _editIdentitySuccess(EditIdentitySuccess success) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastSuccessMessage(
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).you_are_changed_your_identity_successfully);
|
||||
}
|
||||
@@ -299,7 +293,5 @@ class IdentitiesController extends BaseController {
|
||||
_refreshAllIdentities();
|
||||
}
|
||||
|
||||
ImagePaths get imagePaths => _imagePaths;
|
||||
|
||||
bool get isSignatureShow => identitySelected.value != null;
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
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/base/mixin/app_loader_mixin.dart';
|
||||
@@ -10,16 +8,13 @@ import 'package:tmail_ui_user/features/manage_account/presentation/profiles/iden
|
||||
|
||||
class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidgetMixin, AppLoaderMixin {
|
||||
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
IdentitiesView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(24),
|
||||
child: _responsiveUtils.isWebDesktop(context)
|
||||
child: controller.responsiveUtils.isWebDesktop(context)
|
||||
? _buildIdentitiesViewWebDesktop(context)
|
||||
: _buildIdentitiesViewMobile(context),
|
||||
);
|
||||
@@ -35,8 +30,8 @@ class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidge
|
||||
const SizedBox(height: 12),
|
||||
IdentitiesRadioListBuilder(
|
||||
controller: controller,
|
||||
responsiveUtils: _responsiveUtils,
|
||||
imagePaths: _imagePaths
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
imagePaths: controller.imagePaths
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -55,8 +50,8 @@ class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidge
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: IdentitiesRadioListBuilder(
|
||||
controller: controller,
|
||||
responsiveUtils: _responsiveUtils,
|
||||
imagePaths: _imagePaths
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
imagePaths: controller.imagePaths
|
||||
)),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user