Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBL-1233: Consolidate login and signup buttons when OAuth is enabled #1956

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a separate web PR + a follow-up to this PR once the strings are finished.

_ = 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 }
Copy link
Contributor Author

@amy-at-kickstarter amy-at-kickstarter Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perhaps a bit of a paranoid move, but since login is something you might do right after launch, I didn't want there to ever be a situation where the remote config reloads after the login screen has already been presented.

This way, this property is set when the view controller is initialized, and never changes.

}

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