Skip to content

Commit

Permalink
MBL-1233: Consolidate login and signup buttons when OAuth is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-at-kickstarter committed Feb 26, 2024
1 parent 523660f commit 9f6e16a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions Library/ViewModels/LoginToutViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Never> { 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 {
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -354,6 +359,7 @@ public final class LoginToutViewModel: LoginToutViewModelType, LoginToutViewMode
public let startTwoFactorChallenge: Signal<String, Never>
public let showAppleErrorAlert: Signal<String, Never>
public let showFacebookErrorAlert: Signal<AlertError, Never>
public let loginWithOAuthEnabled: Bool
}

private func statusString(_ forStatus: LoginIntent) -> String {
Expand Down

0 comments on commit 9f6e16a

Please sign in to comment.