Skip to content

Commit

Permalink
[MBL-1462] Clean up OAuth flag (#2115)
Browse files Browse the repository at this point in the history
* Delete oauth flag

* Delete login and signup buttons

* Delete signup vc

* Delete unused functions
  • Loading branch information
ifosli authored Aug 7, 2024
1 parent 30ecfd8 commit 1a6acba
Show file tree
Hide file tree
Showing 32 changed files with 12 additions and 1,243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
private lazy var fbLoginStackView = { UIStackView(frame: .zero) }()
private lazy var getNotifiedLabel = { UILabel(frame: .zero) }()
private let helpViewModel = HelpViewModel()
private lazy var loginButton = { UIButton(type: .custom)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var signupOrLoginWithOAuthButton = { UIButton(type: .custom)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
Expand All @@ -53,9 +50,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC

private lazy var separatorView: UIView = { UIView(frame: .zero) }()
private var sessionStartedObserver: Any?
private lazy var signupButton = { UIButton(type: .custom)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()

private let viewModel: LoginToutViewModelType = LoginToutViewModel()

Expand Down Expand Up @@ -142,9 +136,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
}
|> UILabel.lens.text %~ { _ in Strings.Get_notified_when_your_friends_back_and_launch_projects() }

_ = self.loginButton |> greyButtonStyle
self.loginButton.setTitle(Strings.login_tout_back_intent_traditional_login_button(), for: .normal)

_ = self.signupOrLoginWithOAuthButton |> greenButtonStyle
self.signupOrLoginWithOAuthButton
.setTitle(Strings.login_tout_generic_intent_traditional_signup_or_login_button(), for: .normal)
Expand All @@ -169,28 +160,13 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
_ = self.separatorView
|> separatorViewStyle

_ = self.signupButton
|> signupWithEmailButtonStyle

_ = [self.loginContextStackView, self.fbLoginStackView, self.emailLoginStackView]
||> baseStackViewStyle
}

// MARK: - View Model

public override func bindViewModel() {
self.viewModel.outputs.startLogin
.observeForControllerAction()
.observeValues { [weak self] _ in
self?.pushLoginViewController()
}

self.viewModel.outputs.startSignup
.observeForControllerAction()
.observeValues { [weak self] _ in
self?.pushSignupViewController()
}

self.viewModel.outputs.startOAuthSignupOrLogin
.observeForControllerAction()
.observeValues { [weak self] _ in
Expand Down Expand Up @@ -283,10 +259,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
self.contextLabel.rac.text = self.viewModel.outputs.logInContextText
self.bringCreativeProjectsToLifeLabel.rac.hidden = self.viewModel.outputs.headlineLabelHidden

self.loginButton.rac.hidden = self.viewModel.outputs.showLoginWithOAuth
self.signupButton.rac.hidden = self.viewModel.outputs.showLoginWithOAuth
self.signupOrLoginWithOAuthButton.rac.hidden = self.viewModel.outputs.showLoginWithOAuth.signal.negate()

self.viewModel.outputs.headlineLabelHidden
.observeForUI()
.observeValues { [weak self] isHidden in
Expand Down Expand Up @@ -347,17 +319,13 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
|> ksr_addArrangedSubviewsToStackView()

self.emailLoginStackView.addArrangedSubview(self.signupOrLoginWithOAuthButton)
self.emailLoginStackView.addArrangedSubview(self.signupButton)
self.emailLoginStackView.addArrangedSubview(self.loginButton)
}

private func setupConstraints() {
NSLayoutConstraint.activate([
self.separatorView.heightAnchor.constraint(equalToConstant: 1),
self.rootStackView.widthAnchor.constraint(equalTo: self.view.widthAnchor),
self.fbLoginButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Styles.minTouchSize.height),
self.loginButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Styles.minTouchSize.height),
self.signupButton.heightAnchor.constraint(greaterThanOrEqualToConstant: Styles.minTouchSize.height)
])

NSLayoutConstraint.activate([
Expand All @@ -375,8 +343,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
self, action: #selector(self.facebookLoginButtonPressed(_:)),
for: .touchUpInside
)
self.loginButton.addTarget(self, action: #selector(self.loginButtonPressed(_:)), for: .touchUpInside)
self.signupButton.addTarget(self, action: #selector(self.signupButtonPressed), for: .touchUpInside)
self.signupOrLoginWithOAuthButton
.addTarget(self, action: #selector(self.signupOrLoginWithOAuthButtonPressed), for: .touchUpInside)
}
Expand All @@ -397,13 +363,8 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
self.navigationItem.backBarButtonItem = UIBarButtonItem.back(nil, selector: nil)
}

fileprivate func pushLoginViewController() {
self.navigationController?.pushViewController(LoginViewController.instantiate(), animated: true)
self.navigationItem.backBarButtonItem = UIBarButtonItem.back(nil, selector: nil)
}

fileprivate func pushOAuthFlow() {
guard featureLoginWithOAuthEnabled(), let session = createAuthorizationSession() else {
guard let session = createAuthorizationSession() else {
return
}

Expand Down Expand Up @@ -447,11 +408,6 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
self.navigationItem.backBarButtonItem = UIBarButtonItem.back(nil, selector: nil)
}

fileprivate func pushSignupViewController() {
self.navigationController?.pushViewController(SignupViewController.instantiate(), animated: true)
self.navigationItem.backBarButtonItem = UIBarButtonItem.back(nil, selector: nil)
}

private func pushFacebookResetPasswordViewController() {
let vc = FacebookResetPasswordViewController.instantiate()
self.navigationController?.pushViewController(vc, animated: true)
Expand Down Expand Up @@ -521,18 +477,10 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
self.helpViewModel.inputs.showHelpSheetButtonTapped()
}

@objc private func loginButtonPressed(_: UIButton) {
self.viewModel.inputs.loginButtonPressed()
}

@objc private func facebookLoginButtonPressed(_: UIButton) {
self.viewModel.inputs.facebookLoginButtonPressed()
}

@objc private func signupButtonPressed() {
self.viewModel.inputs.signupButtonPressed()
}

@objc private func signupOrLoginWithOAuthButtonPressed() {
self.viewModel.inputs.signupOrLoginWithOAuthButtonPressed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@ internal final class LoginToutViewControllerTests: TestCase {
}

func testLoginToutView() {
let mockConfigClient = MockRemoteConfigClient()
mockConfigClient.features = [
RemoteConfigFeature.loginWithOAuthEnabled.rawValue: false
]

let devices = [Device.phone4_7inch, Device.phone5_8inch, Device.pad]
let intents = [LoginIntent.generic, .starProject, .messageCreator, .backProject]

orthogonalCombos(Language.allLanguages, devices, intents).forEach { language, device, intent in
withEnvironment(language: language, remoteConfigClient: mockConfigClient) {
withEnvironment(language: language) {
let controller = LoginToutViewController.configuredWith(loginIntent: intent)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1a6acba

Please sign in to comment.