TF-1074 Handle go to path /identity_creator
This commit is contained in:
@@ -54,7 +54,6 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
|
||||
final emailsForwardCreatorIsActive = false.obs;
|
||||
final rulesFilterCreatorIsActive = false.obs;
|
||||
final identityCreatorIsActive = false.obs;
|
||||
|
||||
ManageAccountDashBoardController(
|
||||
LogoutOidcInteractor logoutOidcInteractor,
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/emails_forward_creator/presentation/emails_forward_creator_view.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/identity_creator_view.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/mixin/user_setting_popup_menu_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/widgets/vacation_notification_message_widget.dart';
|
||||
@@ -131,8 +130,6 @@ class ManageAccountDashBoardView extends GetWidget<ManageAccountDashBoardControl
|
||||
EmailsForwardCreatorView(),
|
||||
if(controller.rulesFilterCreatorIsActive.isTrue)
|
||||
RuleFilterCreatorView(),
|
||||
if(controller.identityCreatorIsActive.isTrue)
|
||||
IdentityCreatorView()
|
||||
]
|
||||
));
|
||||
}
|
||||
|
||||
+56
-25
@@ -1,6 +1,12 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:core/presentation/extensions/capitalize_extension.dart';
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/resources/image_paths.dart';
|
||||
import 'package:core/presentation/utils/app_toast.dart';
|
||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:core/presentation/views/bottom_popup/confirmation_dialog_action_sheet_builder.dart';
|
||||
import 'package:core/presentation/views/dialog/confirmation_dialog_builder.dart';
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -8,7 +14,6 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/identity_creator_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/model/identity_creator_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/create_new_identity_request.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/edit_identity_request.dart';
|
||||
@@ -45,8 +50,6 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
final idIdentityAll = IdentityId(Id('all'));
|
||||
|
||||
final identityCreatorArguments = Rxn<IdentityCreatorArguments>();
|
||||
|
||||
late Worker accountIdWorker;
|
||||
|
||||
IdentitiesController(
|
||||
@@ -118,7 +121,6 @@ class IdentitiesController extends BaseController {
|
||||
}
|
||||
|
||||
void _getAllIdentities(AccountId accountId) {
|
||||
log('IdentitiesController::_getAllIdentities(): $accountId');
|
||||
consumeState(_getAllIdentitiesInteractor.execute(accountId));
|
||||
}
|
||||
|
||||
@@ -141,11 +143,6 @@ class IdentitiesController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
void _openIdentityCreatorOverlay() {
|
||||
IdentityCreatorBindings().dependencies();
|
||||
_accountDashBoardController.identityCreatorIsActive.toggle();
|
||||
}
|
||||
|
||||
void selectIdentity(Identity? newIdentity) {
|
||||
identitySelected.value = newIdentity;
|
||||
if (newIdentity != null) {
|
||||
@@ -161,20 +158,38 @@ class IdentitiesController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
void goToCreateNewIdentity() async {
|
||||
void goToCreateNewIdentity(BuildContext context) async {
|
||||
final accountId = _accountDashBoardController.accountId.value;
|
||||
final userProfile = _accountDashBoardController.userProfile.value;
|
||||
if (accountId != null && userProfile != null) {
|
||||
identityCreatorArguments.value = IdentityCreatorArguments(accountId, userProfile);
|
||||
if (kIsWeb) {
|
||||
_openIdentityCreatorOverlay();
|
||||
final arguments = IdentityCreatorArguments(accountId, userProfile);
|
||||
|
||||
if (BuildUtils.isWeb) {
|
||||
showDialogIdentityCreator(
|
||||
context: context,
|
||||
arguments: arguments,
|
||||
onCreatedIdentity: (arguments) {
|
||||
if (arguments is CreateNewIdentityRequest) {
|
||||
_createNewIdentityAction(accountId, arguments);
|
||||
} else if (arguments is EditIdentityRequest) {
|
||||
_editIdentityAction(accountId, arguments);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
push(AppRoutes.identityCreator);
|
||||
final newIdentityArguments = await push(
|
||||
AppRoutes.identityCreator,
|
||||
arguments: arguments);
|
||||
|
||||
if (newIdentityArguments is CreateNewIdentityRequest) {
|
||||
_createNewIdentityAction(accountId, newIdentityArguments);
|
||||
} else if (newIdentityArguments is EditIdentityRequest) {
|
||||
_editIdentityAction(accountId, newIdentityArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createNewIdentityAction(AccountId accountId, CreateNewIdentityRequest identityRequest) async {
|
||||
void _createNewIdentityAction(AccountId accountId, CreateNewIdentityRequest identityRequest) async {
|
||||
consumeState(_createNewIdentityInteractor.execute(accountId, identityRequest));
|
||||
}
|
||||
|
||||
@@ -281,32 +296,48 @@ class IdentitiesController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
void goToEditIdentity(Identity identity) async {
|
||||
void goToEditIdentity(BuildContext context, Identity identity) async {
|
||||
popBack();
|
||||
|
||||
final accountId = _accountDashBoardController.accountId.value;
|
||||
final userProfile = _accountDashBoardController.userProfile.value;
|
||||
if (accountId != null && userProfile != null) {
|
||||
identityCreatorArguments.value = IdentityCreatorArguments(
|
||||
final arguments = IdentityCreatorArguments(
|
||||
accountId,
|
||||
userProfile,
|
||||
identity: identity,
|
||||
actionType: IdentityActionType.edit);
|
||||
if (kIsWeb) {
|
||||
_openIdentityCreatorOverlay();
|
||||
|
||||
if (BuildUtils.isWeb) {
|
||||
showDialogIdentityCreator(
|
||||
context: context,
|
||||
arguments: arguments,
|
||||
onCreatedIdentity: (arguments) {
|
||||
if (arguments is CreateNewIdentityRequest) {
|
||||
_createNewIdentityAction(accountId, arguments);
|
||||
} else if (arguments is EditIdentityRequest) {
|
||||
_editIdentityAction(accountId, arguments);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
push(AppRoutes.identityCreator);
|
||||
final newIdentityArguments = await push(
|
||||
AppRoutes.identityCreator,
|
||||
arguments: arguments);
|
||||
|
||||
if (newIdentityArguments is CreateNewIdentityRequest) {
|
||||
_createNewIdentityAction(accountId, newIdentityArguments);
|
||||
} else if (newIdentityArguments is EditIdentityRequest) {
|
||||
_editIdentityAction(accountId, newIdentityArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void editIdentityAction(AccountId accountId, EditIdentityRequest editIdentityRequest) async {
|
||||
log('IdentitiesController::_editIdentityAction(): $editIdentityRequest');
|
||||
void _editIdentityAction(AccountId accountId, EditIdentityRequest editIdentityRequest) async {
|
||||
consumeState(_editIdentityInteractor.execute(accountId, editIdentityRequest));
|
||||
}
|
||||
|
||||
void _editIdentitySuccess(EditIdentitySuccess success) {
|
||||
log('IdentitiesController::_editIdentitySuccess(): $success');
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
_appToast.showToastWithIcon(
|
||||
currentOverlayContext!,
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
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/views/button/button_builder.dart';
|
||||
import 'package:core/presentation/views/responsive/responsive_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@@ -42,7 +47,7 @@ class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidge
|
||||
..radiusSplash(10)
|
||||
..padding(const EdgeInsets.symmetric(vertical: 12))
|
||||
..textStyle(const TextStyle(fontSize: 17, color: Colors.white, fontWeight: FontWeight.w500))
|
||||
..onPressActionClick(() => controller.goToCreateNewIdentity())
|
||||
..onPressActionClick(() => controller.goToCreateNewIdentity(context))
|
||||
..text(AppLocalizations.of(context).new_identity, isVertical: false))
|
||||
.build()
|
||||
]);
|
||||
@@ -77,7 +82,7 @@ class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidge
|
||||
floatingActionButton: _responsiveUtils.isMobile(context)
|
||||
? FloatingActionButton(
|
||||
key: const Key('add_new_identity'),
|
||||
onPressed: () => controller.goToCreateNewIdentity(),
|
||||
onPressed: () => controller.goToCreateNewIdentity(context),
|
||||
backgroundColor: AppColor.primaryColor,
|
||||
child: SvgPicture.asset(_imagePaths.icAddIdentity, width: 24, height: 24))
|
||||
: null),
|
||||
@@ -140,7 +145,7 @@ class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidge
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 17,
|
||||
color: Colors.black),
|
||||
onCallbackAction: () => controller.goToEditIdentity(identity))),
|
||||
onCallbackAction: () => controller.goToEditIdentity(context, identity))),
|
||||
if (identity.mayDelete == true)
|
||||
PopupMenuItem(
|
||||
padding: EdgeInsets.zero,
|
||||
@@ -192,7 +197,7 @@ class IdentitiesView extends GetWidget<IdentitiesController> with PopupMenuWidge
|
||||
iconRightPadding: _responsiveUtils.isMobile(context)
|
||||
? const EdgeInsets.only(right: 12)
|
||||
: EdgeInsets.zero)
|
||||
..onActionClick((identity) => controller.goToEditIdentity(identity)))
|
||||
..onActionClick((identity) => controller.goToEditIdentity(context, identity)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user