Remove old methods from onboarding coordinator and tabbar controller

This commit is contained in:
ismailgulek
2022-06-07 16:15:35 +03:00
parent 1bf3c06d6e
commit 043ad4e5df
5 changed files with 3 additions and 107 deletions
@@ -42,13 +42,6 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
// MARK: Private
private let parameters: OnboardingCoordinatorParameters
// TODO: these can likely be consolidated using an additional authType.
/// The any registration parameters for AuthenticationViewController from a server provisioning link.
private var externalRegistrationParameters: [AnyHashable: Any]?
/// A custom homeserver to be shown when logging in.
private var customHomeserver: String?
/// A custom identity server to be used once logged in.
private var customIdentityServer: String?
// MARK: Navigation State
private var navigationRouter: NavigationRouterType {
@@ -113,21 +106,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
func toPresentable() -> UIViewController {
navigationRouter.toPresentable()
}
/// Force a registration process based on a predefined set of parameters from a server provisioning link.
/// For more information see `AuthenticationViewController.externalRegistrationParameters`.
func update(externalRegistrationParameters: [AnyHashable: Any]) {
self.externalRegistrationParameters = externalRegistrationParameters
legacyAuthenticationCoordinator.update(externalRegistrationParameters: externalRegistrationParameters)
}
/// Set up the authentication screen with the specified homeserver and/or identity server.
func updateHomeserver(_ homeserver: String?, andIdentityServer identityServer: String?) {
self.customHomeserver = homeserver
self.customIdentityServer = identityServer
legacyAuthenticationCoordinator.updateHomeserver(homeserver, andIdentityServer: identityServer)
}
// MARK: - Pre-Authentication
/// Show the onboarding splash screen as the root module in the flow.
@@ -259,14 +238,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
break
}
}
// Due to needing to preload the authVC, this breaks the Coordinator init/start pattern.
// This can be re-assessed once we re-write a native flow for authentication.
if let externalRegistrationParameters = externalRegistrationParameters {
coordinator.update(externalRegistrationParameters: externalRegistrationParameters)
}
coordinator.customServerFieldsVisible = useCaseResult == .customServer
if let softLogoutCredentials = parameters.softLogoutCredentials {
@@ -277,11 +249,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
coordinator.start()
add(childCoordinator: coordinator)
if customHomeserver != nil || customIdentityServer != nil {
coordinator.updateHomeserver(customHomeserver, andIdentityServer: customIdentityServer)
}
if navigationRouter.modules.isEmpty {
navigationRouter.setRootModule(coordinator, popCompletion: nil)
} else {
@@ -20,8 +20,6 @@ import Foundation
@objcMembers
class OnboardingCoordinatorBridgePresenterParameters: NSObject {
/// The external registration parameters for AuthenticationViewController.
var externalRegistrationParameters: [AnyHashable: Any]?
/// The credentials to use after a soft logout has taken place.
var softLogoutCredentials: MXCredentials?
}
@@ -86,17 +84,6 @@ final class OnboardingCoordinatorBridgePresenter: NSObject {
self.navigationType = .push
}
/// Force a registration process based on a predefined set of parameters from a server provisioning link.
/// For more information see `AuthenticationViewController.externalRegistrationParameters`.
func update(externalRegistrationParameters: [AnyHashable: Any]) {
coordinator?.update(externalRegistrationParameters: externalRegistrationParameters)
}
/// Set up the authentication screen with the specified homeserver and/or identity server.
func updateHomeserver(_ homeserver: String?, andIdentityServer identityServer: String?) {
coordinator?.updateHomeserver(homeserver, andIdentityServer: identityServer)
}
func dismiss(animated: Bool, completion: (() -> Void)?) {
guard let coordinator = self.coordinator else {
return
@@ -137,10 +124,6 @@ final class OnboardingCoordinatorBridgePresenter: NSObject {
onboardingCoordinator.completion = { [weak self] in
self?.completion?()
}
if let externalRegistrationParameters = parameters.externalRegistrationParameters {
onboardingCoordinator.update(externalRegistrationParameters: externalRegistrationParameters)
}
return onboardingCoordinator
}
}
@@ -20,11 +20,4 @@ import Foundation
/// full onboarding flow with pre-auth screens, authentication and setup screens once signed in.
protocol OnboardingCoordinatorProtocol: Coordinator, Presentable {
var completion: (() -> Void)? { get set }
/// Force a registration process based on a predefined set of parameters from a server provisioning link.
/// For more information see `AuthenticationViewController.externalRegistrationParameters`.
func update(externalRegistrationParameters: [AnyHashable: Any])
/// Set up the authentication screen with the specified homeserver and/or identity server.
func updateHomeserver(_ homeserver: String?, andIdentityServer identityServer: String?)
}
@@ -63,16 +63,6 @@ typedef NS_ENUM(NSUInteger, MasterTabBarIndex) {
*/
- (void)showOnboardingFlow;
/**
Display the onboarding flow in order to pursue a registration process by using a predefined set
of parameters.
If the provided registration parameters are not supported, the default onboarding flow will be used.
@param parameters the set of parameters.
*/
- (void)showOnboardingFlowWithRegistrationParameters:(NSDictionary*)parameters;
/**
Display the onboarding flow configured to log back into a soft logout session.
@@ -67,8 +67,6 @@
@property (nonatomic, readwrite) id addAccountObserver;
@property (nonatomic, readwrite) id removeAccountObserver;
// The parameters to pass to the Authentication view controller.
@property (nonatomic, readwrite) NSDictionary *authViewControllerRegistrationParameters;
@property (nonatomic, readwrite) MXCredentials *softLogoutCredentials;
@property (nonatomic) BOOL reviewSessionAlertHasBeenDisplayed;
@@ -478,12 +476,6 @@
- (void)presentOnboardingFlow
{
OnboardingCoordinatorBridgePresenterParameters *parameters = [[OnboardingCoordinatorBridgePresenterParameters alloc] init];
// Forward parameters if any
if (self.authViewControllerRegistrationParameters)
{
parameters.externalRegistrationParameters = self.authViewControllerRegistrationParameters;
self.authViewControllerRegistrationParameters = nil;
}
if (self.softLogoutCredentials)
{
parameters.softLogoutCredentials = self.softLogoutCredentials;
@@ -547,36 +539,6 @@
}
}
/**
Sets up authentication with parameters detected in a universal link. For example
https://app.element.io/#/register/?hs_url=matrix.example.com&is_url=identity.example.com
*/
- (void)showOnboardingFlowWithRegistrationParameters:(NSDictionary *)parameters
{
if (self.onboardingCoordinatorBridgePresenter)
{
MXLogDebug(@"[MasterTabBarController] Universal link: Forward registration parameter to the existing AuthViewController");
[self.onboardingCoordinatorBridgePresenter updateWithExternalRegistrationParameters:parameters];
}
else
{
MXLogDebug(@"[MasterTabBarController] Universal link: Prompt to logout current sessions and open AuthViewController to complete the registration");
// Keep a ref on the params
self.authViewControllerRegistrationParameters = parameters;
// Prompt to logout. It will then display AuthViewController if the user is logged out.
[[AppDelegate theDelegate] logoutWithConfirmation:YES completion:^(BOOL isLoggedOut) {
if (!isLoggedOut)
{
// Reset temporary params
self.authViewControllerRegistrationParameters = nil;
}
}];
}
}
- (void)showSoftLogoutOnboardingFlowWithCredentials:(MXCredentials*)credentials;
{
MXLogDebug(@"[MasterTabBarController] showAuthenticationScreenAfterSoftLogout");