-
Notifications
You must be signed in to change notification settings - Fork 120
Implements Login Prologue #71
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bcedb30
New Prologue Asset
jleandroperez 284bf57
AppDelegate: Customizing FancyButton's Appearance
jleandroperez 50d3008
AuthenticationManager: Renaming Auth public method
jleandroperez 204573f
Styles: New Button Style
jleandroperez 06310de
Implements UIFont+Helpers
jleandroperez 6c9a124
Implements LoginPrologueViewController
jleandroperez f39b978
Style: Fixing Hound warning
jleandroperez 6cf864a
Adding Assets
jleandroperez c8707d7
UIColor+Woo: New Extension
jleandroperez 8582160
UIImage+Woo: New Extension
jleandroperez 5e0441d
LoginPrologueViewController: Adding new fields
jleandroperez fef9666
Implements WooConstants
jleandroperez de4b5e8
UIImage+Wo: Removes extra space
jleandroperez 596ce0c
LoginPrologueViewController: Fixing UI Glitch
jleandroperez 8830c0d
LoginPrologueViewController: Adding shadow
jleandroperez b2a7316
Fixing LaunchScreen
jleandroperez 154571d
Moving termsOfServiceUrl to WooConstants
jleandroperez 93a6b6c
LoginPrologueViewController: Updates opacity
jleandroperez 08dd821
Merge remote-tracking branch 'origin/develop' into issue/22-woo-prologue
jleandroperez e320a19
Code Review: Fixing few typos
jleandroperez f1ce067
Implements SafariViewController
jleandroperez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
WooCommerce/Classes/Authentication/Prologue/LoginPrologueViewController.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| import Foundation | ||
| import UIKit | ||
| import SafariServices | ||
| import WordPressAuthenticator | ||
|
|
||
|
|
||
| /// Displays the WooCommerce Prologue UI. | ||
| /// | ||
| class LoginPrologueViewController: UIViewController { | ||
|
|
||
| /// White-Background View, to be placed surrounding the bottom area. | ||
| /// | ||
| @IBOutlet var backgroundView: UIView! | ||
|
|
||
| /// Label to be displayed at the top of the Prologue. | ||
| /// | ||
| @IBOutlet var upperLabel: UILabel! | ||
|
|
||
| /// Disclaimer Label | ||
| /// | ||
| @IBOutlet var disclaimerTextView: UITextView! | ||
|
|
||
| /// Jetpack Logo ImageVIew | ||
| /// | ||
| @IBOutlet var jetpackImageView: UIImageView! | ||
|
|
||
| /// Default Action Button. | ||
| /// | ||
| @IBOutlet var loginButton: UIButton! | ||
|
|
||
|
|
||
| // MARK: - Overridden Properties | ||
|
|
||
| override var supportedInterfaceOrientations: UIInterfaceOrientationMask { | ||
| return .portrait | ||
| } | ||
|
|
||
|
|
||
| // MARK: - Overridden Methods | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| setupMainView() | ||
| setupBackgroundView() | ||
| setupJetpackImage() | ||
| setupDisclaimerLabel() | ||
| setupUpperLabel() | ||
| setupLoginButton() | ||
| } | ||
|
|
||
| override func viewWillAppear(_ animated: Bool) { | ||
| super.viewWillAppear(animated) | ||
| navigationController?.setNavigationBarHidden(true, animated: animated) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // MARK: - Initialization Methods | ||
| // | ||
| private extension LoginPrologueViewController { | ||
|
|
||
| func setupMainView() { | ||
| view.backgroundColor = StyleManager.wooCommerceBrandColor | ||
| } | ||
|
|
||
| func setupBackgroundView() { | ||
| backgroundView.layer.masksToBounds = false | ||
| backgroundView.layer.shadowOpacity = 0.2 | ||
| } | ||
|
|
||
| func setupUpperLabel() { | ||
| upperLabel.text = NSLocalizedString("Check your WooCommerce store on the go, fulfill your orders and get notifications of new sales.", comment: "Login Prologue Legend") | ||
| upperLabel.font = UIFont.font(forStyle: .subheadline, weight: .bold) | ||
| upperLabel.textColor = .white | ||
| } | ||
|
|
||
| func setupJetpackImage() { | ||
| jetpackImageView.image = UIImage.jetpackLogoImage.imageWithTintColor(.jetpackGreen) | ||
| } | ||
|
|
||
| func setupDisclaimerLabel() { | ||
| disclaimerTextView.attributedText = disclaimerAttributedText | ||
| disclaimerTextView.textContainerInset = .zero | ||
| } | ||
|
|
||
| func setupLoginButton() { | ||
| let title = NSLocalizedString("Log in with Jetpack", comment: "Authentication Login Button") | ||
| loginButton.setTitle(title, for: .normal) | ||
| loginButton.backgroundColor = .clear | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // MARK: - UITextViewDeletgate Conformance | ||
| // | ||
| extension LoginPrologueViewController: UITextViewDelegate { | ||
|
|
||
| func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { | ||
| displaySafariViewController(at: URL) | ||
| return false | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // MARK: - Action Handlers | ||
| // | ||
| extension LoginPrologueViewController { | ||
|
|
||
| /// Opens SafariViewController at the specified URL. | ||
| /// | ||
| func displaySafariViewController(at url: URL) { | ||
| let safariViewController = SafariViewController(url: url) | ||
| safariViewController.modalPresentationStyle = .pageSheet | ||
| present(safariViewController, animated: true, completion: nil) | ||
| } | ||
|
|
||
| /// Proceeds with the Login Flow. | ||
| /// | ||
| @IBAction func loginWasPressed() { | ||
| let loginViewController = WordPressAuthenticator.signinForWordPress() | ||
| loginViewController.restrictToWPCom = true | ||
| loginViewController.offerSignupOption = false | ||
|
|
||
| navigationController?.pushViewController(loginViewController, animated: true) | ||
| navigationController?.setNavigationBarHidden(false, animated: true) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // MARK: - Private Methods | ||
| // | ||
| private extension LoginPrologueViewController { | ||
|
|
||
| /// Returns the Disclaimer Attributed Text (which contains a link to the Jetpack Setup URL). | ||
| /// | ||
| var disclaimerAttributedText: NSAttributedString { | ||
| let disclaimerText = NSLocalizedString("This app requires Jetpack to be able to connect to your WooCommerce Store.\nFor configuration instructions, ", comment: "Login Disclaimer Text") | ||
| let disclaimerAttributes: [NSAttributedStringKey: Any] = [ | ||
| .font: UIFont.font(forStyle: .caption1, weight: .thin), | ||
| .foregroundColor: UIColor.black | ||
| ] | ||
|
|
||
| let readText = NSLocalizedString("read here.", comment: "Login Disclaimer Linked Text") | ||
| var readAttributes = disclaimerAttributes | ||
| readAttributes[.link] = URL(string: WooConstants.jetpackSetupUrl) | ||
|
|
||
| let readAttrText = NSMutableAttributedString(string: readText, attributes: readAttributes) | ||
| let disclaimerAttrText = NSMutableAttributedString(string: disclaimerText, attributes: disclaimerAttributes) | ||
| disclaimerAttrText.append(readAttrText) | ||
|
|
||
| return disclaimerAttrText | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of our AppDelegate settings, the Safari VC gets a white status bar. To fix it, add this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for bringing this up!! i've, instead, added
SafariViewController(SFSafariViewController subclass), that would give us extra flexibility (just a few LOC's).