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 6ca46033a..000000000 Binary files a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@2x.png and /dev/null differ diff --git a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@3x.png b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@3x.png deleted file mode 100644 index 87995a5ef..000000000 Binary files a/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple@3x.png and /dev/null differ 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 000000000..495f6740d Binary files /dev/null and b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_dark.png differ 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 000000000..97f82b6eb Binary files /dev/null and b/Core/Core/Assets.xcassets/Socials/icon_apple.imageset/icon_apple_white.png differ diff --git a/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/Contents.json b/Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/Contents.json similarity index 73% rename from Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/Contents.json rename to Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/Contents.json index af6600d1a..5f7fe66fd 100644 --- a/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/Contents.json +++ b/Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/Contents.json @@ -5,12 +5,11 @@ "scale" : "1x" }, { - "filename" : "icon_facebook_white@2x.png", + "filename" : "icon_facebook.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "icon_facebook_white@3x.png", "idiom" : "universal", "scale" : "3x" } diff --git a/Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/icon_facebook.png b/Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/icon_facebook.png new file mode 100644 index 000000000..1a1568468 Binary files /dev/null and b/Core/Core/Assets.xcassets/Socials/icon_facebook.imageset/icon_facebook.png differ diff --git a/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@2x.png b/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@2x.png deleted file mode 100644 index 109a67604..000000000 Binary files a/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@2x.png and /dev/null differ diff --git a/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@3x.png b/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@3x.png deleted file mode 100644 index 1623f36fd..000000000 Binary files a/Core/Core/Assets.xcassets/Socials/icon_facebook_white.imageset/icon_facebook_white@3x.png and /dev/null differ 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) })