diff --git a/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift b/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift index 44d622424b..d943f3f07f 100644 --- a/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift +++ b/Kickstarter-iOS/Features/LoginTout/Controller/LoginToutViewController.swift @@ -138,11 +138,14 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC } |> UILabel.lens.text %~ { _ in Strings.Get_notified_when_your_friends_back_and_launch_projects() } - _ = self.loginButton - |> greyButtonStyle - |> UIButton.lens.title(for: .normal) %~ { _ in - Strings.login_tout_back_intent_traditional_login_button() - } + if self.viewModel.outputs.loginWithOAuthEnabled { + // TODO: Add and translate a new version of this string for this page. + _ = self.loginButton |> greenButtonStyle + self.loginButton.setTitle(Strings.discovery_onboarding_buttons_signup_or_login(), for: .normal) + } else { + _ = self.loginButton |> greyButtonStyle + self.loginButton.setTitle(Strings.login_tout_back_intent_traditional_login_button(), for: .normal) + } _ = self.loginContextStackView |> UIStackView.lens.spacing .~ Styles.gridHalf(1) @@ -353,8 +356,12 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC _ = ([self.appleLoginButton, self.fbLoginButton, self.getNotifiedLabel], self.fbLoginStackView) |> ksr_addArrangedSubviewsToStackView() - _ = ([self.signupButton, self.loginButton], self.emailLoginStackView) - |> ksr_addArrangedSubviewsToStackView() + if self.viewModel.outputs.loginWithOAuthEnabled { + self.emailLoginStackView.addArrangedSubview(self.loginButton) + } else { + self.emailLoginStackView.addArrangedSubview(self.signupButton) + self.emailLoginStackView.addArrangedSubview(self.loginButton) + } } private func setupConstraints() { @@ -402,7 +409,7 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC } fileprivate func pushLoginViewController() { - if featureLoginWithOAuthEnabled(), let session = createAuthorizationSession() { + if self.viewModel.outputs.loginWithOAuthEnabled, let session = createAuthorizationSession() { session.presentationContextProvider = self session.start() } else { diff --git a/Library/ViewModels/LoginToutViewModel.swift b/Library/ViewModels/LoginToutViewModel.swift index 654001b9d8..0bcebcfebc 100644 --- a/Library/ViewModels/LoginToutViewModel.swift +++ b/Library/ViewModels/LoginToutViewModel.swift @@ -97,6 +97,10 @@ public protocol LoginToutViewModelOutputs { /// Emits an access token to show 2fa view when Facebook login fails with tfaRequired error var startTwoFactorChallenge: Signal { get } + + /// True if the feature flag for OAuth login is true. + /// Note that this is not a signal, because we don't want it to ever change after the screen is loaded. + var loginWithOAuthEnabled: Bool { get } } public protocol LoginToutViewModelType { @@ -265,6 +269,7 @@ public final class LoginToutViewModel: LoginToutViewModelType, LoginToutViewMode self.logIntoEnvironmentWithApple = logIntoEnvironmentWithApple.signal self.logIntoEnvironmentWithFacebook = logIntoEnvironmentWithFacebook.signal + self.loginWithOAuthEnabled = featureLoginWithOAuthEnabled() } public var inputs: LoginToutViewModelInputs { return self } @@ -354,6 +359,7 @@ public final class LoginToutViewModel: LoginToutViewModelType, LoginToutViewMode public let startTwoFactorChallenge: Signal public let showAppleErrorAlert: Signal public let showFacebookErrorAlert: Signal + public let loginWithOAuthEnabled: Bool } private func statusString(_ forStatus: LoginIntent) -> String {