From 6ab9590d30b7a0c52904da5bbc8068b70e54b7df Mon Sep 17 00:00:00 2001 From: Saeed Bashir Date: Mon, 18 Nov 2024 15:55:44 +0500 Subject: [PATCH 1/3] chore: sign-in and register screens social sign in improvements --- .../Presentation/Login/SignInView.swift | 24 ++- .../Presentation/Login/SignInViewModel.swift | 14 +- .../Registration/SignUpView.swift | 28 +-- .../Registration/SignUpViewModel.swift | 33 +++- .../SocialAuth/SocialAuthView.swift | 163 ++++++++++-------- .../SocialAuth/SocialAuthViewModel.swift | 28 +++ .../Authorization/SwiftGen/Strings.swift | 12 +- .../en.lproj/Localizable.strings | 6 +- .../uk.lproj/Localizable.strings | 6 +- .../AuthorizationMock.generated.swift | 46 ++--- .../Login/SignInViewModelTests.swift | 28 ++- .../Register/SignUpViewModelTests.swift | 19 +- .../Socials/icon_apple.imageset/Contents.json | 34 +++- .../icon_apple.imageset/icon_apple@2x.png | Bin 660 -> 0 bytes .../icon_apple.imageset/icon_apple@3x.png | Bin 915 -> 0 bytes .../icon_apple.imageset/icon_apple_dark.png | Bin 0 -> 1002 bytes .../icon_apple.imageset/icon_apple_white.png | Bin 0 -> 660 bytes .../Contents.json | 3 +- .../icon_facebook.imageset/icon_facebook.png | Bin 0 -> 1067 bytes .../icon_facebook_white@2x.png | Bin 800 -> 0 bytes .../icon_facebook_white@3x.png | Bin 1049 -> 0 bytes Core/Core/Configuration/BaseRouter.swift | 10 +- Core/Core/Data/CoreStorage.swift | 2 + Core/Core/SwiftGen/Assets.swift | 2 +- Core/Core/View/Base/SocialAuthButton.swift | 51 +++--- Course/CourseTests/CourseMock.generated.swift | 23 +-- .../DashboardMock.generated.swift | 23 +-- .../DiscoveryMock.generated.swift | 23 +-- .../DiscussionMock.generated.swift | 46 ++--- OpenEdX/DI/ScreenAssembly.swift | 2 + OpenEdX/Data/AppStorage.swift | 14 ++ OpenEdX/Router.swift | 11 +- OpenEdX/View/MainScreenViewModel.swift | 5 +- .../ProfileTests/ProfileMock.generated.swift | 46 ++--- .../SocialAuthColor.colorset/Contents.json | 38 ++++ Theme/Theme/SwiftGen/ThemeAssets.swift | 1 + Theme/Theme/Theme.swift | 1 + .../WhatsNew/Presentation/WhatsNewView.swift | 22 ++- 38 files changed, 503 insertions(+), 261 deletions(-) delete mode 100644 Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@2x.png delete mode 100644 Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@3x.png create mode 100644 Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_dark.png create mode 100644 Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_white.png rename Core/Core/Assets.xcassets/Socials/{icon_facebook_white.imageset => icon_facebook.imageset}/Contents.json (73%) create mode 100644 Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/icon_facebook.png delete mode 100644 Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@2x.png delete mode 100644 Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@3x.png create mode 100644 Theme/Theme/Assets.xcassets/Colors/SocialAuthColor.colorset/Contents.json diff --git a/Authorization/Authorization/Presentation/Login/SignInView.swift b/Authorization/Authorization/Presentation/Login/SignInView.swift index e93f2dce8..85dc35a1d 100644 --- a/Authorization/Authorization/Presentation/Login/SignInView.swift +++ b/Authorization/Authorization/Presentation/Login/SignInView.swift @@ -71,6 +71,20 @@ public struct SignInView: View { .foregroundColor(Theme.Colors.textPrimary) .padding(.bottom, 20) .accessibilityIdentifier("welcome_back_text") + + if viewModel.socialAuthEnabled { + SocialAuthView( + viewModel: .init( + config: viewModel.config, + lastUsedOption: viewModel.storage.lastUsedSocialAuth + ) { result in + Task { await viewModel.login(with: result) } + } + ) + .padding(.top, 22) + .padding(.bottom, 16) + } + Text(AuthLocalization.SignIn.emailOrUsername) .font(Theme.Fonts.labelLarge) .foregroundColor(Theme.Colors.textPrimary) @@ -156,15 +170,6 @@ public struct SignInView: View { .accessibilityIdentifier("signin_button") } } - if viewModel.socialAuthEnabled { - SocialAuthView( - viewModel: .init( - config: viewModel.config - ) { result in - Task { await viewModel.login(with: result) } - } - ) - } agreements Spacer() } @@ -254,6 +259,7 @@ struct SignInView_Previews: PreviewProvider { config: ConfigMock(), analytics: AuthorizationAnalyticsMock(), validator: Validator(), + storage: CoreStorageMock(), sourceScreen: .default ) diff --git a/Authorization/Authorization/Presentation/Login/SignInViewModel.swift b/Authorization/Authorization/Presentation/Login/SignInViewModel.swift index 5a87151f5..f80ed6dbe 100644 --- a/Authorization/Authorization/Presentation/Login/SignInViewModel.swift +++ b/Authorization/Authorization/Presentation/Login/SignInViewModel.swift @@ -41,6 +41,7 @@ public class SignInViewModel: ObservableObject { private let interactor: AuthInteractorProtocol private let analytics: AuthorizationAnalytics private let validator: Validator + let storage: CoreStorage public init( interactor: AuthInteractorProtocol, @@ -48,6 +49,7 @@ public class SignInViewModel: ObservableObject { config: ConfigProtocol, analytics: AuthorizationAnalytics, validator: Validator, + storage: CoreStorage, sourceScreen: LogistrationSourceScreen ) { self.interactor = interactor @@ -55,6 +57,7 @@ public class SignInViewModel: ObservableObject { self.config = config self.analytics = analytics self.validator = validator + self.storage = storage self.sourceScreen = sourceScreen } @@ -81,7 +84,7 @@ public class SignInViewModel: ObservableObject { let user = try await interactor.login(username: username, password: password) analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.userLogin(method: .password) - router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen) + router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, authMethod: nil) NotificationCenter.default.post(name: .userAuthorized, object: nil) } catch let error { failure(error) @@ -113,7 +116,14 @@ public class SignInViewModel: ObservableObject { let user = try await interactor.login(externalToken: externalToken, backend: backend) analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.userLogin(method: authMethod) - router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen) + var socialAuthMethod: String? = nil + if case AuthMethod.socailAuth(let method) = authMethod { + socialAuthMethod = method.rawValue + } + router.showMainOrWhatsNewScreen( + sourceScreen: sourceScreen, + authMethod: socialAuthMethod + ) NotificationCenter.default.post(name: .userAuthorized, object: nil) } catch let error { failure(error, authMethod: authMethod) diff --git a/Authorization/Authorization/Presentation/Registration/SignUpView.swift b/Authorization/Authorization/Presentation/Registration/SignUpView.swift index 7ec2c8ba5..9b27e5529 100644 --- a/Authorization/Authorization/Presentation/Registration/SignUpView.swift +++ b/Authorization/Authorization/Presentation/Registration/SignUpView.swift @@ -89,6 +89,21 @@ public struct SignUpView: View { let requiredFields = viewModel.requiredFields let optionalFields = viewModel.optionalFields + + if viewModel.socialAuthEnabled, + !requiredFields.isEmpty { + SocialAuthView( + authType: .register, + viewModel: .init( + config: viewModel.config, + lastUsedOption: viewModel.storage.lastUsedSocialAuth + ) { result in + Task { await viewModel.register(with: result) } + } + ) + .padding(.top, 22) + .padding(.bottom, -2) + } FieldsView( fields: requiredFields, @@ -148,18 +163,6 @@ public struct SignUpView: View { .frame(maxWidth: .infinity) .accessibilityLabel("signup_button") } - if viewModel.socialAuthEnabled, - !requiredFields.isEmpty { - SocialAuthView( - authType: .register, - viewModel: .init( - config: viewModel.config - ) { result in - Task { await viewModel.register(with: result) } - } - ) - .padding(.bottom, 30) - } Spacer() } .padding(.horizontal, 24) @@ -213,6 +216,7 @@ struct SignUpView_Previews: PreviewProvider { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: Validator(), + storage: CoreStorageMock(), sourceScreen: .default ) diff --git a/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift b/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift index f700b2764..9ffd5c31b 100644 --- a/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift +++ b/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift @@ -55,6 +55,7 @@ public class SignUpViewModel: ObservableObject { private let analytics: AuthorizationAnalytics private let validator: Validator var authMethod: AuthMethod = .password + let storage: CoreStorage public init( interactor: AuthInteractorProtocol, @@ -63,6 +64,7 @@ public class SignUpViewModel: ObservableObject { config: ConfigProtocol, cssInjector: CSSInjector, validator: Validator, + storage: CoreStorage, sourceScreen: LogistrationSourceScreen ) { self.interactor = interactor @@ -71,6 +73,7 @@ public class SignUpViewModel: ObservableObject { self.config = config self.cssInjector = cssInjector self.validator = validator + self.storage = storage self.sourceScreen = sourceScreen } @@ -135,7 +138,14 @@ public class SignUpViewModel: ObservableObject { analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.registrationSuccess(method: authMetod.analyticsValue) isShowProgress = false - router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen) + var socialAuthMethod: String? = nil + if case AuthMethod.socailAuth(let method) = authMethod { + socialAuthMethod = method.rawValue + } + router.showMainOrWhatsNewScreen( + sourceScreen: sourceScreen, + authMethod: socialAuthMethod + ) NotificationCenter.default.post(name: .userAuthorized, object: nil) } catch let error { isShowProgress = false @@ -192,7 +202,15 @@ public class SignUpViewModel: ObservableObject { analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.userLogin(method: authMethod) isShowProgress = false - router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen) + var socialAuthMethod: String? = nil + if case AuthMethod.socailAuth(let method) = authMethod { + socialAuthMethod = method.rawValue + } + router.showMainOrWhatsNewScreen( + sourceScreen: sourceScreen, + authMethod: socialAuthMethod + ) + setUsedAuthMethodOption(authMethod: authMethod) NotificationCenter.default.post( name: .userAuthorized, object: [ @@ -208,9 +226,20 @@ public class SignUpViewModel: ObservableObject { isShowProgress = false self.authMethod = authMethod await registerUser(authMetod: authMethod) + setUsedAuthMethodOption(authMethod: authMethod) } } + private func setUsedAuthMethodOption(authMethod: AuthMethod) { + switch authMethod { + case .socailAuth(let auth): + UserDefaults.standard.set(auth.rawValue, forKey: "lastSocialAuthUsedOption") + UserDefaults.standard.synchronize() + default: + break + } + } + private func update(fullName: String?, email: String?) { fields.first(where: { $0.field.type == .email })?.text = email ?? "" fields.first(where: { $0.field.name == "name" })?.text = fullName ?? "" diff --git a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift index 57dc84943..e60e7affb 100644 --- a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift +++ b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift @@ -10,11 +10,10 @@ import Core import Theme struct SocialAuthView: View { - + // MARK: - Properties @StateObject var viewModel: SocialAuthViewModel - let iPadButtonWidth: CGFloat = 260 - + init( authType: SocialAuthType = .signIn, viewModel: SocialAuthViewModel @@ -22,109 +21,133 @@ struct SocialAuthView: View { self._viewModel = .init(wrappedValue: viewModel) self.authType = authType } - + enum SocialAuthType { case signIn case register } var authType: SocialAuthType = .signIn - + private var title: String { + AuthLocalization.continueWith + } + + private var bottomViewText: String { switch authType { case .signIn: - AuthLocalization.signInWith + AuthLocalization.orSignInWith case .register: - AuthLocalization.registerWith + AuthLocalization.orRegisterWith } } - private var columns: [GridItem] { - if isPad { - return [GridItem(.fixed(iPadButtonWidth)), GridItem(.fixed(iPadButtonWidth))] - } - return [GridItem(.flexible())] - } - - private var isPad: Bool { - UIDevice.current.userInterfaceIdiom == .pad - } // MARK: - Views - + var body: some View { - VStack(spacing: 10) { + VStack(spacing: 16) { headerView buttonsView + bottomView } - .padding(.bottom, 20) .frame(maxWidth: .infinity) } - + private var headerView: some View { HStack { - Text("\(AuthLocalization.or) \(title.lowercased()):") - .padding(.vertical, 20) + Text(title) .font(Theme.Fonts.bodyMedium) .accessibilityIdentifier("social_auth_title_text") Spacer() } - .frame(maxWidth: .infinity, minHeight: 42) } - + private var buttonsView: some View { - LazyVGrid(columns: columns) { - if viewModel.googleEnabled { - SocialAuthButton( - image: CoreAssets.iconGoogleWhite.swiftUIImage, - title: "\(title) \(AuthLocalization.google)", - textColor: .black, - backgroundColor: CoreAssets.googleButtonColor.swiftUIColor, - action: { Task { await viewModel.signInWithGoogle() } } - ) - .accessibilityElement(children: .ignore) - .accessibilityLabel("\(title) \(AuthLocalization.google)") - .accessibilityIdentifier("social_auth_google_button") - } - if viewModel.faceboolEnabled { - SocialAuthButton( - image: CoreAssets.iconFacebookWhite.swiftUIImage, - title: "\(title) \(AuthLocalization.facebook)", - backgroundColor: CoreAssets.facebookButtonColor.swiftUIColor, - action: { Task { await viewModel.signInWithFacebook() } } - ) - .accessibilityElement(children: .ignore) - .accessibilityLabel("\(title) \(AuthLocalization.facebook)") - .accessibilityIdentifier("social_auth_facebook_button") - } - if viewModel.microsoftEnabled { - SocialAuthButton( - image: CoreAssets.iconMicrosoftWhite.swiftUIImage, - title: "\(title) \(AuthLocalization.microsoft)", - backgroundColor: CoreAssets.microsoftButtonColor.swiftUIColor, - action: { Task { await viewModel.signInWithMicrosoft() } } - ) - .accessibilityElement(children: .ignore) - .accessibilityLabel("\(title) \(AuthLocalization.microsoft)") - .accessibilityIdentifier("social_auth_microsoft_button") + HStack { + if let lastOption = viewModel.lastUsedOption, + authType == .signIn { + Text(AuthLocalization.lastSignIn) + .font(Theme.Fonts.bodySmall) + .foregroundStyle(Theme.Colors.textPrimary) + socialAuthButton(lastOption) + .padding(.leading, 10) + + Divider() + .frame(width: 1) + .overlay(Theme.Colors.socialAuthColor) + .padding(.horizontal, 20) + + Spacer() } - if viewModel.appleSignInEnabled { - SocialAuthButton( - image: CoreAssets.iconApple.swiftUIImage, - title: "\(title) \(AuthLocalization.apple)", - backgroundColor: CoreAssets.appleButtonColor.swiftUIColor, - action: viewModel.signInWithApple - ) - .accessibilityElement(children: .ignore) - .accessibilityLabel("\(title) \(AuthLocalization.apple)") - .accessibilityIdentifier("social_auth_apple_button") + + HStack { + ForEach(viewModel.enabledOptions, id: \.self) { option in + if option == viewModel.lastUsedOption, authType == .signIn { + } else { + socialAuthButton(option) + .padding(.trailing, 16) + } + } + Spacer() } } + .frame(height: 42) + } + + private func socialAuthButton( + _ option: SocialAuthMethod + ) -> SocialAuthButton { + switch option { + case .google: + return SocialAuthButton( + image: CoreAssets.iconGoogleWhite.swiftUIImage, + accessibilityLabel: "\(title) \(AuthLocalization.google)", + accessibilityIdentifier: "social_auth_google_button", + action: { Task { await viewModel.signInWithGoogle() }} + ) + case .apple: + return SocialAuthButton( + image: CoreAssets.iconApple.swiftUIImage, + accessibilityLabel: "\(title) \(AuthLocalization.apple)", + accessibilityIdentifier: "social_auth_apple_button", + action: { Task { viewModel.signInWithApple() }} + ) + case .facebook: + return SocialAuthButton( + image: CoreAssets.iconFacebook.swiftUIImage, + accessibilityLabel: "\(title) \(AuthLocalization.facebook)", + accessibilityIdentifier: "social_auth_facebook_button", + action: { Task { await viewModel.signInWithFacebook() }} + ) + case .microsoft: + return SocialAuthButton( + image: CoreAssets.iconMicrosoftWhite.swiftUIImage, + accessibilityLabel: "\(title) \(AuthLocalization.microsoft)", + accessibilityIdentifier: "social_auth_microsoft_button", + action: { Task { await viewModel.signInWithMicrosoft() }} + ) + } + } + + private var bottomView: some View { + HStack { + Text(bottomViewText) + .font(Theme.Fonts.bodyMedium) + .accessibilityIdentifier("social_auth_or_signin_with_text") + Spacer() + } + .padding(.top, 16) } } #if DEBUG struct SocialSignView_Previews: PreviewProvider { static var previews: some View { - let vm = SocialAuthViewModel(config: ConfigMock(), completion: { _ in }) + let vm = SocialAuthViewModel( + config: ConfigMock(), + lastUsedOption: nil, + completion: { + _ in + }) SocialAuthView(viewModel: vm).padding() } } diff --git a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift index 24e8ca5b8..1463cc4bc 100644 --- a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift +++ b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift @@ -63,12 +63,21 @@ final public class SocialAuthViewModel: ObservableObject { private var completion: ((Result) -> Void) private let config: ConfigProtocol + @Published var lastUsedOption: SocialAuthMethod? + var enabledOptions: [SocialAuthMethod] = [] + init( config: ConfigProtocol, + lastUsedOption: String?, completion: @escaping (Result) -> Void ) { self.config = config self.completion = completion + if let lastUsedOption { + self.lastUsedOption = SocialAuthMethod(rawValue: lastUsedOption) + } + + configureEnabledOptions() } private lazy var appleAuthProvider: AppleAuthProvider = .init(config: config) @@ -105,6 +114,25 @@ final public class SocialAuthViewModel: ObservableObject { } return config.appleSignIn.enabled } + + func configureEnabledOptions() { + + if googleEnabled { + enabledOptions.append(.google) + } + + if microsoftEnabled { + enabledOptions.append(.microsoft) + } + + if faceboolEnabled { + enabledOptions.append(.facebook) + } + + if appleSignInEnabled { + enabledOptions.append(.apple) + } + } // MARK: - Public Intens diff --git a/Authorization/Authorization/SwiftGen/Strings.swift b/Authorization/Authorization/SwiftGen/Strings.swift index d139b4a0e..e91a52f58 100644 --- a/Authorization/Authorization/SwiftGen/Strings.swift +++ b/Authorization/Authorization/SwiftGen/Strings.swift @@ -12,18 +12,22 @@ import Foundation public enum AuthLocalization { /// Apple public static let apple = AuthLocalization.tr("Localizable", "APPLE", fallback: "Apple") + /// Continue with: + public static let continueWith = AuthLocalization.tr("Localizable", "CONTINUE_WITH", fallback: "Continue with:") /// Facebook public static let facebook = AuthLocalization.tr("Localizable", "FACEBOOK", fallback: "Facebook") /// Google public static let google = AuthLocalization.tr("Localizable", "GOOGLE", fallback: "Google") + /// Last sign in + public static let lastSignIn = AuthLocalization.tr("Localizable", "LAST_SIGN_IN", fallback: "Last sign in") /// Microsoft public static let microsoft = AuthLocalization.tr("Localizable", "MICROSOFT", fallback: "Microsoft") /// Or public static let or = AuthLocalization.tr("Localizable", "OR", fallback: "Or") - /// Register with - public static let registerWith = AuthLocalization.tr("Localizable", "REGISTER_WITH", fallback: "Register with") - /// Sign in with - public static let signInWith = AuthLocalization.tr("Localizable", "SIGN_IN_WITH", fallback: "Sign in with") + /// Or register below: + public static let orRegisterWith = AuthLocalization.tr("Localizable", "OR_REGISTER_WITH", fallback: "Or register below:") + /// Or sign in with email: + public static let orSignInWith = AuthLocalization.tr("Localizable", "OR_SIGN_IN_WITH", fallback: "Or sign in with email:") public enum Error { /// This %@ account is not linked with any %@ account. Please register. public static func accountNotRegistered(_ p1: Any, _ p2: Any) -> String { diff --git a/Authorization/Authorization/en.lproj/Localizable.strings b/Authorization/Authorization/en.lproj/Localizable.strings index f15da07ce..7d82393d7 100644 --- a/Authorization/Authorization/en.lproj/Localizable.strings +++ b/Authorization/Authorization/en.lproj/Localizable.strings @@ -37,8 +37,10 @@ accordance with the [Privacy Policy.](%@)"; "FORGOT.CHECK_TITLE" = "Check your email"; "FORGOT.CHECK_Description" = "We have sent a password recover instructions to your email "; -"SIGN_IN_WITH" = "Sign in with"; -"REGISTER_WITH" = "Register with"; +"CONTINUE_WITH" = "Continue with:"; +"LAST_SIGN_IN" = "Last sign in"; +"OR_SIGN_IN_WITH" = "Or sign in with email:"; +"OR_REGISTER_WITH" = "Or register below:"; "APPLE" = "Apple"; "GOOGLE" = "Google"; "FACEBOOK" = "Facebook"; diff --git a/Authorization/Authorization/uk.lproj/Localizable.strings b/Authorization/Authorization/uk.lproj/Localizable.strings index 00ab874ce..01d1e41b4 100644 --- a/Authorization/Authorization/uk.lproj/Localizable.strings +++ b/Authorization/Authorization/uk.lproj/Localizable.strings @@ -34,8 +34,10 @@ accordance with the [Privacy Policy.](%@)"; "FORGOT.CHECK_TITLE" = "Перевірте свою електронну пошту"; "FORGOT.CHECK_Description" = "Ми надіслали інструкції щодо відновлення пароля на вашу електронну пошту "; -"SIGN_IN_WITH" = "Sign in with"; -"REGISTER_WITH" = "Register with"; +"CONTINUE_WITH" = "Continue with:"; +"LAST_SIGN_IN" = "Last sign in"; +"OR_SIGN_IN_WITH" = "Or sign in with email:"; +"OR_REGISTER_WITH" = "Or register below:"; "APPLE" = "Apple"; "GOOGLE" = "Google"; "FACEBOOK" = "Facebook"; diff --git a/Authorization/AuthorizationTests/AuthorizationMock.generated.swift b/Authorization/AuthorizationTests/AuthorizationMock.generated.swift index 661642afe..cedaa9682 100644 --- a/Authorization/AuthorizationTests/AuthorizationMock.generated.swift +++ b/Authorization/AuthorizationTests/AuthorizationMock.generated.swift @@ -885,10 +885,10 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -1007,7 +1007,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -1055,9 +1055,10 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -1170,7 +1171,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -1198,7 +1199,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -1240,7 +1241,7 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -1288,8 +1289,8 @@ open class AuthorizationRouterMock: AuthorizationRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) @@ -1497,10 +1498,10 @@ open class BaseRouterMock: BaseRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -1618,7 +1619,7 @@ open class BaseRouterMock: BaseRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -1661,9 +1662,10 @@ open class BaseRouterMock: BaseRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -1775,7 +1777,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -1802,7 +1804,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -1843,7 +1845,7 @@ open class BaseRouterMock: BaseRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -1888,8 +1890,8 @@ open class BaseRouterMock: BaseRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) diff --git a/Authorization/AuthorizationTests/Presentation/Login/SignInViewModelTests.swift b/Authorization/AuthorizationTests/Presentation/Login/SignInViewModelTests.swift index e824ad975..c12b4ca06 100644 --- a/Authorization/AuthorizationTests/Presentation/Login/SignInViewModelTests.swift +++ b/Authorization/AuthorizationTests/Presentation/Login/SignInViewModelTests.swift @@ -33,13 +33,14 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) await viewModel.login(username: "", password: "") Verify(interactor, 0, .login(username: .any, password: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, AuthLocalization.Error.invalidEmailAddressOrUsername) XCTAssertEqual(viewModel.isShowProgress, false) @@ -56,12 +57,13 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) await viewModel.login(username: "edxUser@edx.com", password: "") Verify(interactor, 0, .login(username: .any, password: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, AuthLocalization.Error.invalidPasswordLenght) XCTAssertEqual(viewModel.isShowProgress, false) @@ -78,6 +80,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) let user = User(id: 1, username: "username", email: "edxUser@edx.com", name: "Name", userAvatar: "") @@ -88,7 +91,7 @@ final class SignInViewModelTests: XCTestCase { Verify(interactor, 1, .login(username: .any, password: .any)) Verify(analytics, .userLogin(method: .any)) - Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, nil) XCTAssertEqual(viewModel.isShowProgress, true) @@ -105,6 +108,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -119,7 +123,7 @@ final class SignInViewModelTests: XCTestCase { Verify(interactor, 1, .login(externalToken: .any, backend: .any)) Verify(analytics, .userLogin(method: .any)) - Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, nil) XCTAssertEqual(viewModel.isShowProgress, true) @@ -136,6 +140,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -154,7 +159,7 @@ final class SignInViewModelTests: XCTestCase { await viewModel.login(with: result) Verify(interactor, 1, .login(externalToken: .any, backend: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, validationErrorMessage) XCTAssertEqual(viewModel.isShowProgress, false) @@ -171,6 +176,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -183,7 +189,7 @@ final class SignInViewModelTests: XCTestCase { await viewModel.login(username: "edxUser@edx.com", password: "password123") Verify(interactor, 1, .login(username: .any, password: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, validationErrorMessage) XCTAssertEqual(viewModel.isShowProgress, false) @@ -200,6 +206,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -208,7 +215,7 @@ final class SignInViewModelTests: XCTestCase { await viewModel.login(username: "edxUser@edx.com", password: "password123") Verify(interactor, 1, .login(username: .any, password: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, CoreLocalization.Error.invalidCredentials) XCTAssertEqual(viewModel.isShowProgress, false) @@ -225,6 +232,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -233,7 +241,7 @@ final class SignInViewModelTests: XCTestCase { await viewModel.login(username: "edxUser@edx.com", password: "password123") Verify(interactor, 1, .login(username: .any, password: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, CoreLocalization.Error.unknownError) XCTAssertEqual(viewModel.isShowProgress, false) @@ -250,6 +258,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -260,7 +269,7 @@ final class SignInViewModelTests: XCTestCase { await viewModel.login(username: "edxUser@edx.com", password: "password123") Verify(interactor, 1, .login(username: .any, password: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, CoreLocalization.Error.slowOrNoInternetConnection) XCTAssertEqual(viewModel.isShowProgress, false) @@ -277,6 +286,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) diff --git a/Authorization/AuthorizationTests/Presentation/Register/SignUpViewModelTests.swift b/Authorization/AuthorizationTests/Presentation/Register/SignUpViewModelTests.swift index ad180a925..02f1d653e 100644 --- a/Authorization/AuthorizationTests/Presentation/Register/SignUpViewModelTests.swift +++ b/Authorization/AuthorizationTests/Presentation/Register/SignUpViewModelTests.swift @@ -34,6 +34,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -66,6 +67,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -93,6 +95,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -118,6 +121,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -132,7 +136,7 @@ final class SignUpViewModelTests: XCTestCase { Verify(interactor, 1, .validateRegistrationFields(fields: .any)) Verify(interactor, 1, .registerUser(fields: .any, isSocial: .any)) - Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.isShowProgress, false) XCTAssertEqual(viewModel.showError, false) @@ -150,6 +154,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -169,7 +174,7 @@ final class SignUpViewModelTests: XCTestCase { Verify(interactor, 1, .validateRegistrationFields(fields: .any)) Verify(interactor, 0, .registerUser(fields: .any, isSocial: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.isShowProgress, false) XCTAssertEqual(viewModel.showError, false) @@ -188,6 +193,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -198,7 +204,7 @@ final class SignUpViewModelTests: XCTestCase { Verify(interactor, 1, .validateRegistrationFields(fields: .any)) Verify(interactor, 1, .registerUser(fields: .any, isSocial: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.isShowProgress, false) XCTAssertEqual(viewModel.showError, true) @@ -217,6 +223,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -227,7 +234,7 @@ final class SignUpViewModelTests: XCTestCase { Verify(interactor, 1, .validateRegistrationFields(fields: .any)) Verify(interactor, 1, .registerUser(fields: .any, isSocial: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.isShowProgress, false) XCTAssertEqual(viewModel.showError, true) @@ -246,6 +253,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -258,7 +266,7 @@ final class SignUpViewModelTests: XCTestCase { Verify(interactor, 1, .validateRegistrationFields(fields: .any)) Verify(interactor, 1, .registerUser(fields: .any, isSocial: .any)) - Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 0, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.isShowProgress, false) XCTAssertEqual(viewModel.showError, true) @@ -277,6 +285,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) diff --git a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/Contents.json b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/Contents.json index f98d12c7c..c2038f4fa 100644 --- a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/Contents.json +++ b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/Contents.json @@ -5,12 +5,42 @@ "scale" : "1x" }, { - "filename" : "icon_apple@2x.png", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "icon_apple_dark.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "icon_apple_white.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "icon_apple@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], "idiom" : "universal", "scale" : "3x" } diff --git a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@2x.png b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@2x.png deleted file mode 100644 index 6ca46033ab4cd4630f767c5d5d802a3c030946ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 660 zcmV;F0&D$=P)zCs5uexRS=Hj+_+5)@3^&i)AZL zSsU-OMchky?%=KOvBmkk%x&{$tZ)rfPEi^=woxv^UE5_FH&|ahLq6MWDoh?er^{Kh zO&f};659VyTuk+GtPNg7OQeb8mnBZ;#0oi|j~!)V4100HgfC8dHbV9Jvn}>i6_zMF z;MNRWO&v#^+?@K`b9-jItv~L7dj^NFXW|dI0(-D!QMwd37ihh`D{asf*eu1|j#L{w z3M4Ow8gbADI|v7L2Md7**b{4mM}bAnW{es|+$~OF%Yc+x&=t6WEh28@54r-ku; zD6YU2>=7?6U6E%6D`hP)>wqn!Y)_K<{5ZHk7{qKlcG%eWV1lgN4+iZwiFBS~1cH|8 zz7Y;H&4Y4D#ET(ZmWPrD^RyR2_g%{Ww6ZtDo|Mayz>Wtk%(%S5uF9Ec<$npv8bWO| z$0bm8xAYe5=$h)DuJ2S`!d?^CsDVjY=$RsGK-Q5WD>{llX=I%gqDg~w&weBHVp!-0 umD_Ui&E*&*HS46ECw(8SwKAugZT$nDmtTxb$wCPL0000P)nJ0@?|ZPJlas%>>B?s>GdJ*YTatkED$R z-+Ow5oa68#-JMPr@Wvbe6(Sn5-LtLPwro>agGFUtV4Eoh@(w48c#?mt*fLm#h2Hv5 zjgdh+eqN?<4$XLvrm%))$gQ@0p<6SBW>`R(C{(T+Lo4DbO6Lxmp#ffnX2>NCDQs1T zufPIUiDENohebRlcytO2^aw54E@1(3duxaX(w-$X=@2U+yE@kV9N_?vTO}pjCIj&GIZXLT-*ez=lxa{46qf54Ue> zM;5A?gmGsnmE1-@g?=iw>pHRNoU`N($z$lILPMyq7slSJW9a9movL=t*<0vm-j!$n z6~=xA)?Mdu;d|9}Flc+$!a@0K=mgXjn?XN$XrL|j0=g+;=VxnS{1h8(i`AYQ7O}zK zVo7@e+EK*@W4W<8tci_ILu+EkvB6g*ww*2#bhG1q_I+ru?b!;tk$Q6$8f=R_URC|y z5j?fE#r}YPCZU|cS{Mtm{j9nM+G01bfjmapYc$!bLGeXf*eRc0H7gcf`|NkvVclGv zyToo_2Z>M-EH&`XFqR8S*a_vDJXAN9=Q|mU5z39{Fi7wzp0QQ=nb@i43ycx-tht3M z=viNAw&dNa@5#F*@6Mu?3h!MDE3-78<-KJY-&#{ZH_r}BtwGJ87wMGAn!$FOj3e!k=`u?r{WoRi?!nuMD=1rl(;1*op2=<86X2U|S+iwmolKc64$_rM7 zL;rp3;m>q>loWXy`Jzs8az(8LhO=S&3Eyqrc>mJdM+|RIl6&3sb*{e%a((_~!hd~D puG2dy^(5D5ol{z)^)ltYzW@n)sO9)zkTn1R002ovPDHLkV1mT;toHx_ diff --git a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_dark.png b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..495f6740d8206c59ddce07cba011f6ef1eb45886 GIT binary patch literal 1002 zcmV5{ia>@2n?%ZiQltW>OBbh02RuQXCjg!x_7gzf0NwzeAV-zfq@p3-G+?S& zB1J&*ZDtQ!LDufwp6$DJkx#M!?;6j)J3BKwNAN%pR7-aPbwIr%g<3RAZ#ow(i4k~$ zf_WZP>-VG%pit6(D~t!BKq~7SY&h)=zkl66AK4Cpg0LCSYZzh-3K5{)#%w&hkiap< zAa?=fpc+J^K3j$*dI&KFxeJ&9YWyQG4l4T6k)uVQ0l5p{)&FQ5VB@c4>kwm-y8sR^ z)#3M)qGL9G4-+6)0XkuEoG(3kOOm1;cAGjTMDB@lpqxr)$Y!$VA%krK#@SJhfC zLY1I4mFgc*QY|8Jc6Hf0N&4*LGJ@0az`eTq#bVE*2uE2Cb|wL_;k`H{))J;kB7{*y z&4D4>==&MeRHSxOK06@fbMnbWh?9WW0HF?ewd=@6tN$gz&{=STNHwm0d~YVrnL!Hi zmXrF*zkWb=%Kg_IMuKXK%PYA3b#rE$kt$$*Y2_OXp|ChuM5%Iq+wEMKMiay6>iUNE zcaO$HC%pYDX%7t6GoWi2_Q5th(m%*YNpq|_AcVC5D+D&anP$93*#Ci3xXTO4#y4Ch z8U=9uuKhlMCzPP3>s+INNO)a+%=K{MI@jhx0lYz>l&!AoY@-0KabCg`T!zRj^Nj+O z%AWQo$j>a33+qZ`Ak*$!T!=EQ!X!~j1zF~sU5Ma(h;pE+3rN?=HW!lcNB_d(hIt2~ zhdSOHO6|Jtf>FR6JPY7FbSEOGTFiJK=yp4Q7M992_)TbU(=Ia_>xE`u-GLBO0GHK`%GzdoHK=Zz#;pSSJ)98JLBL(?z%-DYiHS}zC2(XkR;Y;rX1U2k z@S4@#N;$4s^h}d;5$7rhzqg_exVJhf6q`J-k zCl?yPuGD!}s@(9sbsPC1IqJN3eMT_S0}gIG)&+69-P$tehu4Ht!R1Kr-;M<&Sh!MK zuosD$jE}zwBcgk!g3#cjw)G%{q&8Y-%(O>IdI4C>7O98l2HGtng;Or$53{sX{xc2y Y1;77MqnWS9u>b%707*qoM6N<$f~AMZwEzGB literal 0 HcmV?d00001 diff --git a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_white.png b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_white.png new file mode 100644 index 0000000000000000000000000000000000000000..97f82b6ebf19d298312b6f76da2daadd536d3735 GIT binary patch literal 660 zcmV;F0&D$=P)u_Y6Q8&`Qsd^pLB`@ zHhM3oeu*JK*Co>uV+c?-VO{3@6diJp{)suhIrgK`C_%@J&;Y)R6TUoi zJaHKJ@t$MLBG(mt$9#!6Ufge3PA;|_G5^K^ePD%`Je2t~S>?;4OQoqt-!mKPvb;J0 zE2_`V#gUpZM_Ziu9qG}|gtGWE%_Lh7%4l`y)_ZKg0fUf z>2|bFodOefse6m(A*H?!|ET=XE^P4^Cdx))L)m{J?1&i`_H1EE=QP{bD_G;HWnwts#G~yRuqJo)vM4~YO0000IUxQ6`ZUHfcF=Qw zkb{gMq=X1P9O9IPY_Px$q(h$+uCgejt-wTZ7WynS!kM55U4zipRYXgH4=3s(Z^6S* zK4A@ikL>%xGusHPG$BuTwnvlzQGT&h0hv0{9>oYV;ExW1TRZ7{w1cL5O?L~= z!w)n^~fIkD+GjE(F#cW>xeNBD%Ou~WBZA50bSVto!y%YC$YlsYH~ zY%-@}c9Z+50%L^>WJjN)MGM73sLa{q##2B>pGj2{8Np6=jx}I*7W^3)rDl_}y*eBr zdRPypvrv%(Gr?12$8(ZKQyLD=ACwn9C-&?>XI&tCl5-^>YT0>?;&>ke`PQEy9w`u% z=7YEm9dHgJgJI-iK3;#`2u30Z6gF~#WPygtiDeoF;$yx-EW6YJr?54H{5-aJG?f)W z6Vk#q#F4NDm}UW#T;V{%sEzG~6`PTj92PMHRM13_ulA55n4}$1iX23uP~MC&6)0tG z$)K_*kS-cJ26LD`N&sHu^w%R21;%*6rjdS)coq}d_zdtGk%|p4m+BktUp!#L$Ur80 z9v?Knsz;?01;~5R2|bH0%(9u7ySQBTui)D@G@$(KuU-l6e(|xP@pdD;c<^*e&Bj^v zickq2=_YallgBIXEC=@;owBS48tBQvrxINn@WmCj1X6RFnCp}aZPhHWzfCUxlesOK z1*tpD28%g1>iRXEQmo8N!7FdL?zBLsnUj1jqbYe+ZNg#r`GNv6J;s^}R63~a;CR_O zvoxXMhFxB$5^uB>4YB*-H7#WfD>E|jhcYN3!bjCxBU4IIf;-rVPbhyw<2bHZ9Geq! z2M_EM_26d$>w&OLe>bKZ*ECU5FV6FJL;FRWRIq>6=5N)L?$~QpB|N_{Ad1`}M@$5- zRa3i3L^g lOHKh__}n)?;vtVcw0|uQYX7VlIA%S{kAxO9R`H@HraW`eX6BpZ|spc6D3s1lgep_m^=2KsqV z<<&0kSHj4)0QklPAOs>V=%UD$WD9L2XR?H^K@cP$#31n`IHJohvPfGO*pU<23)wR{ zbA~Y?(J|Q(hx1OhBU9iTjx9(k5^Zlr8%Ok3U(1Ef#+KHD2WSIj zvkH&3?C?Lg9ma~<28mIQ7&_8Xe2SI%A6CX0o}vow=`lZnEQ)MnHeAH(NGTXjLc;%p zAO4!rHzO|<^+)gr3%^7^&o<=EiY^BbfTG^GQ`M1MRhoa-wAtV%`_mk7hcdiEvv8^P zBjWMOY17r~Hrn>){B+%x{A=>`8)A`%B?e?NTL*rgv?SnZmPbBpm=K*pUEaGh ziyyb>^Oe^9zJ-j%iNeE*4Ejx;A$Qe=u;!2c!2G7q0|hp#HhvMW zrw=?ri&`L16or!Ck|>s^LC925!;y16offY+u0piXTt3MbO4@q>K0z ei^6U+RP+b`ibVn+mM94T0000gi6@nC1s&B`UZIv6O|-5$|AoA-|-iOoh;piz5Gm*tn-q1Tq)% zkHR5ki*YO{^O8RlE-&QUd$_9Ok&-WQD62Ys;}%^)VKlI9xkndJzeUM$D-LJ) zNT-9FYDN8QQ>yq@b>EW;QDRPBa6BYF(k3mE2c8P;ko+!N#aon(Q&RGejE&}0vzs;7 z8MU}pDW`dyMOl#Mlay+>xZ~@6Y+6W6ep%3gQ8KlEkWt+Nd{?2LZ~(OzW?{>3YWYt3 zdIdjdwmTdbX`kZKGbr;GpTuwk9o8nMyZP;UOgF=3J2E}_iZEFBY{f4&!cf-uMexTP z!eYxQ&I*4^SE=BS1T8QRu#0(KX=@_(;zT|ag}H%0mQ6>U#?|GiM(Bc=Q-MYKjpXYhe^dK5+*3$QY$+_mf6_ z{?8oZ#m?`yraLk?y3_xPQ31^C>BIY&*%@2-nqdAY^t`WYiuVG;}*U0gEW2xID2 zg5i=BKkQCaJz%(O-TRg>1NNHN-Coi*wK+7e(Xia}Ct(KYHE*^t)xOE_A2^Muy9()v z=C*%Wg)s^ap-SzYg5A4(!s0w3yj@Q&c_<4@s@9ccBD&Y}HG6p8SA}v)g^>vxPQK$b zrayC*byglKS0atONnO^)?XG-Gy4U5@c292`xEje~iRcZ088advY(i zKJ;f)oNOF2-Xj7XYosiK$iq25#7jDbvR8Xvsr+TId4v2GCHcsEjknanZ^--yg{qc> Ty#Z_K00000NkvXXu0mjfylU7l diff --git a/Core/Core/Configuration/BaseRouter.swift b/Core/Core/Configuration/BaseRouter.swift index ec69e09a4..8e9aa4c8b 100644 --- a/Core/Core/Configuration/BaseRouter.swift +++ b/Core/Core/Configuration/BaseRouter.swift @@ -21,7 +21,10 @@ public protocol BaseRouter { func removeLastView(controllers: Int) - func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) + func showMainOrWhatsNewScreen( + sourceScreen: LogistrationSourceScreen, + authMethod: String? + ) func showStartupScreen() @@ -106,7 +109,10 @@ open class BaseRouterMock: BaseRouter { public func dismiss(animated: Bool) {} - public func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) {} + public func showMainOrWhatsNewScreen( + sourceScreen: LogistrationSourceScreen, + authMethod: String? + ) {} public func showStartupScreen() {} diff --git a/Core/Core/Data/CoreStorage.swift b/Core/Core/Data/CoreStorage.swift index 60837da41..157b705fd 100644 --- a/Core/Core/Data/CoreStorage.swift +++ b/Core/Core/Data/CoreStorage.swift @@ -19,6 +19,7 @@ public protocol CoreStorage { var user: DataLayer.User? {get set} var userSettings: UserSettings? {get set} var resetAppSupportDirectoryUserData: Bool? {get set} + var lastUsedSocialAuth: String? {get set} func clear() } @@ -35,6 +36,7 @@ public class CoreStorageMock: CoreStorage { public var user: DataLayer.User? public var userSettings: UserSettings? public var resetAppSupportDirectoryUserData: Bool? + public var lastUsedSocialAuth: String? public func clear() {} public init() {} diff --git a/Core/Core/SwiftGen/Assets.swift b/Core/Core/SwiftGen/Assets.swift index c52d9f811..54db2785a 100644 --- a/Core/Core/SwiftGen/Assets.swift +++ b/Core/Core/SwiftGen/Assets.swift @@ -93,7 +93,7 @@ public enum CoreAssets { public static let noAvatar = ImageAsset(name: "noAvatar") public static let removePhoto = ImageAsset(name: "removePhoto") public static let iconApple = ImageAsset(name: "icon_apple") - public static let iconFacebookWhite = ImageAsset(name: "icon_facebook_white") + public static let iconFacebook = ImageAsset(name: "icon_facebook") public static let iconGoogleWhite = ImageAsset(name: "icon_google_white") public static let iconMicrosoftWhite = ImageAsset(name: "icon_microsoft_white") public static let upgradeArrowImage = ImageAsset(name: "UpgradeArrowImage") diff --git a/Core/Core/View/Base/SocialAuthButton.swift b/Core/Core/View/Base/SocialAuthButton.swift index 74224fa25..8e99442a9 100644 --- a/Core/Core/View/Base/SocialAuthButton.swift +++ b/Core/Core/View/Base/SocialAuthButton.swift @@ -15,25 +15,19 @@ public struct SocialAuthButton: View { private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } private var image: Image - private var title: String - private var textColor: Color - private var backgroundColor: Color - private var cornerRadius: CGFloat + private var accessibilityLabel: String + private var accessibilityIdentifier: String private var action: () -> Void public init( image: Image, - title: String, - textColor: Color = .white, - backgroundColor: Color = .accentColor, - cornerRadius: CGFloat = 8, + accessibilityLabel: String, + accessibilityIdentifier: String, action: @escaping () -> Void ) { self.image = image - self.title = title - self.textColor = textColor - self.backgroundColor = backgroundColor - self.cornerRadius = cornerRadius + self.accessibilityLabel = accessibilityLabel + self.accessibilityIdentifier = accessibilityIdentifier self.action = action } @@ -43,22 +37,25 @@ public struct SocialAuthButton: View { Button { action() } label: { - Label { - Text(title) - .foregroundStyle(textColor) - .padding(.leading, 10) - .font(Theme.Fonts.bodyLarge) - Spacer() - } icon: { - image.padding(.leading, 10) - } + image + .padding() } - .frame(maxWidth: idiom == .pad ? 260: .infinity, minHeight: 42) - .background(backgroundColor) - .clipShape( + .frame(maxWidth: 42, maxHeight: 42) + .overlay( Theme.Shapes.buttonShape + .stroke(style: .init( + lineWidth: 1, + lineCap: .round, + lineJoin: .round, + miterLimit: 1) + ) + .foregroundColor( + Theme.Colors.socialAuthColor + ) ) - + .accessibilityElement(children: .ignore) + .accessibilityLabel(accessibilityLabel) + .accessibilityIdentifier(accessibilityIdentifier) } } @@ -67,8 +64,8 @@ struct LabelButton_Previews: PreviewProvider { static var previews: some View { SocialAuthButton( image: CoreAssets.iconApple.swiftUIImage, - title: "Apple", - backgroundColor: CoreAssets.appleButtonColor.swiftUIColor, + accessibilityLabel: "social auth button", + accessibilityIdentifier: "some_identifier", action: { } ) } diff --git a/Course/CourseTests/CourseMock.generated.swift b/Course/CourseTests/CourseMock.generated.swift index 38639507f..befa47961 100644 --- a/Course/CourseTests/CourseMock.generated.swift +++ b/Course/CourseTests/CourseMock.generated.swift @@ -539,10 +539,10 @@ open class BaseRouterMock: BaseRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -660,7 +660,7 @@ open class BaseRouterMock: BaseRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -703,9 +703,10 @@ open class BaseRouterMock: BaseRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -817,7 +818,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -844,7 +845,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -885,7 +886,7 @@ open class BaseRouterMock: BaseRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -930,8 +931,8 @@ open class BaseRouterMock: BaseRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) diff --git a/Dashboard/DashboardTests/DashboardMock.generated.swift b/Dashboard/DashboardTests/DashboardMock.generated.swift index 5250ac326..c47407720 100644 --- a/Dashboard/DashboardTests/DashboardMock.generated.swift +++ b/Dashboard/DashboardTests/DashboardMock.generated.swift @@ -539,10 +539,10 @@ open class BaseRouterMock: BaseRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -660,7 +660,7 @@ open class BaseRouterMock: BaseRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -703,9 +703,10 @@ open class BaseRouterMock: BaseRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -817,7 +818,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -844,7 +845,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -885,7 +886,7 @@ open class BaseRouterMock: BaseRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -930,8 +931,8 @@ open class BaseRouterMock: BaseRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) diff --git a/Discovery/DiscoveryTests/DiscoveryMock.generated.swift b/Discovery/DiscoveryTests/DiscoveryMock.generated.swift index e52eb4c60..86252851f 100644 --- a/Discovery/DiscoveryTests/DiscoveryMock.generated.swift +++ b/Discovery/DiscoveryTests/DiscoveryMock.generated.swift @@ -539,10 +539,10 @@ open class BaseRouterMock: BaseRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -660,7 +660,7 @@ open class BaseRouterMock: BaseRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -703,9 +703,10 @@ open class BaseRouterMock: BaseRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -817,7 +818,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -844,7 +845,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -885,7 +886,7 @@ open class BaseRouterMock: BaseRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -930,8 +931,8 @@ open class BaseRouterMock: BaseRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) diff --git a/Discussion/DiscussionTests/DiscussionMock.generated.swift b/Discussion/DiscussionTests/DiscussionMock.generated.swift index b63c781e0..4317ca595 100644 --- a/Discussion/DiscussionTests/DiscussionMock.generated.swift +++ b/Discussion/DiscussionTests/DiscussionMock.generated.swift @@ -539,10 +539,10 @@ open class BaseRouterMock: BaseRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -660,7 +660,7 @@ open class BaseRouterMock: BaseRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -703,9 +703,10 @@ open class BaseRouterMock: BaseRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -817,7 +818,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -844,7 +845,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -885,7 +886,7 @@ open class BaseRouterMock: BaseRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -930,8 +931,8 @@ open class BaseRouterMock: BaseRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) @@ -3879,10 +3880,10 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -4006,7 +4007,7 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -4095,9 +4096,10 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -4215,7 +4217,7 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -4248,7 +4250,7 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -4295,7 +4297,7 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -4358,8 +4360,8 @@ open class DiscussionRouterMock: DiscussionRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) diff --git a/OpenEdX/DI/ScreenAssembly.swift b/OpenEdX/DI/ScreenAssembly.swift index a3b27eeb7..f233c97bb 100644 --- a/OpenEdX/DI/ScreenAssembly.swift +++ b/OpenEdX/DI/ScreenAssembly.swift @@ -59,6 +59,7 @@ class ScreenAssembly: Assembly { config: r.resolve(ConfigProtocol.self)!, analytics: r.resolve(AuthorizationAnalytics.self)!, validator: r.resolve(Validator.self)!, + storage: r.resolve(CoreStorage.self)!, sourceScreen: sourceScreen ) } @@ -70,6 +71,7 @@ class ScreenAssembly: Assembly { config: r.resolve(ConfigProtocol.self)!, cssInjector: r.resolve(CSSInjector.self)!, validator: r.resolve(Validator.self)!, + storage: r.resolve(CoreStorage.self)!, sourceScreen: sourceScreen ) } diff --git a/OpenEdX/Data/AppStorage.swift b/OpenEdX/Data/AppStorage.swift index 2da3a295e..d1695daa1 100644 --- a/OpenEdX/Data/AppStorage.swift +++ b/OpenEdX/Data/AppStorage.swift @@ -237,6 +237,19 @@ public class AppStorage: CoreStorage, ProfileStorage, WhatsNewStorage, CourseSto } } + public var lastUsedSocialAuth: String? { + get { + return userDefaults.string(forKey: KEY_LAST_USED_SOCIAL_AUTH) + } + set(newValue) { + if let newValue { + userDefaults.set(newValue, forKey: KEY_LAST_USED_SOCIAL_AUTH) + } else { + userDefaults.removeObject(forKey: KEY_LAST_USED_SOCIAL_AUTH) + } + } + } + public func clear() { accessToken = nil refreshToken = nil @@ -265,4 +278,5 @@ public class AppStorage: CoreStorage, ProfileStorage, WhatsNewStorage, CourseSto private let KEY_APPLE_SIGN_EMAIL = "appleSignEmail" private let KEY_ALLOWED_DOWNLOAD_LARGE_FILE = "allowedDownloadLargeFile" private let KEY_RESET_APP_SUPPORT_DIRECTORY_USER_DATA = "resetAppSupportDirectoryUserData" + private let KEY_LAST_USED_SOCIAL_AUTH = "lastUsedSocialAuth" } diff --git a/OpenEdX/Router.swift b/OpenEdX/Router.swift index f6318c9cc..b2f813ac2 100644 --- a/OpenEdX/Router.swift +++ b/OpenEdX/Router.swift @@ -71,17 +71,24 @@ public class Router: AuthorizationRouter, navigationController.setViewControllers(viewControllers, animated: true) } - public func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { + public func showMainOrWhatsNewScreen( + sourceScreen: LogistrationSourceScreen, + authMethod: String? + ) { showToolBar() var whatsNewStorage = Container.shared.resolve(WhatsNewStorage.self)! let config = Container.shared.resolve(ConfigProtocol.self)! let persistence = Container.shared.resolve(CorePersistenceProtocol.self)! - let coreStorage = Container.shared.resolve(CoreStorage.self)! + var coreStorage = Container.shared.resolve(CoreStorage.self)! let analytics = Container.shared.resolve(WhatsNewAnalytics.self)! if let userId = coreStorage.user?.id { persistence.set(userId: userId) } + + if let authMethod = authMethod { + coreStorage.lastUsedSocialAuth = authMethod + } let viewModel = WhatsNewViewModel(storage: whatsNewStorage, sourceScreen: sourceScreen, analytics: analytics) let whatsNew = WhatsNewView(router: Container.shared.resolve(WhatsNewRouter.self)!, viewModel: viewModel) diff --git a/OpenEdX/View/MainScreenViewModel.swift b/OpenEdX/View/MainScreenViewModel.swift index 45189cfba..576884eff 100644 --- a/OpenEdX/View/MainScreenViewModel.swift +++ b/OpenEdX/View/MainScreenViewModel.swift @@ -43,10 +43,9 @@ final class MainScreenViewModel: ObservableObject { .sink { [weak self] object in guard let self, let dict = object.object as? [String: Any], - let authMethod = dict["authMethod"] as? AuthMethod, - let shouldShowBanner = dict["showSocialRegisterBanner"] as? Bool + let authMethod = dict["authMethod"] as? AuthMethod else { return } - self.shouldShowRegisterBanner = shouldShowBanner + self.shouldShowRegisterBanner = dict["showSocialRegisterBanner"] as? Bool ?? false self.authMethod = authMethod } .store(in: &cancellations) diff --git a/Profile/ProfileTests/ProfileMock.generated.swift b/Profile/ProfileTests/ProfileMock.generated.swift index 0f67899ad..43dc0d0e8 100644 --- a/Profile/ProfileTests/ProfileMock.generated.swift +++ b/Profile/ProfileTests/ProfileMock.generated.swift @@ -539,10 +539,10 @@ open class BaseRouterMock: BaseRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -660,7 +660,7 @@ open class BaseRouterMock: BaseRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -703,9 +703,10 @@ open class BaseRouterMock: BaseRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -817,7 +818,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -844,7 +845,7 @@ open class BaseRouterMock: BaseRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -885,7 +886,7 @@ open class BaseRouterMock: BaseRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -930,8 +931,8 @@ open class BaseRouterMock: BaseRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) @@ -4317,10 +4318,10 @@ open class ProfileRouterMock: ProfileRouter, Mock { perform?(`controllers`) } - open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) { - addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) - let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter.value(`sourceScreen`))) as? (LogistrationSourceScreen) -> Void - perform?(`sourceScreen`) + open func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen, authMethod: String?) { + addInvocation(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) + let perform = methodPerformValue(.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter.value(`sourceScreen`), Parameter.value(`authMethod`))) as? (LogistrationSourceScreen, String?) -> Void + perform?(`sourceScreen`, `authMethod`) } open func showStartupScreen() { @@ -4448,7 +4449,7 @@ open class ProfileRouterMock: ProfileRouter, Mock { case m_backWithFade case m_dismiss__animated_animated(Parameter) case m_removeLastView__controllers_controllers(Parameter) - case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(Parameter) + case m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(Parameter, Parameter) case m_showStartupScreen case m_showLoginScreen__sourceScreen_sourceScreen(Parameter) case m_showRegisterScreen__sourceScreen_sourceScreen(Parameter) @@ -4524,9 +4525,10 @@ open class ProfileRouterMock: ProfileRouter, Mock { results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsControllers, rhs: rhsControllers, with: matcher), lhsControllers, rhsControllers, "controllers")) return Matcher.ComparisonResult(results) - case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let lhsSourcescreen), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(let rhsSourcescreen)): + case (.m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let lhsSourcescreen, let lhsAuthmethod), .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(let rhsSourcescreen, let rhsAuthmethod)): var results: [Matcher.ParameterComparisonResult] = [] results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsSourcescreen, rhs: rhsSourcescreen, with: matcher), lhsSourcescreen, rhsSourcescreen, "sourceScreen")) + results.append(Matcher.ParameterComparisonResult(Parameter.compare(lhs: lhsAuthmethod, rhs: rhsAuthmethod, with: matcher), lhsAuthmethod, rhsAuthmethod, "authMethod")) return Matcher.ComparisonResult(results) case (.m_showStartupScreen, .m_showStartupScreen): return .match @@ -4648,7 +4650,7 @@ open class ProfileRouterMock: ProfileRouter, Mock { case .m_backWithFade: return 0 case let .m_dismiss__animated_animated(p0): return p0.intValue case let .m_removeLastView__controllers_controllers(p0): return p0.intValue - case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(p0): return p0.intValue + case let .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(p0, p1): return p0.intValue + p1.intValue case .m_showStartupScreen: return 0 case let .m_showLoginScreen__sourceScreen_sourceScreen(p0): return p0.intValue case let .m_showRegisterScreen__sourceScreen_sourceScreen(p0): return p0.intValue @@ -4685,7 +4687,7 @@ open class ProfileRouterMock: ProfileRouter, Mock { case .m_backWithFade: return ".backWithFade()" case .m_dismiss__animated_animated: return ".dismiss(animated:)" case .m_removeLastView__controllers_controllers: return ".removeLastView(controllers:)" - case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen: return ".showMainOrWhatsNewScreen(sourceScreen:)" + case .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod: return ".showMainOrWhatsNewScreen(sourceScreen:authMethod:)" case .m_showStartupScreen: return ".showStartupScreen()" case .m_showLoginScreen__sourceScreen_sourceScreen: return ".showLoginScreen(sourceScreen:)" case .m_showRegisterScreen__sourceScreen_sourceScreen: return ".showRegisterScreen(sourceScreen:)" @@ -4736,7 +4738,7 @@ open class ProfileRouterMock: ProfileRouter, Mock { public static func backWithFade() -> Verify { return Verify(method: .m_backWithFade)} public static func dismiss(animated: Parameter) -> Verify { return Verify(method: .m_dismiss__animated_animated(`animated`))} public static func removeLastView(controllers: Parameter) -> Verify { return Verify(method: .m_removeLastView__controllers_controllers(`controllers`))} - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`))} + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter) -> Verify { return Verify(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`))} public static func showStartupScreen() -> Verify { return Verify(method: .m_showStartupScreen)} public static func showLoginScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showLoginScreen__sourceScreen_sourceScreen(`sourceScreen`))} public static func showRegisterScreen(sourceScreen: Parameter) -> Verify { return Verify(method: .m_showRegisterScreen__sourceScreen_sourceScreen(`sourceScreen`))} @@ -4811,8 +4813,8 @@ open class ProfileRouterMock: ProfileRouter, Mock { public static func removeLastView(controllers: Parameter, perform: @escaping (Int) -> Void) -> Perform { return Perform(method: .m_removeLastView__controllers_controllers(`controllers`), performs: perform) } - public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, perform: @escaping (LogistrationSourceScreen) -> Void) -> Perform { - return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreen(`sourceScreen`), performs: perform) + public static func showMainOrWhatsNewScreen(sourceScreen: Parameter, authMethod: Parameter, perform: @escaping (LogistrationSourceScreen, String?) -> Void) -> Perform { + return Perform(method: .m_showMainOrWhatsNewScreen__sourceScreen_sourceScreenauthMethod_authMethod(`sourceScreen`, `authMethod`), performs: perform) } public static func showStartupScreen(perform: @escaping () -> Void) -> Perform { return Perform(method: .m_showStartupScreen, performs: perform) diff --git a/Theme/Theme/Assets.xcassets/Colors/SocialAuthColor.colorset/Contents.json b/Theme/Theme/Assets.xcassets/Colors/SocialAuthColor.colorset/Contents.json new file mode 100644 index 000000000..bf1a96417 --- /dev/null +++ b/Theme/Theme/Assets.xcassets/Colors/SocialAuthColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.408", + "red" : "0.235" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF8", + "green" : "0x78", + "red" : "0x53" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Theme/Theme/SwiftGen/ThemeAssets.swift b/Theme/Theme/SwiftGen/ThemeAssets.swift index c02d768ca..70c31b721 100644 --- a/Theme/Theme/SwiftGen/ThemeAssets.swift +++ b/Theme/Theme/SwiftGen/ThemeAssets.swift @@ -73,6 +73,7 @@ public enum ThemeAssets { public static let snackbarInfoColor = ColorAsset(name: "SnackbarInfoColor") public static let snackbarTextColor = ColorAsset(name: "SnackbarTextColor") public static let snackbarWarningColor = ColorAsset(name: "SnackbarWarningColor") + public static let socialAuthColor = ColorAsset(name: "SocialAuthColor") public static let styledButtonText = ColorAsset(name: "StyledButtonText") public static let success = ColorAsset(name: "Success") public static let tabbarActiveColor = ColorAsset(name: "TabbarActiveColor") diff --git a/Theme/Theme/Theme.swift b/Theme/Theme/Theme.swift index 92b2c8472..d3a66c27f 100644 --- a/Theme/Theme/Theme.swift +++ b/Theme/Theme/Theme.swift @@ -79,6 +79,7 @@ public struct Theme { public private(set) static var courseProgressBG = ThemeAssets.courseProgressBG.swiftUIColor public private(set) static var resumeButtonBG = ThemeAssets.resumeButtonBG.swiftUIColor public private(set) static var resumeButtonText = ThemeAssets.resumeButtonText.swiftUIColor + public private(set) static var socialAuthColor = ThemeAssets.socialAuthColor.swiftUIColor public static func update( accentColor: Color = ThemeAssets.accentColor.swiftUIColor, diff --git a/WhatsNew/WhatsNew/Presentation/WhatsNewView.swift b/WhatsNew/WhatsNew/Presentation/WhatsNewView.swift index 4fbd03c4e..5628c0131 100644 --- a/WhatsNew/WhatsNew/Presentation/WhatsNewView.swift +++ b/WhatsNew/WhatsNew/Presentation/WhatsNewView.swift @@ -110,7 +110,10 @@ public struct WhatsNewView: View { index += 1 } } else { - router.showMainOrWhatsNewScreen(sourceScreen: viewModel.sourceScreen) + router.showMainOrWhatsNewScreen( + sourceScreen: viewModel.sourceScreen, + authMethod: nil + ) } if viewModel.index == viewModel.newItems.count - 1 { @@ -144,11 +147,18 @@ public struct WhatsNewView: View { } .navigationTitle(WhatsNewLocalization.title) .toolbar { - ToolbarItem(placement: .navigationBarTrailing, content: { - Button(action: { - router.showMainOrWhatsNewScreen(sourceScreen: viewModel.sourceScreen) - viewModel.logWhatsNewClose() - }, label: { + ToolbarItem( + placement: .navigationBarTrailing, + content: { + Button( + action: { + router.showMainOrWhatsNewScreen( + sourceScreen: viewModel.sourceScreen, + authMethod: nil + ) + viewModel.logWhatsNewClose() + }, + label: { Image(systemName: "xmark") .foregroundColor(Theme.Colors.accentXColor) }) From bbeffced1d75720264b3808cf3f6bbcb1540c023 Mon Sep 17 00:00:00 2001 From: Saeed Bashir Date: Tue, 19 Nov 2024 10:44:56 +0500 Subject: [PATCH 2/3] refactor: address review feedback --- .../Presentation/Login/SignInViewModel.swift | 2 +- .../Registration/SignUpViewModel.swift | 14 +------------- .../Presentation/SocialAuth/SocialAuthView.swift | 5 +++-- .../SocialAuth/SocialAuthViewModel.swift | 1 - 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Authorization/Authorization/Presentation/Login/SignInViewModel.swift b/Authorization/Authorization/Presentation/Login/SignInViewModel.swift index f80ed6dbe..8b6b80e9d 100644 --- a/Authorization/Authorization/Presentation/Login/SignInViewModel.swift +++ b/Authorization/Authorization/Presentation/Login/SignInViewModel.swift @@ -116,7 +116,7 @@ public class SignInViewModel: ObservableObject { let user = try await interactor.login(externalToken: externalToken, backend: backend) analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.userLogin(method: authMethod) - var socialAuthMethod: String? = nil + var socialAuthMethod: String? if case AuthMethod.socailAuth(let method) = authMethod { socialAuthMethod = method.rawValue } diff --git a/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift b/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift index 9ffd5c31b..d7eab51eb 100644 --- a/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift +++ b/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift @@ -138,7 +138,7 @@ public class SignUpViewModel: ObservableObject { analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.registrationSuccess(method: authMetod.analyticsValue) isShowProgress = false - var socialAuthMethod: String? = nil + var socialAuthMethod: String? if case AuthMethod.socailAuth(let method) = authMethod { socialAuthMethod = method.rawValue } @@ -210,7 +210,6 @@ public class SignUpViewModel: ObservableObject { sourceScreen: sourceScreen, authMethod: socialAuthMethod ) - setUsedAuthMethodOption(authMethod: authMethod) NotificationCenter.default.post( name: .userAuthorized, object: [ @@ -226,17 +225,6 @@ public class SignUpViewModel: ObservableObject { isShowProgress = false self.authMethod = authMethod await registerUser(authMetod: authMethod) - setUsedAuthMethodOption(authMethod: authMethod) - } - } - - private func setUsedAuthMethodOption(authMethod: AuthMethod) { - switch authMethod { - case .socailAuth(let auth): - UserDefaults.standard.set(auth.rawValue, forKey: "lastSocialAuthUsedOption") - UserDefaults.standard.synchronize() - default: - break } } diff --git a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift index e60e7affb..41a7e6cb5 100644 --- a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift +++ b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift @@ -68,6 +68,7 @@ struct SocialAuthView: View { Text(AuthLocalization.lastSignIn) .font(Theme.Fonts.bodySmall) .foregroundStyle(Theme.Colors.textPrimary) + socialAuthButton(lastOption) .padding(.leading, 10) @@ -75,14 +76,14 @@ struct SocialAuthView: View { .frame(width: 1) .overlay(Theme.Colors.socialAuthColor) .padding(.horizontal, 20) + .opacity(viewModel.enabledOptions.count == 1 ? 0 : 1) Spacer() } HStack { ForEach(viewModel.enabledOptions, id: \.self) { option in - if option == viewModel.lastUsedOption, authType == .signIn { - } else { + if option != viewModel.lastUsedOption || authType != .signIn { socialAuthButton(option) .padding(.trailing, 16) } diff --git a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift index 1463cc4bc..625e5361f 100644 --- a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift +++ b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift @@ -116,7 +116,6 @@ final public class SocialAuthViewModel: ObservableObject { } func configureEnabledOptions() { - if googleEnabled { enabledOptions.append(.google) } From 2d2ff603467ec4ec22d6be7394f3af8ef3ecc06c Mon Sep 17 00:00:00 2001 From: Saeed Bashir Date: Fri, 22 Nov 2024 12:27:06 +0500 Subject: [PATCH 3/3] refactor: address review feedback --- .../Presentation/SocialAuth/SocialAuthView.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift index 41a7e6cb5..6fda03cb4 100644 --- a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift +++ b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift @@ -75,7 +75,7 @@ struct SocialAuthView: View { Divider() .frame(width: 1) .overlay(Theme.Colors.socialAuthColor) - .padding(.horizontal, 20) + .padding(.horizontal, 16) .opacity(viewModel.enabledOptions.count == 1 ? 0 : 1) Spacer() @@ -85,7 +85,7 @@ struct SocialAuthView: View { ForEach(viewModel.enabledOptions, id: \.self) { option in if option != viewModel.lastUsedOption || authType != .signIn { socialAuthButton(option) - .padding(.trailing, 16) + .padding(.trailing, option == viewModel.enabledOptions.last ? 0 : 12) } } Spacer() @@ -146,9 +146,8 @@ struct SocialSignView_Previews: PreviewProvider { let vm = SocialAuthViewModel( config: ConfigMock(), lastUsedOption: nil, - completion: { - _ in - }) + completion: { _ in } + ) SocialAuthView(viewModel: vm).padding() } }