diff --git a/Authorization/Authorization/Presentation/Login/SignInView.swift b/Authorization/Authorization/Presentation/Login/SignInView.swift index dd1b895e5..f92309117 100644 --- a/Authorization/Authorization/Presentation/Login/SignInView.swift +++ b/Authorization/Authorization/Presentation/Login/SignInView.swift @@ -73,6 +73,18 @@ 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) @@ -231,15 +243,6 @@ public struct SignInView: View { } } } - if viewModel.socialAuthEnabled { - SocialAuthView( - viewModel: .init( - config: viewModel.config - ) { result in - Task { await viewModel.login(with: result) } - } - ) - } agreements Spacer() } @@ -329,6 +332,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 b2ef69786..d05386709 100644 --- a/Authorization/Authorization/Presentation/Login/SignInViewModel.swift +++ b/Authorization/Authorization/Presentation/Login/SignInViewModel.swift @@ -43,6 +43,7 @@ public class SignInViewModel: ObservableObject { private let interactor: AuthInteractorProtocol private let analytics: AuthorizationAnalytics private let validator: Validator + let storage: CoreStorage public init( interactor: AuthInteractorProtocol, @@ -50,6 +51,7 @@ public class SignInViewModel: ObservableObject { config: ConfigProtocol, analytics: AuthorizationAnalytics, validator: Validator, + storage: CoreStorage, sourceScreen: LogistrationSourceScreen ) { self.interactor = interactor @@ -57,6 +59,7 @@ public class SignInViewModel: ObservableObject { self.config = config self.analytics = analytics self.validator = validator + self.storage = storage self.sourceScreen = sourceScreen } @@ -83,7 +86,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) @@ -98,7 +101,7 @@ public class SignInViewModel: ObservableObject { let user = try await interactor.login(ssoToken: "") 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) } catch let error { failure(error) } @@ -129,7 +132,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? + 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 1651b6060..4bf20dda2 100644 --- a/Authorization/Authorization/Presentation/Registration/SignUpView.swift +++ b/Authorization/Authorization/Presentation/Registration/SignUpView.swift @@ -90,6 +90,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, @@ -149,18 +164,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) @@ -214,6 +217,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 8123cb1d1..51d2db3f8 100644 --- a/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift +++ b/Authorization/Authorization/Presentation/Registration/SignUpViewModel.swift @@ -57,6 +57,7 @@ public final class SignUpViewModel: ObservableObject { private let analytics: AuthorizationAnalytics private let validator: Validator var authMethod: AuthMethod = .password + let storage: CoreStorage public init( interactor: AuthInteractorProtocol, @@ -65,6 +66,7 @@ public final class SignUpViewModel: ObservableObject { config: ConfigProtocol, cssInjector: CSSInjector, validator: Validator, + storage: CoreStorage, sourceScreen: LogistrationSourceScreen ) { self.interactor = interactor @@ -73,6 +75,7 @@ public final class SignUpViewModel: ObservableObject { self.config = config self.cssInjector = cssInjector self.validator = validator + self.storage = storage self.sourceScreen = sourceScreen } @@ -137,7 +140,14 @@ public final 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? + 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 @@ -194,7 +204,14 @@ public final 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? + if case AuthMethod.socailAuth(let method) = authMethod { + socialAuthMethod = method.rawValue + } + router.showMainOrWhatsNewScreen( + sourceScreen: sourceScreen, + authMethod: socialAuthMethod + ) NotificationCenter.default.post( name: .userAuthorized, object: [ @@ -212,7 +229,7 @@ public final class SignUpViewModel: ObservableObject { await registerUser(authMetod: authMethod) } } - + 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/SSO/SSOWebViewModel.swift b/Authorization/Authorization/Presentation/SSO/SSOWebViewModel.swift index 2437254d5..198766e2c 100644 --- a/Authorization/Authorization/Presentation/SSO/SSOWebViewModel.swift +++ b/Authorization/Authorization/Presentation/SSO/SSOWebViewModel.swift @@ -82,7 +82,7 @@ public class SSOWebViewModel: ObservableObject { let user = try await interactor.login(ssoToken: "\(payload).\(signature)") analytics.identify(id: "\(user.id)", username: user.username, email: user.email) analytics.userLogin(method: .SSO) - router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen) + router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, authMethod: nil) } catch let error { failure(error, authMethod: .SSO) } diff --git a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthView.swift index 57dc84943..6fda03cb4 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, 16) + .opacity(viewModel.enabledOptions.count == 1 ? 0 : 1) + + 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 { + socialAuthButton(option) + .padding(.trailing, option == viewModel.enabledOptions.last ? 0 : 12) + } + } + 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 5dbe3cfd0..4182c390d 100644 --- a/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift +++ b/Authorization/Authorization/Presentation/SocialAuth/SocialAuthViewModel.swift @@ -64,12 +64,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) @@ -106,6 +115,24 @@ 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/SocialAuth/MicrosoftAuthProvider.swift b/Authorization/Authorization/SocialAuth/MicrosoftAuthProvider.swift index 813c755f1..62508e078 100644 --- a/Authorization/Authorization/SocialAuth/MicrosoftAuthProvider.swift +++ b/Authorization/Authorization/SocialAuth/MicrosoftAuthProvider.swift @@ -78,10 +78,11 @@ public final class MicrosoftAuthProvider { } private func createClientApplication() throws -> MSALPublicClientApplication { - guard let config = Container.shared.resolve(ConfigProtocol.self), let appID = config.microsoft.appID else { + guard let config = Container.shared.resolve(ConfigProtocol.self), + let clientID = config.microsoft.clientID else { throw SocialAuthError.error(text: "Configuration error") } - let configuration = MSALPublicClientApplicationConfig(clientId: appID) + let configuration = MSALPublicClientApplicationConfig(clientId: clientID) do { return try MSALPublicClientApplication(configuration: configuration) diff --git a/Authorization/Authorization/SwiftGen/Strings.swift b/Authorization/Authorization/SwiftGen/Strings.swift index 11eeb9a91..c72255aa0 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 5285b05e6..de9e0dd5f 100644 --- a/Authorization/Authorization/en.lproj/Localizable.strings +++ b/Authorization/Authorization/en.lproj/Localizable.strings @@ -40,8 +40,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/AuthorizationTests/AuthorizationMock.generated.swift b/Authorization/AuthorizationTests/AuthorizationMock.generated.swift index 31285ffcb..df20635a8 100644 --- a/Authorization/AuthorizationTests/AuthorizationMock.generated.swift +++ b/Authorization/AuthorizationTests/AuthorizationMock.generated.swift @@ -927,10 +927,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) @@ -1049,9 +1049,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 @@ -1132,7 +1133,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 @@ -1154,7 +1155,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:)" @@ -1190,7 +1191,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`))} @@ -1226,8 +1227,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) @@ -1411,10 +1412,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() { @@ -1490,7 +1491,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) @@ -1527,9 +1528,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 @@ -1609,7 +1611,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 @@ -1630,7 +1632,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:)" @@ -1665,7 +1667,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`))} @@ -1698,8 +1700,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 a75a51d4c..e9e558d0f 100644 --- a/Authorization/AuthorizationTests/Presentation/Login/SignInViewModelTests.swift +++ b/Authorization/AuthorizationTests/Presentation/Login/SignInViewModelTests.swift @@ -35,13 +35,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) @@ -58,12 +59,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) @@ -80,6 +82,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: "") @@ -90,7 +93,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) @@ -107,6 +110,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: "") @@ -116,7 +120,7 @@ final class SignInViewModelTests: XCTestCase { await viewModel.ssoLogin(title: "Riyadah") Verify(interactor, 1, .login(ssoToken: .any)) - Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any)) + Verify(router, 1, .showMainOrWhatsNewScreen(sourceScreen: .any, authMethod: .any)) XCTAssertEqual(viewModel.errorMessage, nil) XCTAssertEqual(viewModel.isShowProgress, true) @@ -133,6 +137,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -147,7 +152,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) @@ -164,6 +169,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -182,7 +188,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) @@ -199,6 +205,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -211,7 +218,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) @@ -228,6 +235,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -236,7 +244,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) @@ -253,6 +261,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -261,7 +270,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) @@ -278,6 +287,7 @@ final class SignInViewModelTests: XCTestCase { config: ConfigMock(), analytics: analytics, validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -288,7 +298,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) @@ -305,6 +315,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 3d680dc63..15128c7a0 100644 --- a/Authorization/AuthorizationTests/Presentation/Register/SignUpViewModelTests.swift +++ b/Authorization/AuthorizationTests/Presentation/Register/SignUpViewModelTests.swift @@ -36,6 +36,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -68,6 +69,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -95,6 +97,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -120,6 +123,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -134,7 +138,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) @@ -152,6 +156,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -171,7 +176,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) @@ -190,6 +195,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -200,7 +206,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) @@ -219,6 +225,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -229,7 +236,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) @@ -248,6 +255,7 @@ final class SignUpViewModelTests: XCTestCase { config: ConfigMock(), cssInjector: CSSInjectorMock(), validator: validator, + storage: CoreStorageMock(), sourceScreen: .default ) @@ -260,7 +268,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) @@ -279,6 +287,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 f36868494..0f592e750 100644 --- a/Core/Core/Configuration/BaseRouter.swift +++ b/Core/Core/Configuration/BaseRouter.swift @@ -22,7 +22,10 @@ public protocol BaseRouter: Sendable { func removeLastView(controllers: Int) - func showMainOrWhatsNewScreen(sourceScreen: LogistrationSourceScreen) + func showMainOrWhatsNewScreen( + sourceScreen: LogistrationSourceScreen, + authMethod: String? + ) func showStartupScreen() @@ -82,7 +85,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/Configuration/Config/MicrosoftConfig.swift b/Core/Core/Configuration/Config/MicrosoftConfig.swift index eb3d4d825..c38ec6dcb 100644 --- a/Core/Core/Configuration/Config/MicrosoftConfig.swift +++ b/Core/Core/Configuration/Config/MicrosoftConfig.swift @@ -9,19 +9,19 @@ import Foundation private enum MicrosoftKeys: String { case enabled = "ENABLED" - case appID = "APP_ID" + case clientID = "CLIENT_ID" } public final class MicrosoftConfig: NSObject { public var enabled: Bool = false - public private(set) var appID: String? + public private(set) var clientID: String? private var requiredKeysAvailable: Bool { - return appID != nil + return clientID != nil } init(dictionary: [String: AnyObject]) { - appID = dictionary[MicrosoftKeys.appID.rawValue] as? String + clientID = dictionary[MicrosoftKeys.clientID.rawValue] as? String super.init() enabled = requiredKeysAvailable && dictionary[MicrosoftKeys.enabled.rawValue] as? Bool == true } diff --git a/Core/Core/Data/CoreStorage.swift b/Core/Core/Data/CoreStorage.swift index c7fedbd52..aacfd973b 100644 --- a/Core/Core/Data/CoreStorage.swift +++ b/Core/Core/Data/CoreStorage.swift @@ -21,6 +21,7 @@ public protocol CoreStorage: Sendable { var userSettings: UserSettings? {get set} var resetAppSupportDirectoryUserData: Bool? {get set} var useRelativeDates: Bool {get set} + var lastUsedSocialAuth: String? {get set} func clear() } @@ -38,6 +39,7 @@ public final class CoreStorageMock: CoreStorage, @unchecked Sendable { public var userSettings: UserSettings? public var resetAppSupportDirectoryUserData: Bool? public var useRelativeDates: Bool = true + public var lastUsedSocialAuth: String? public func clear() {} public init() {} diff --git a/Core/Core/SwiftGen/Assets.swift b/Core/Core/SwiftGen/Assets.swift index 0b846c4a9..89329e99c 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 rotateDevice = ImageAsset(name: "rotateDevice") 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/Core/CoreTests/Configuration/ConfigTests.swift b/Core/CoreTests/Configuration/ConfigTests.swift index c408e02a5..ed51d45a7 100644 --- a/Core/CoreTests/Configuration/ConfigTests.swift +++ b/Core/CoreTests/Configuration/ConfigTests.swift @@ -48,7 +48,7 @@ class ConfigTests: XCTestCase { ], "MICROSOFT": [ "ENABLED": true, - "APP_ID": "appId" + "CLIENT_ID": "cliendID" ], "APPLE_SIGNIN": [ "ENABLED": true @@ -119,7 +119,7 @@ class ConfigTests: XCTestCase { let config = Config(properties: properties) XCTAssertTrue(config.microsoft.enabled) - XCTAssertEqual(config.microsoft.appID, "appId") + XCTAssertEqual(config.microsoft.clientID, "cliendID") } func testAppleConfigInitialization() { diff --git a/Core/CoreTests/CoreMock.generated.swift b/Core/CoreTests/CoreMock.generated.swift index 9b2d098b5..d483cb7bf 100644 --- a/Core/CoreTests/CoreMock.generated.swift +++ b/Core/CoreTests/CoreMock.generated.swift @@ -579,10 +579,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() { @@ -658,7 +658,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) @@ -695,9 +695,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 @@ -777,7 +778,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 @@ -798,7 +799,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:)" @@ -833,7 +834,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`))} @@ -866,8 +867,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) @@ -3119,6 +3120,12 @@ open class CoreStorageMock: CoreStorage, Mock { } private var __p_useRelativeDates: (Bool)? + public var lastUsedSocialAuth: String? { + get { invocations.append(.p_lastUsedSocialAuth_get); return __p_lastUsedSocialAuth ?? optionalGivenGetterValue(.p_lastUsedSocialAuth_get, "CoreStorageMock - stub value for lastUsedSocialAuth was not defined") } + set { invocations.append(.p_lastUsedSocialAuth_set(.value(newValue))); __p_lastUsedSocialAuth = newValue } + } + private var __p_lastUsedSocialAuth: (String)? + @@ -3156,6 +3163,8 @@ open class CoreStorageMock: CoreStorage, Mock { case p_resetAppSupportDirectoryUserData_set(Parameter) case p_useRelativeDates_get case p_useRelativeDates_set(Parameter) + case p_lastUsedSocialAuth_get + case p_lastUsedSocialAuth_set(Parameter) static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult { switch (lhs, rhs) { @@ -3184,6 +3193,8 @@ open class CoreStorageMock: CoreStorage, Mock { case (.p_resetAppSupportDirectoryUserData_set(let left),.p_resetAppSupportDirectoryUserData_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) case (.p_useRelativeDates_get,.p_useRelativeDates_get): return Matcher.ComparisonResult.match case (.p_useRelativeDates_set(let left),.p_useRelativeDates_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) + case (.p_lastUsedSocialAuth_get,.p_lastUsedSocialAuth_get): return Matcher.ComparisonResult.match + case (.p_lastUsedSocialAuth_set(let left),.p_lastUsedSocialAuth_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) default: return .none } } @@ -3215,6 +3226,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set(let newValue): return newValue.intValue case .p_useRelativeDates_get: return 0 case .p_useRelativeDates_set(let newValue): return newValue.intValue + case .p_lastUsedSocialAuth_get: return 0 + case .p_lastUsedSocialAuth_set(let newValue): return newValue.intValue } } func assertionName() -> String { @@ -3244,6 +3257,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set: return "[set] .resetAppSupportDirectoryUserData" case .p_useRelativeDates_get: return "[get] .useRelativeDates" case .p_useRelativeDates_set: return "[set] .useRelativeDates" + case .p_lastUsedSocialAuth_get: return "[get] .lastUsedSocialAuth" + case .p_lastUsedSocialAuth_set: return "[set] .lastUsedSocialAuth" } } } @@ -3292,6 +3307,9 @@ open class CoreStorageMock: CoreStorage, Mock { public static func useRelativeDates(getter defaultValue: Bool...) -> PropertyStub { return Given(method: .p_useRelativeDates_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) } + public static func lastUsedSocialAuth(getter defaultValue: String?...) -> PropertyStub { + return Given(method: .p_lastUsedSocialAuth_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) + } } @@ -3323,6 +3341,8 @@ open class CoreStorageMock: CoreStorage, Mock { public static func resetAppSupportDirectoryUserData(set newValue: Parameter) -> Verify { return Verify(method: .p_resetAppSupportDirectoryUserData_set(newValue)) } public static var useRelativeDates: Verify { return Verify(method: .p_useRelativeDates_get) } public static func useRelativeDates(set newValue: Parameter) -> Verify { return Verify(method: .p_useRelativeDates_set(newValue)) } + public static var lastUsedSocialAuth: Verify { return Verify(method: .p_lastUsedSocialAuth_get) } + public static func lastUsedSocialAuth(set newValue: Parameter) -> Verify { return Verify(method: .p_lastUsedSocialAuth_set(newValue)) } } public struct Perform { diff --git a/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift b/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift index f7132b16f..6f555d0dd 100644 --- a/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift +++ b/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift @@ -131,23 +131,13 @@ struct CustomDisclosureGroup: View { alignment: .leading ) } - if let sequentialProgress = sequential.sequentialProgress, - let assignmentType = sequentialProgress.assignmentType, - let numPointsEarned = sequentialProgress.numPointsEarned, - let numPointsPossible = sequentialProgress.numPointsPossible, - let due = sequential.due { - let daysRemaining = getAssignmentStatus(for: due) - Text( - """ - \(assignmentType) - - \(daysRemaining) - - \(numPointsEarned) / - \(numPointsPossible) - """ - ) - .font(Theme.Fonts.bodySmall) - .multilineTextAlignment(.leading) - .lineLimit(2) + if let assignmentStatusText = assignmentStatusText( + sequential: sequential + ) { + Text(assignmentStatusText) + .font(Theme.Fonts.bodySmall) + .multilineTextAlignment(.leading) + .lineLimit(2) } } .foregroundColor(Theme.Colors.textPrimary) @@ -225,6 +215,21 @@ struct CustomDisclosureGroup: View { } return false } + + private func assignmentStatusText( + sequential: CourseSequential + ) -> String? { + + guard let sequentialProgress = sequential.sequentialProgress, + let assignmentType = sequentialProgress.assignmentType, + let due = sequential.due else { + return nil + } + + let daysRemaining = getAssignmentStatus(for: due) + + return "\(assignmentType) - \(daysRemaining)" + } private func downloadAllSubsections(in chapter: CourseChapter, state: DownloadViewState) { Task { diff --git a/Course/CourseTests/CourseMock.generated.swift b/Course/CourseTests/CourseMock.generated.swift index d19ad5f4e..b521e9725 100644 --- a/Course/CourseTests/CourseMock.generated.swift +++ b/Course/CourseTests/CourseMock.generated.swift @@ -581,10 +581,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) @@ -697,9 +697,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 @@ -779,7 +780,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 @@ -800,7 +801,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:)" @@ -835,7 +836,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`))} @@ -868,8 +869,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) @@ -3121,6 +3122,12 @@ open class CoreStorageMock: CoreStorage, Mock { } private var __p_useRelativeDates: (Bool)? + public var lastUsedSocialAuth: String? { + get { invocations.append(.p_lastUsedSocialAuth_get); return __p_lastUsedSocialAuth ?? optionalGivenGetterValue(.p_lastUsedSocialAuth_get, "CoreStorageMock - stub value for lastUsedSocialAuth was not defined") } + set { invocations.append(.p_lastUsedSocialAuth_set(.value(newValue))); __p_lastUsedSocialAuth = newValue } + } + private var __p_lastUsedSocialAuth: (String)? + @@ -3158,6 +3165,8 @@ open class CoreStorageMock: CoreStorage, Mock { case p_resetAppSupportDirectoryUserData_set(Parameter) case p_useRelativeDates_get case p_useRelativeDates_set(Parameter) + case p_lastUsedSocialAuth_get + case p_lastUsedSocialAuth_set(Parameter) static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult { switch (lhs, rhs) { @@ -3186,6 +3195,8 @@ open class CoreStorageMock: CoreStorage, Mock { case (.p_resetAppSupportDirectoryUserData_set(let left),.p_resetAppSupportDirectoryUserData_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) case (.p_useRelativeDates_get,.p_useRelativeDates_get): return Matcher.ComparisonResult.match case (.p_useRelativeDates_set(let left),.p_useRelativeDates_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) + case (.p_lastUsedSocialAuth_get,.p_lastUsedSocialAuth_get): return Matcher.ComparisonResult.match + case (.p_lastUsedSocialAuth_set(let left),.p_lastUsedSocialAuth_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) default: return .none } } @@ -3217,6 +3228,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set(let newValue): return newValue.intValue case .p_useRelativeDates_get: return 0 case .p_useRelativeDates_set(let newValue): return newValue.intValue + case .p_lastUsedSocialAuth_get: return 0 + case .p_lastUsedSocialAuth_set(let newValue): return newValue.intValue } } func assertionName() -> String { @@ -3246,6 +3259,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set: return "[set] .resetAppSupportDirectoryUserData" case .p_useRelativeDates_get: return "[get] .useRelativeDates" case .p_useRelativeDates_set: return "[set] .useRelativeDates" + case .p_lastUsedSocialAuth_get: return "[get] .lastUsedSocialAuth" + case .p_lastUsedSocialAuth_set: return "[set] .lastUsedSocialAuth" } } } @@ -3294,6 +3309,9 @@ open class CoreStorageMock: CoreStorage, Mock { public static func useRelativeDates(getter defaultValue: Bool...) -> PropertyStub { return Given(method: .p_useRelativeDates_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) } + public static func lastUsedSocialAuth(getter defaultValue: String?...) -> PropertyStub { + return Given(method: .p_lastUsedSocialAuth_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) + } } @@ -3325,6 +3343,8 @@ open class CoreStorageMock: CoreStorage, Mock { public static func resetAppSupportDirectoryUserData(set newValue: Parameter) -> Verify { return Verify(method: .p_resetAppSupportDirectoryUserData_set(newValue)) } public static var useRelativeDates: Verify { return Verify(method: .p_useRelativeDates_get) } public static func useRelativeDates(set newValue: Parameter) -> Verify { return Verify(method: .p_useRelativeDates_set(newValue)) } + public static var lastUsedSocialAuth: Verify { return Verify(method: .p_lastUsedSocialAuth_get) } + public static func lastUsedSocialAuth(set newValue: Parameter) -> Verify { return Verify(method: .p_lastUsedSocialAuth_set(newValue)) } } public struct Perform { diff --git a/Dashboard/DashboardTests/DashboardMock.generated.swift b/Dashboard/DashboardTests/DashboardMock.generated.swift index 1508c25a1..291eb6e81 100644 --- a/Dashboard/DashboardTests/DashboardMock.generated.swift +++ b/Dashboard/DashboardTests/DashboardMock.generated.swift @@ -581,10 +581,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) @@ -697,9 +697,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 @@ -779,7 +780,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 @@ -800,7 +801,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:)" @@ -835,7 +836,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`))} @@ -868,8 +869,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) @@ -3121,6 +3122,12 @@ open class CoreStorageMock: CoreStorage, Mock { } private var __p_useRelativeDates: (Bool)? + public var lastUsedSocialAuth: String? { + get { invocations.append(.p_lastUsedSocialAuth_get); return __p_lastUsedSocialAuth ?? optionalGivenGetterValue(.p_lastUsedSocialAuth_get, "CoreStorageMock - stub value for lastUsedSocialAuth was not defined") } + set { invocations.append(.p_lastUsedSocialAuth_set(.value(newValue))); __p_lastUsedSocialAuth = newValue } + } + private var __p_lastUsedSocialAuth: (String)? + @@ -3158,6 +3165,8 @@ open class CoreStorageMock: CoreStorage, Mock { case p_resetAppSupportDirectoryUserData_set(Parameter) case p_useRelativeDates_get case p_useRelativeDates_set(Parameter) + case p_lastUsedSocialAuth_get + case p_lastUsedSocialAuth_set(Parameter) static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult { switch (lhs, rhs) { @@ -3186,6 +3195,8 @@ open class CoreStorageMock: CoreStorage, Mock { case (.p_resetAppSupportDirectoryUserData_set(let left),.p_resetAppSupportDirectoryUserData_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) case (.p_useRelativeDates_get,.p_useRelativeDates_get): return Matcher.ComparisonResult.match case (.p_useRelativeDates_set(let left),.p_useRelativeDates_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) + case (.p_lastUsedSocialAuth_get,.p_lastUsedSocialAuth_get): return Matcher.ComparisonResult.match + case (.p_lastUsedSocialAuth_set(let left),.p_lastUsedSocialAuth_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) default: return .none } } @@ -3217,6 +3228,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set(let newValue): return newValue.intValue case .p_useRelativeDates_get: return 0 case .p_useRelativeDates_set(let newValue): return newValue.intValue + case .p_lastUsedSocialAuth_get: return 0 + case .p_lastUsedSocialAuth_set(let newValue): return newValue.intValue } } func assertionName() -> String { @@ -3246,6 +3259,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set: return "[set] .resetAppSupportDirectoryUserData" case .p_useRelativeDates_get: return "[get] .useRelativeDates" case .p_useRelativeDates_set: return "[set] .useRelativeDates" + case .p_lastUsedSocialAuth_get: return "[get] .lastUsedSocialAuth" + case .p_lastUsedSocialAuth_set: return "[set] .lastUsedSocialAuth" } } } @@ -3294,6 +3309,9 @@ open class CoreStorageMock: CoreStorage, Mock { public static func useRelativeDates(getter defaultValue: Bool...) -> PropertyStub { return Given(method: .p_useRelativeDates_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) } + public static func lastUsedSocialAuth(getter defaultValue: String?...) -> PropertyStub { + return Given(method: .p_lastUsedSocialAuth_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) + } } @@ -3325,6 +3343,8 @@ open class CoreStorageMock: CoreStorage, Mock { public static func resetAppSupportDirectoryUserData(set newValue: Parameter) -> Verify { return Verify(method: .p_resetAppSupportDirectoryUserData_set(newValue)) } public static var useRelativeDates: Verify { return Verify(method: .p_useRelativeDates_get) } public static func useRelativeDates(set newValue: Parameter) -> Verify { return Verify(method: .p_useRelativeDates_set(newValue)) } + public static var lastUsedSocialAuth: Verify { return Verify(method: .p_lastUsedSocialAuth_get) } + public static func lastUsedSocialAuth(set newValue: Parameter) -> Verify { return Verify(method: .p_lastUsedSocialAuth_set(newValue)) } } public struct Perform { diff --git a/Discovery/DiscoveryTests/DiscoveryMock.generated.swift b/Discovery/DiscoveryTests/DiscoveryMock.generated.swift index 52d805914..1aabd5860 100644 --- a/Discovery/DiscoveryTests/DiscoveryMock.generated.swift +++ b/Discovery/DiscoveryTests/DiscoveryMock.generated.swift @@ -581,10 +581,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) @@ -697,9 +697,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 @@ -779,7 +780,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 @@ -800,7 +801,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:)" @@ -835,7 +836,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`))} @@ -868,8 +869,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) @@ -3121,6 +3122,12 @@ open class CoreStorageMock: CoreStorage, Mock { } private var __p_useRelativeDates: (Bool)? + public var lastUsedSocialAuth: String? { + get { invocations.append(.p_lastUsedSocialAuth_get); return __p_lastUsedSocialAuth ?? optionalGivenGetterValue(.p_lastUsedSocialAuth_get, "CoreStorageMock - stub value for lastUsedSocialAuth was not defined") } + set { invocations.append(.p_lastUsedSocialAuth_set(.value(newValue))); __p_lastUsedSocialAuth = newValue } + } + private var __p_lastUsedSocialAuth: (String)? + @@ -3158,6 +3165,8 @@ open class CoreStorageMock: CoreStorage, Mock { case p_resetAppSupportDirectoryUserData_set(Parameter) case p_useRelativeDates_get case p_useRelativeDates_set(Parameter) + case p_lastUsedSocialAuth_get + case p_lastUsedSocialAuth_set(Parameter) static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult { switch (lhs, rhs) { @@ -3186,6 +3195,8 @@ open class CoreStorageMock: CoreStorage, Mock { case (.p_resetAppSupportDirectoryUserData_set(let left),.p_resetAppSupportDirectoryUserData_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) case (.p_useRelativeDates_get,.p_useRelativeDates_get): return Matcher.ComparisonResult.match case (.p_useRelativeDates_set(let left),.p_useRelativeDates_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) + case (.p_lastUsedSocialAuth_get,.p_lastUsedSocialAuth_get): return Matcher.ComparisonResult.match + case (.p_lastUsedSocialAuth_set(let left),.p_lastUsedSocialAuth_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) default: return .none } } @@ -3217,6 +3228,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set(let newValue): return newValue.intValue case .p_useRelativeDates_get: return 0 case .p_useRelativeDates_set(let newValue): return newValue.intValue + case .p_lastUsedSocialAuth_get: return 0 + case .p_lastUsedSocialAuth_set(let newValue): return newValue.intValue } } func assertionName() -> String { @@ -3246,6 +3259,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set: return "[set] .resetAppSupportDirectoryUserData" case .p_useRelativeDates_get: return "[get] .useRelativeDates" case .p_useRelativeDates_set: return "[set] .useRelativeDates" + case .p_lastUsedSocialAuth_get: return "[get] .lastUsedSocialAuth" + case .p_lastUsedSocialAuth_set: return "[set] .lastUsedSocialAuth" } } } @@ -3294,6 +3309,9 @@ open class CoreStorageMock: CoreStorage, Mock { public static func useRelativeDates(getter defaultValue: Bool...) -> PropertyStub { return Given(method: .p_useRelativeDates_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) } + public static func lastUsedSocialAuth(getter defaultValue: String?...) -> PropertyStub { + return Given(method: .p_lastUsedSocialAuth_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) + } } @@ -3325,6 +3343,8 @@ open class CoreStorageMock: CoreStorage, Mock { public static func resetAppSupportDirectoryUserData(set newValue: Parameter) -> Verify { return Verify(method: .p_resetAppSupportDirectoryUserData_set(newValue)) } public static var useRelativeDates: Verify { return Verify(method: .p_useRelativeDates_get) } public static func useRelativeDates(set newValue: Parameter) -> Verify { return Verify(method: .p_useRelativeDates_set(newValue)) } + public static var lastUsedSocialAuth: Verify { return Verify(method: .p_lastUsedSocialAuth_get) } + public static func lastUsedSocialAuth(set newValue: Parameter) -> Verify { return Verify(method: .p_lastUsedSocialAuth_set(newValue)) } } public struct Perform { diff --git a/Discussion/DiscussionTests/DiscussionMock.generated.swift b/Discussion/DiscussionTests/DiscussionMock.generated.swift index 3cff451fc..17383de14 100644 --- a/Discussion/DiscussionTests/DiscussionMock.generated.swift +++ b/Discussion/DiscussionTests/DiscussionMock.generated.swift @@ -581,10 +581,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) @@ -697,9 +697,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 @@ -779,7 +780,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 @@ -800,7 +801,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:)" @@ -835,7 +836,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`))} @@ -868,8 +869,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) @@ -3121,6 +3122,12 @@ open class CoreStorageMock: CoreStorage, Mock { } private var __p_useRelativeDates: (Bool)? + public var lastUsedSocialAuth: String? { + get { invocations.append(.p_lastUsedSocialAuth_get); return __p_lastUsedSocialAuth ?? optionalGivenGetterValue(.p_lastUsedSocialAuth_get, "CoreStorageMock - stub value for lastUsedSocialAuth was not defined") } + set { invocations.append(.p_lastUsedSocialAuth_set(.value(newValue))); __p_lastUsedSocialAuth = newValue } + } + private var __p_lastUsedSocialAuth: (String)? + @@ -3158,6 +3165,8 @@ open class CoreStorageMock: CoreStorage, Mock { case p_resetAppSupportDirectoryUserData_set(Parameter) case p_useRelativeDates_get case p_useRelativeDates_set(Parameter) + case p_lastUsedSocialAuth_get + case p_lastUsedSocialAuth_set(Parameter) static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult { switch (lhs, rhs) { @@ -3186,6 +3195,8 @@ open class CoreStorageMock: CoreStorage, Mock { case (.p_resetAppSupportDirectoryUserData_set(let left),.p_resetAppSupportDirectoryUserData_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) case (.p_useRelativeDates_get,.p_useRelativeDates_get): return Matcher.ComparisonResult.match case (.p_useRelativeDates_set(let left),.p_useRelativeDates_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) + case (.p_lastUsedSocialAuth_get,.p_lastUsedSocialAuth_get): return Matcher.ComparisonResult.match + case (.p_lastUsedSocialAuth_set(let left),.p_lastUsedSocialAuth_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) default: return .none } } @@ -3217,6 +3228,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set(let newValue): return newValue.intValue case .p_useRelativeDates_get: return 0 case .p_useRelativeDates_set(let newValue): return newValue.intValue + case .p_lastUsedSocialAuth_get: return 0 + case .p_lastUsedSocialAuth_set(let newValue): return newValue.intValue } } func assertionName() -> String { @@ -3246,6 +3259,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set: return "[set] .resetAppSupportDirectoryUserData" case .p_useRelativeDates_get: return "[get] .useRelativeDates" case .p_useRelativeDates_set: return "[set] .useRelativeDates" + case .p_lastUsedSocialAuth_get: return "[get] .lastUsedSocialAuth" + case .p_lastUsedSocialAuth_set: return "[set] .lastUsedSocialAuth" } } } @@ -3294,6 +3309,9 @@ open class CoreStorageMock: CoreStorage, Mock { public static func useRelativeDates(getter defaultValue: Bool...) -> PropertyStub { return Given(method: .p_useRelativeDates_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) } + public static func lastUsedSocialAuth(getter defaultValue: String?...) -> PropertyStub { + return Given(method: .p_lastUsedSocialAuth_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) + } } @@ -3325,6 +3343,8 @@ open class CoreStorageMock: CoreStorage, Mock { public static func resetAppSupportDirectoryUserData(set newValue: Parameter) -> Verify { return Verify(method: .p_resetAppSupportDirectoryUserData_set(newValue)) } public static var useRelativeDates: Verify { return Verify(method: .p_useRelativeDates_get) } public static func useRelativeDates(set newValue: Parameter) -> Verify { return Verify(method: .p_useRelativeDates_set(newValue)) } + public static var lastUsedSocialAuth: Verify { return Verify(method: .p_lastUsedSocialAuth_get) } + public static func lastUsedSocialAuth(set newValue: Parameter) -> Verify { return Verify(method: .p_lastUsedSocialAuth_set(newValue)) } } public struct Perform { @@ -4739,10 +4759,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() { @@ -4824,7 +4844,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) @@ -4907,9 +4927,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 @@ -4995,7 +5016,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 @@ -5022,7 +5043,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:)" @@ -5063,7 +5084,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`))} @@ -5114,8 +5135,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/Documentation/CONFIGURATION_MANAGEMENT.md b/Documentation/CONFIGURATION_MANAGEMENT.md index b7db2e6d9..b8695e546 100644 --- a/Documentation/CONFIGURATION_MANAGEMENT.md +++ b/Documentation/CONFIGURATION_MANAGEMENT.md @@ -87,7 +87,7 @@ FIREBASE: MICROSOFT: ENABLED: true - APP_ID: "microsoftAppID" + CLIENT_ID: "microsoftAppID" ``` `shared.yaml`: diff --git a/OpenEdX/DI/ScreenAssembly.swift b/OpenEdX/DI/ScreenAssembly.swift index 876026351..683d64748 100644 --- a/OpenEdX/DI/ScreenAssembly.swift +++ b/OpenEdX/DI/ScreenAssembly.swift @@ -87,6 +87,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 ) } @@ -107,6 +108,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 ec2bbab5d..91efe18c0 100644 --- a/OpenEdX/Data/AppStorage.swift +++ b/OpenEdX/Data/AppStorage.swift @@ -275,6 +275,19 @@ public final class AppStorage: CoreStorage, ProfileStorage, WhatsNewStorage, Cou } } } + + 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 var lastLoginUsername: String? { get { @@ -382,4 +395,5 @@ public final class AppStorage: CoreStorage, ProfileStorage, WhatsNewStorage, Cou private let KEY_FIRST_CALENDAR_UPDATE = "firstCalendarUpdate" private let KEY_RESET_APP_SUPPORT_DIRECTORY_USER_DATA = "resetAppSupportDirectoryUserData" private let KEY_USE_RELATIVE_DATES = "useRelativeDates" + private let KEY_LAST_USED_SOCIAL_AUTH = "lastUsedSocialAuth" } diff --git a/OpenEdX/Router.swift b/OpenEdX/Router.swift index 326b2b8e1..a675d6218 100644 --- a/OpenEdX/Router.swift +++ b/OpenEdX/Router.swift @@ -64,17 +64,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 599b0581a..7dab55368 100644 --- a/OpenEdX/View/MainScreenViewModel.swift +++ b/OpenEdX/View/MainScreenViewModel.swift @@ -79,10 +79,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 123c0940a..54f9df0d8 100644 --- a/Profile/ProfileTests/ProfileMock.generated.swift +++ b/Profile/ProfileTests/ProfileMock.generated.swift @@ -581,10 +581,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) @@ -697,9 +697,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 @@ -779,7 +780,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 @@ -800,7 +801,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:)" @@ -835,7 +836,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`))} @@ -868,8 +869,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) @@ -3121,6 +3122,12 @@ open class CoreStorageMock: CoreStorage, Mock { } private var __p_useRelativeDates: (Bool)? + public var lastUsedSocialAuth: String? { + get { invocations.append(.p_lastUsedSocialAuth_get); return __p_lastUsedSocialAuth ?? optionalGivenGetterValue(.p_lastUsedSocialAuth_get, "CoreStorageMock - stub value for lastUsedSocialAuth was not defined") } + set { invocations.append(.p_lastUsedSocialAuth_set(.value(newValue))); __p_lastUsedSocialAuth = newValue } + } + private var __p_lastUsedSocialAuth: (String)? + @@ -3158,6 +3165,8 @@ open class CoreStorageMock: CoreStorage, Mock { case p_resetAppSupportDirectoryUserData_set(Parameter) case p_useRelativeDates_get case p_useRelativeDates_set(Parameter) + case p_lastUsedSocialAuth_get + case p_lastUsedSocialAuth_set(Parameter) static func compareParameters(lhs: MethodType, rhs: MethodType, matcher: Matcher) -> Matcher.ComparisonResult { switch (lhs, rhs) { @@ -3186,6 +3195,8 @@ open class CoreStorageMock: CoreStorage, Mock { case (.p_resetAppSupportDirectoryUserData_set(let left),.p_resetAppSupportDirectoryUserData_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) case (.p_useRelativeDates_get,.p_useRelativeDates_get): return Matcher.ComparisonResult.match case (.p_useRelativeDates_set(let left),.p_useRelativeDates_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) + case (.p_lastUsedSocialAuth_get,.p_lastUsedSocialAuth_get): return Matcher.ComparisonResult.match + case (.p_lastUsedSocialAuth_set(let left),.p_lastUsedSocialAuth_set(let right)): return Matcher.ComparisonResult([Matcher.ParameterComparisonResult(Parameter.compare(lhs: left, rhs: right, with: matcher), left, right, "newValue")]) default: return .none } } @@ -3217,6 +3228,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set(let newValue): return newValue.intValue case .p_useRelativeDates_get: return 0 case .p_useRelativeDates_set(let newValue): return newValue.intValue + case .p_lastUsedSocialAuth_get: return 0 + case .p_lastUsedSocialAuth_set(let newValue): return newValue.intValue } } func assertionName() -> String { @@ -3246,6 +3259,8 @@ open class CoreStorageMock: CoreStorage, Mock { case .p_resetAppSupportDirectoryUserData_set: return "[set] .resetAppSupportDirectoryUserData" case .p_useRelativeDates_get: return "[get] .useRelativeDates" case .p_useRelativeDates_set: return "[set] .useRelativeDates" + case .p_lastUsedSocialAuth_get: return "[get] .lastUsedSocialAuth" + case .p_lastUsedSocialAuth_set: return "[set] .lastUsedSocialAuth" } } } @@ -3294,6 +3309,9 @@ open class CoreStorageMock: CoreStorage, Mock { public static func useRelativeDates(getter defaultValue: Bool...) -> PropertyStub { return Given(method: .p_useRelativeDates_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) } + public static func lastUsedSocialAuth(getter defaultValue: String?...) -> PropertyStub { + return Given(method: .p_lastUsedSocialAuth_get, products: defaultValue.map({ StubProduct.return($0 as Any) })) + } } @@ -3325,6 +3343,8 @@ open class CoreStorageMock: CoreStorage, Mock { public static func resetAppSupportDirectoryUserData(set newValue: Parameter) -> Verify { return Verify(method: .p_resetAppSupportDirectoryUserData_set(newValue)) } public static var useRelativeDates: Verify { return Verify(method: .p_useRelativeDates_get) } public static func useRelativeDates(set newValue: Parameter) -> Verify { return Verify(method: .p_useRelativeDates_set(newValue)) } + public static var lastUsedSocialAuth: Verify { return Verify(method: .p_lastUsedSocialAuth_get) } + public static func lastUsedSocialAuth(set newValue: Parameter) -> Verify { return Verify(method: .p_lastUsedSocialAuth_set(newValue)) } } public struct Perform { @@ -5858,10 +5878,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() { @@ -5947,7 +5967,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) @@ -6017,9 +6037,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 @@ -6109,7 +6130,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 @@ -6140,7 +6161,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:)" @@ -6185,7 +6206,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`))} @@ -6248,8 +6269,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 1b0d20ef6..714c1dfdd 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 disabledButton = ColorAsset(name: "disabledButton") public static let disabledButtonText = ColorAsset(name: "disabledButtonText") diff --git a/Theme/Theme/Theme.swift b/Theme/Theme/Theme.swift index 359e2c8ef..e28fa78c1 100644 --- a/Theme/Theme/Theme.swift +++ b/Theme/Theme/Theme.swift @@ -82,6 +82,7 @@ public struct Theme: Sendable { nonisolated(unsafe) public private(set) static var courseProgressBG = ThemeAssets.courseProgressBG.swiftUIColor nonisolated(unsafe) public private(set) static var resumeButtonBG = ThemeAssets.resumeButtonBG.swiftUIColor nonisolated(unsafe) public private(set) static var resumeButtonText = ThemeAssets.resumeButtonText.swiftUIColor + nonisolated(unsafe) 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 9a6ec09ce..31c25b795 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) }) diff --git a/config_script/process_config.py b/config_script/process_config.py index 1fdea0270..d8e174818 100644 --- a/config_script/process_config.py +++ b/config_script/process_config.py @@ -240,7 +240,7 @@ def add_google_config(self, config, plist): def add_microsoft_config(self, config, plist): microsoft = config.get('MICROSOFT', {}) - key = microsoft.get('APP_ID') + key = microsoft.get('CLIENT_ID') if key: bundle_identifier = self.plist_manager.get_bundle_identifier()