Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Jan 21, 2021

For woocommerce/woocommerce-ios#3107 and woocommerce/woocommerce-ios#3429

Why

When launching the app in logged out state, we call WordPressAuthenticator.showLogin to show the login UI in both WPiOS and WCiOS apps. However, since iOS 14 we started seeing a delay presenting the login UI (similar WPiOS issue). From my testing, it seems to be due to loading the view controller from Login.storyboard in the authenticator pod which is not easy to change. Because the app window's root view controller is the tab bar UI, the uninitialized tab bar UI is shown briefly before the login UI is presented.

In order to solve the glitch in WCiOS, we are setting the login view controller to the app window's root view controller instead of calling WordPressAuthenticator.showLogin to present the login UI from a source view controller. Therefore, this PR moved the login UI creation to a separate public function so that the host app can decide how it is displayed (set to the app window's root view controller in WCiOS' case).

Changes

  • Added a function loginUI with the same logic from how a login view controller is created and configured from the pre-existing showLogin.

Testing

WPiOS

Please review/test wordpress-mobile/WordPress-iOS#15682 - I think we can merge it once it's approved so that we can also QA the authenticator change in case of regression

WCiOS

Please see the testing section in woocommerce/woocommerce-ios#3498

@diegoreymendez
Copy link
Contributor

This is something we've been discussing for WPiOS with @frosty as well. Pinging him to loop him in.

public class func showLogin(from presenter: UIViewController, animated: Bool, showCancel: Bool = false, restrictToWPCom: Bool = false, onLoginButtonTapped: (() -> Void)? = nil, onCompletion: (() -> Void)? = nil) {
defer {
trackOpenedLogin()
guard let loginViewController = loginUI(showCancel: showCancel, restrictToWPCom: restrictToWPCom, onLoginButtonTapped: onLoginButtonTapped) else {
Copy link
Contributor

Choose a reason for hiding this comment

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

So if I understand correctly, this is the method that WordPress would call to initialize the login flow, while WooCommerce would call loginUI?

If that's the case, would it make sense to make the names of both methods a bit more explicit, or rename in a way that the method name indicates that one method presents the login flow while the other leaves the responsibility of presenting the flow to the client app?

I'm curious about what others think though

Copy link
Contributor

@diegoreymendez diegoreymendez Jan 21, 2021

Choose a reason for hiding this comment

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

@ctarda - My personal opinion is that we'll probably want to follow suit in WPiOS soon (in showing the login UI as the root VC). There are several advantages in doing so.

With this in mind I'd say the naming isn't overly important as we'll eventually deprecate showLogin(...) entirely - the documentation of these methods should be enough for starters.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correction: we may never deprecate showLogin(...) as it is currently used in WPiOS to log in to additional sites (which means it wouldn't be shown as the root VC).

Still the naming showLogin(...) and loginUI(...) sounds good to me. The other only option I can think of is to use loginViewController(...) instead of loginUI(...) but I'm not sure that'd make a huge difference.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Contributor

@ctarda ctarda left a comment

Choose a reason for hiding this comment

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

Thanks for your feedback @diegoreymendez If you don't have any concerns about the naming, I'd say :shipit:

@jaclync
Copy link
Contributor Author

jaclync commented Jan 22, 2021

Thanks for the feedback César and Diego! I tested in WPiOS with this branch wordpress-mobile/WordPress-iOS#15682 and verified the login behavior is as before. Merging the PR now for code freeze next Monday!

@jaclync jaclync merged commit 0eef99d into develop Jan 22, 2021
@jaclync jaclync deleted the wcios-3107/login-ui branch January 22, 2021 01:49
jaclync added a commit that referenced this pull request Jan 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants