From 7009d36ab6637a3eb7e8604011d3ed2681850691 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:13:51 +0530 Subject: [PATCH 01/12] Bring `UITableView+HeaderFooterHelpers` from WooCommerce iOS repo for resizing table view header and footer views. --- .../project.pbxproj | 4 ++ .../UITableView+HeaderFooterHelpers.swift | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index 16c24aba6..abbd51063 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -166,6 +166,7 @@ D881A311256B5B4700FE5605 /* NavigateToEnterSite.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A310256B5B4700FE5605 /* NavigateToEnterSite.swift */; }; D881A315256B5B5800FE5605 /* NavigateToEnterAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A314256B5B5800FE5605 /* NavigateToEnterAccount.swift */; }; E8AF6B9EF50902F2117DFAF9 /* Pods_WordPressAuthenticatorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */; }; + EE758BFF28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE758BFE28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift */; }; F11448EC258B827B0048203D /* URL+JetpackConnect.swift in Sources */ = {isa = PBXBuildFile; fileRef = F11448EB258B827B0048203D /* URL+JetpackConnect.swift */; }; F12F9FB424D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */; }; F12F9FB824D8A7FC00771BCE /* AnalyticsTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */; }; @@ -378,6 +379,7 @@ D881A310256B5B4700FE5605 /* NavigateToEnterSite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateToEnterSite.swift; sourceTree = ""; }; D881A314256B5B5800FE5605 /* NavigateToEnterAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateToEnterAccount.swift; sourceTree = ""; }; E9414A95E29F3297555AC92B /* Pods-WordPressAuthenticator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.debug.xcconfig"; sourceTree = ""; }; + EE758BFE28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITableView+HeaderFooterHelpers.swift"; sourceTree = ""; }; F11448EB258B827B0048203D /* URL+JetpackConnect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+JetpackConnect.swift"; sourceTree = ""; }; F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticatorAnalyticsTracker.swift; sourceTree = ""; }; F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsTrackerTests.swift; sourceTree = ""; }; @@ -674,6 +676,7 @@ B560909B208A4EB000399AE4 /* Extensions */ = { isa = PBXGroup; children = ( + EE758BFE28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift */, B56090ED208A527000399AE4 /* FancyAlertViewController+LoginError.swift */, B56090EE208A527000399AE4 /* String+Underline.swift */, B56090EC208A527000399AE4 /* WPStyleGuide+Login.swift */, @@ -1253,6 +1256,7 @@ B560913D208A563800399AE4 /* LoginProloguePageViewController.swift in Sources */, B5609117208A555600399AE4 /* SearchTableViewCell.swift in Sources */, BA70352424F70C9F00B3AA1C /* ModalViewControllerPresenting.swift in Sources */, + EE758BFF28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift in Sources */, B56090C9208A4F5400399AE4 /* NUXLinkMailViewController.swift in Sources */, B56090F1208A527000399AE4 /* String+Underline.swift in Sources */, B56052A42090B2ED001B91FD /* CircularImageView.swift in Sources */, diff --git a/WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift b/WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift new file mode 100644 index 000000000..b23953d90 --- /dev/null +++ b/WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift @@ -0,0 +1,54 @@ +import UIKit + +extension UITableView { + /// Called in view controller's `viewDidLayoutSubviews`. If table view has a footer view, calculates the new height. + /// If new height is different from current height, updates the footer view with the new height and reassigns the table footer view. + /// Note: make sure the top-level footer view (`tableView.tableFooterView`) is frame based as a container of the Auto Layout based subview. + func updateFooterHeight() { + if let footerView = tableFooterView { + let targetSize = CGSize(width: footerView.frame.width, height: 0) + let newSize = footerView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow) + let newHeight = newSize.height + var currentFrame = footerView.frame + if newHeight != currentFrame.size.height { + currentFrame.size.height = newHeight + footerView.frame = currentFrame + tableFooterView = footerView + } + } + } + + /// Called in view controller's `viewDidLayoutSubviews`. If table view has a header view, calculates the new height. + /// If new height is different from current height, updates the header view with the new height and reassigns the table header view. + /// Note: make sure the top-level header view (`tableView.tableHeaderView`) is frame based as a container of the Auto Layout based subview. + func updateHeaderHeight() { + if let headerView = tableHeaderView { + let targetSize = CGSize(width: headerView.frame.width, height: 0) + let newSize = headerView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow) + let newHeight = newSize.height + var currentFrame = headerView.frame + if newHeight != currentFrame.size.height { + currentFrame.size.height = newHeight + headerView.frame = currentFrame + tableHeaderView = headerView + } + } + } + + /// Removes the separator of the last cell. + /// + func removeLastCellSeparator() { + tableFooterView = UIView(frame: CGRect(origin: .zero, + size: CGSize(width: frame.width, height: 1))) + } + + /// Change `self.tableFooterView` to an empty view in order to hide the `UITableView`'s + /// default row placeholders (with separators). + /// + /// This intentionally have an absurdingly long method name because we want to be clear that + /// we are replacing the `tableFooterView` property. + /// + func applyFooterViewForHidingExtraRowPlaceholders() { + tableFooterView = UIView(frame: .zero) + } +} From fe71c89ffc1cef47071a11dbcc2e021d5a07dca5 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:14:41 +0530 Subject: [PATCH 02/12] Add analytics event to cover what is WordPress.com link tap event. --- .../Analytics/AuthenticatorAnalyticsTracker.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift b/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift index 07aebbfdb..3ce0131fd 100644 --- a/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift +++ b/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift @@ -142,6 +142,10 @@ public class AuthenticatorAnalyticsTracker { /// case continueWithWordPressCom = "continue_with_wordpress_com" + /// Tracked when the user clicks “What is WordPress.com?" button on the WordPress.com flow screen + /// + case whatIsWpCom = "what_is_wordpress_com" + /// Tracked when the user clicks “Login with site address” on the Prologue screen /// case loginWithSiteAddress = "login_with_site_address" From e225ddea67a675929940e3272c16845d10de45ff Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:15:33 +0530 Subject: [PATCH 03/12] Add `whatIsWPComURL` string to hold "What is WordPress.com" webpage URL. --- .../WordPressAuthenticatorConfiguration.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift index c57ad7c5b..851452470 100644 --- a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift @@ -29,6 +29,12 @@ public struct WordPressAuthenticatorConfiguration { /// let wpcomAPIBaseURL: String + /// The URL of a webpage which has details about What is WordPress.com?. + /// + /// Displayed in the WordPress.com login page. + /// + let whatIsWPComURL: String? + /// GoogleLogin Client ID /// let googleLoginClientId: String @@ -97,6 +103,7 @@ public struct WordPressAuthenticatorConfiguration { wpcomTermsOfServiceURL: String, wpcomBaseURL: String = WordPressComOAuthClient.WordPressComOAuthDefaultBaseUrl, wpcomAPIBaseURL: String = WordPressComOAuthClient.WordPressComOAuthDefaultApiBaseUrl, + whatIsWPComURL: String? = nil, googleLoginClientId: String, googleLoginServerClientId: String, googleLoginScheme: String, @@ -116,6 +123,7 @@ public struct WordPressAuthenticatorConfiguration { self.wpcomTermsOfServiceURL = wpcomTermsOfServiceURL self.wpcomBaseURL = wpcomBaseURL self.wpcomAPIBaseURL = wpcomAPIBaseURL + self.whatIsWPComURL = whatIsWPComURL self.googleLoginClientId = googleLoginClientId self.googleLoginServerClientId = googleLoginServerClientId self.googleLoginScheme = googleLoginScheme From 7c08bdfd48a25abc963759888903becf38f11001 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:16:25 +0530 Subject: [PATCH 04/12] Add `whatIsWPComLinkTitle` to hold the title for "What is WordPress.com" link. --- .../Authenticator/WordPressAuthenticatorDisplayStrings.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDisplayStrings.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDisplayStrings.swift index bce0c0504..1a4c38d95 100644 --- a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDisplayStrings.swift +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorDisplayStrings.swift @@ -45,6 +45,7 @@ public struct WordPressAuthenticatorDisplayStrings { public let textCodeButtonTitle: String public let loginTermsOfService: String public let signupTermsOfService: String + public let whatIsWPComLinkTitle: String /// Placeholder text for textfields. /// @@ -83,6 +84,7 @@ public struct WordPressAuthenticatorDisplayStrings { textCodeButtonTitle: String = defaultStrings.textCodeButtonTitle, loginTermsOfService: String = defaultStrings.loginTermsOfService, signupTermsOfService: String = defaultStrings.signupTermsOfService, + whatIsWPComLinkTitle: String = defaultStrings.whatIsWPComLinkTitle, getStartedTitle: String = defaultStrings.getStartedTitle, logInTitle: String = defaultStrings.logInTitle, signUpTitle: String = defaultStrings.signUpTitle, @@ -119,6 +121,7 @@ public struct WordPressAuthenticatorDisplayStrings { self.textCodeButtonTitle = textCodeButtonTitle self.loginTermsOfService = loginTermsOfService self.signupTermsOfService = signupTermsOfService + self.whatIsWPComLinkTitle = whatIsWPComLinkTitle self.getStartedTitle = getStartedTitle self.logInTitle = logInTitle self.signUpTitle = signUpTitle @@ -183,6 +186,8 @@ public extension WordPressAuthenticatorDisplayStrings { comment: "The button's title text to send a 2FA code via SMS text message."), loginTermsOfService: NSLocalizedString("By continuing, you agree to our _Terms of Service_.", comment: "Legal disclaimer for logging in. The underscores _..._ denote underline."), signupTermsOfService: NSLocalizedString("If you continue with Apple or Google and don't already have a WordPress.com account, you are creating an account and you agree to our _Terms of Service_.", comment: "Legal disclaimer for signing up. The underscores _..._ denote underline."), + whatIsWPComLinkTitle: NSLocalizedString("_What is WordPress.com?_", + comment: "Navigates to page with details about What is WordPress.com. The underscores _..._ denote underline."), getStartedTitle: NSLocalizedString("Get Started", comment: "View title for initial auth views."), logInTitle: NSLocalizedString("Log In", From 5b59f4f0767d38c91fe61583f211e7c062ab32b5 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:16:57 +0530 Subject: [PATCH 05/12] Add helper method for creating for "What is WordPress.com" link button. --- .../Extensions/WPStyleGuide+Login.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift b/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift index 8fec50dd5..807e985ea 100644 --- a/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift +++ b/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift @@ -216,6 +216,26 @@ extension WPStyleGuide { return textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font, alignment: .center) } + /// Creates a button to open a webpage with details about What is WordPress.com? + /// + /// - Returns: A properly styled UIButton + /// + class func whatIsWPComButton() -> UIButton { + let unifiedStyle = WordPressAuthenticator.shared.unifiedStyle + let originalStyle = WordPressAuthenticator.shared.style + let baseString = WordPressAuthenticator.shared.displayStrings.whatIsWPComLinkTitle + let textColor = unifiedStyle?.textSubtleColor ?? originalStyle.subheadlineColor + let linkColor = unifiedStyle?.textButtonColor ?? originalStyle.textButtonColor + + let attrStrNormal = baseString.underlined(color: textColor, underlineColor: linkColor) + let attrStrHighlight = baseString.underlined(color: textColor, underlineColor: linkColor) + let font = WPStyleGuide.mediumWeightFont(forStyle: .footnote) + + let button = textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font, alignment: .center, forUnified: true) + button.titleLabel?.textAlignment = .center + return button + } + /// Creates a button to open our T&C. /// Specifically, the Sign Up verbiage on the Get Started view. /// - Returns: A properly styled UIButton From 6fdbbddeadca605b27780c305349356aca9f95de Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:29:21 +0530 Subject: [PATCH 06/12] Use stack view for adding `Continue` button and stop hardcoding the height. --- .../GetStartedViewController.swift | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index 85a417f23..1ecb5e84a 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -27,9 +27,13 @@ class GetStartedViewController: LoginViewController { private var shouldChangeVoiceOverFocus: Bool = false // Submit button displayed in the table footer. - private let continueButton: NUXButton = { + private lazy var continueButton: NUXButton = { let button = NUXButton() + button.translatesAutoresizingMaskIntoConstraints = false button.isPrimary = true + button.isEnabled = false + button.addTarget(self, action: #selector(handleSubmitButtonTapped(_:)), for: .touchUpInside) + button.accessibilityIdentifier = "Get Started Email Continue Button" let title = WordPressAuthenticator.shared.displayStrings.continueButtonTitle button.setTitle(title, for: .normal) @@ -53,7 +57,7 @@ class GetStartedViewController: LoginViewController { setupTable() registerTableViewCells() loadRows() - setupContinueButton() + setupTableFooterView() configureDivider() configureSocialButtons() } @@ -160,15 +164,18 @@ private extension GetStartedViewController { setTableViewMargins(forWidth: view.frame.width) } - func setupContinueButton() { - let tableFooter = UIView(frame: Constants.footerFrame) - tableFooter.addSubview(continueButton) - tableFooter.pinSubviewToSafeArea(continueButton, insets: Constants.footerButtonInsets) - continueButton.translatesAutoresizingMaskIntoConstraints = false - continueButton.isEnabled = false - continueButton.addTarget(self, action: #selector(handleSubmitButtonTapped(_:)), for: .touchUpInside) - continueButton.accessibilityIdentifier = "Get Started Email Continue Button" - tableView.tableFooterView = tableFooter + func setupTableFooterView() { + let stackView = UIStackView() + stackView.axis = .vertical + stackView.alignment = .fill + stackView.spacing = Constants.FooterStackView.spacing + stackView.layoutMargins = Constants.FooterStackView.layoutMargins + stackView.isLayoutMarginsRelativeArrangement = true + + stackView.addArrangedSubview(continueButton) + + tableView.tableFooterView = stackView + tableView.updateFooterHeight() } /// Style the "OR" divider. @@ -318,8 +325,10 @@ private extension GetStartedViewController { } enum Constants { - static let footerFrame = CGRect(x: 0, y: 0, width: 0, height: 44) - static let footerButtonInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) + enum FooterStackView { + static let spacing = 16.0 + static let layoutMargins = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) + } } } From 1358cfcc468cef8da129d3877294119066678018 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 17:33:59 +0530 Subject: [PATCH 07/12] Add "What is WordPress.com" button. --- .../GetStartedViewController.swift | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index 1ecb5e84a..cdb76b93f 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -174,6 +174,18 @@ private extension GetStartedViewController { stackView.addArrangedSubview(continueButton) + if WordPressAuthenticator.shared.configuration.whatIsWPComURL != nil { + let stackViewWithCenterAlignment = UIStackView() + stackViewWithCenterAlignment.axis = .vertical + stackViewWithCenterAlignment.alignment = .center + + let button = WPStyleGuide.whatIsWPComButton() + button.addTarget(self, action: #selector(whatIsWPComButtonTapped(_:)), for: .touchUpInside) + stackViewWithCenterAlignment.addArrangedSubview(button) + + stackView.addArrangedSubview(stackViewWithCenterAlignment) + } + tableView.tableFooterView = stackView tableView.updateFooterHeight() } @@ -197,6 +209,17 @@ private extension GetStartedViewController { validateForm() } + // MARK: - What is WordPress.com Button Action + + @IBAction func whatIsWPComButtonTapped(_ sender: UIButton) { + tracker.track(click: .whatIsWpCom) + guard let whatIsWPCom = WordPressAuthenticator.shared.configuration.whatIsWPComURL, + let url = URL(string: whatIsWPCom) else { + return + } + UIApplication.shared.open(url) + } + // MARK: - Hidden Password Field Action @IBAction func handlePasswordFieldDidChange(_ sender: UITextField) { From fade30c6d772c482353c44809601019196db12eb Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 19:30:22 +0530 Subject: [PATCH 08/12] Bumping beta version to `2.0.1-beta.1` --- WordPressAuthenticator.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index 53b8bae34..759b09ca5 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = 'WordPressAuthenticator' - s.version = '2.0.0' + s.version = '2.0.1-beta.1' s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.' s.description = <<-DESC From f1f7a2ea0d7709652999a03b4801ec5fbc97f9d8 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Tue, 5 Jul 2022 20:10:38 +0530 Subject: [PATCH 09/12] Update footer height on layout subviews call. --- .../View Related/Get Started/GetStartedViewController.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index cdb76b93f..57463a68c 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -91,6 +91,11 @@ class GetStartedViewController: LoginViewController { hiddenPasswordField?.isAccessibilityElement = false } + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + tableView.updateFooterHeight() + } + // MARK: - Overrides override func styleBackground() { From 36ded4aad16ed4ce3c3b6f56e5a60098d9258935 Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Wed, 6 Jul 2022 11:47:24 +0530 Subject: [PATCH 10/12] Mention that the button will be displayed if the value is `nil`. --- .../Authenticator/WordPressAuthenticatorConfiguration.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift index 851452470..48933f9d5 100644 --- a/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift +++ b/WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift @@ -31,7 +31,7 @@ public struct WordPressAuthenticatorConfiguration { /// The URL of a webpage which has details about What is WordPress.com?. /// - /// Displayed in the WordPress.com login page. + /// Displayed in the WordPress.com login page. The button/link will not be displayed if this value is nil. /// let whatIsWPComURL: String? From 4b360454d253c1789462e1d1f606fce054d668ed Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Wed, 6 Jul 2022 11:52:00 +0530 Subject: [PATCH 11/12] Add only `updateFooterHeight` method to `UITableView+Helpers` and remove other unused methods. --- .../project.pbxproj | 8 +-- .../UITableView+HeaderFooterHelpers.swift | 54 ------------------- .../Extensions/UITableView+Helpers.swift | 20 +++++++ 3 files changed, 24 insertions(+), 58 deletions(-) delete mode 100644 WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift create mode 100644 WordPressAuthenticator/Extensions/UITableView+Helpers.swift diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index abbd51063..e22e09888 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -166,7 +166,7 @@ D881A311256B5B4700FE5605 /* NavigateToEnterSite.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A310256B5B4700FE5605 /* NavigateToEnterSite.swift */; }; D881A315256B5B5800FE5605 /* NavigateToEnterAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A314256B5B5800FE5605 /* NavigateToEnterAccount.swift */; }; E8AF6B9EF50902F2117DFAF9 /* Pods_WordPressAuthenticatorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A441EC80D2B8D2209C2E228 /* Pods_WordPressAuthenticatorTests.framework */; }; - EE758BFF28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE758BFE28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift */; }; + EE633D02287560E50002DE03 /* UITableView+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE633D01287560E50002DE03 /* UITableView+Helpers.swift */; }; F11448EC258B827B0048203D /* URL+JetpackConnect.swift in Sources */ = {isa = PBXBuildFile; fileRef = F11448EB258B827B0048203D /* URL+JetpackConnect.swift */; }; F12F9FB424D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */; }; F12F9FB824D8A7FC00771BCE /* AnalyticsTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */; }; @@ -379,7 +379,7 @@ D881A310256B5B4700FE5605 /* NavigateToEnterSite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateToEnterSite.swift; sourceTree = ""; }; D881A314256B5B5800FE5605 /* NavigateToEnterAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateToEnterAccount.swift; sourceTree = ""; }; E9414A95E29F3297555AC92B /* Pods-WordPressAuthenticator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.debug.xcconfig"; sourceTree = ""; }; - EE758BFE28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITableView+HeaderFooterHelpers.swift"; sourceTree = ""; }; + EE633D01287560E50002DE03 /* UITableView+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+Helpers.swift"; sourceTree = ""; }; F11448EB258B827B0048203D /* URL+JetpackConnect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+JetpackConnect.swift"; sourceTree = ""; }; F12F9FB324D8A68E00771BCE /* AuthenticatorAnalyticsTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticatorAnalyticsTracker.swift; sourceTree = ""; }; F12F9FB724D8A7FC00771BCE /* AnalyticsTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsTrackerTests.swift; sourceTree = ""; }; @@ -676,7 +676,6 @@ B560909B208A4EB000399AE4 /* Extensions */ = { isa = PBXGroup; children = ( - EE758BFE28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift */, B56090ED208A527000399AE4 /* FancyAlertViewController+LoginError.swift */, B56090EE208A527000399AE4 /* String+Underline.swift */, B56090EC208A527000399AE4 /* WPStyleGuide+Login.swift */, @@ -688,6 +687,7 @@ F1C96668250BF53400EB529D /* UIViewController+Dismissal.swift */, CE9091FD249A720E00AB50BD /* UIView+AuthHelpers.swift */, F11448EB258B827B0048203D /* URL+JetpackConnect.swift */, + EE633D01287560E50002DE03 /* UITableView+Helpers.swift */, ); path = Extensions; sourceTree = ""; @@ -1184,6 +1184,7 @@ buildActionMask = 2147483647; files = ( CE73475624B77A3800A22660 /* SiteCredentialsViewController.swift in Sources */, + EE633D02287560E50002DE03 /* UITableView+Helpers.swift in Sources */, 982C8E7923021C20003F1BA0 /* LoginPrologueLoginMethodViewController.swift in Sources */, B5609144208A563800399AE4 /* LoginPrologueSignupMethodViewController.swift in Sources */, B56090D1208A4F5400399AE4 /* NUXViewController.swift in Sources */, @@ -1256,7 +1257,6 @@ B560913D208A563800399AE4 /* LoginProloguePageViewController.swift in Sources */, B5609117208A555600399AE4 /* SearchTableViewCell.swift in Sources */, BA70352424F70C9F00B3AA1C /* ModalViewControllerPresenting.swift in Sources */, - EE758BFF28731B8B002E3679 /* UITableView+HeaderFooterHelpers.swift in Sources */, B56090C9208A4F5400399AE4 /* NUXLinkMailViewController.swift in Sources */, B56090F1208A527000399AE4 /* String+Underline.swift in Sources */, B56052A42090B2ED001B91FD /* CircularImageView.swift in Sources */, diff --git a/WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift b/WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift deleted file mode 100644 index b23953d90..000000000 --- a/WordPressAuthenticator/Extensions/UITableView+HeaderFooterHelpers.swift +++ /dev/null @@ -1,54 +0,0 @@ -import UIKit - -extension UITableView { - /// Called in view controller's `viewDidLayoutSubviews`. If table view has a footer view, calculates the new height. - /// If new height is different from current height, updates the footer view with the new height and reassigns the table footer view. - /// Note: make sure the top-level footer view (`tableView.tableFooterView`) is frame based as a container of the Auto Layout based subview. - func updateFooterHeight() { - if let footerView = tableFooterView { - let targetSize = CGSize(width: footerView.frame.width, height: 0) - let newSize = footerView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow) - let newHeight = newSize.height - var currentFrame = footerView.frame - if newHeight != currentFrame.size.height { - currentFrame.size.height = newHeight - footerView.frame = currentFrame - tableFooterView = footerView - } - } - } - - /// Called in view controller's `viewDidLayoutSubviews`. If table view has a header view, calculates the new height. - /// If new height is different from current height, updates the header view with the new height and reassigns the table header view. - /// Note: make sure the top-level header view (`tableView.tableHeaderView`) is frame based as a container of the Auto Layout based subview. - func updateHeaderHeight() { - if let headerView = tableHeaderView { - let targetSize = CGSize(width: headerView.frame.width, height: 0) - let newSize = headerView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow) - let newHeight = newSize.height - var currentFrame = headerView.frame - if newHeight != currentFrame.size.height { - currentFrame.size.height = newHeight - headerView.frame = currentFrame - tableHeaderView = headerView - } - } - } - - /// Removes the separator of the last cell. - /// - func removeLastCellSeparator() { - tableFooterView = UIView(frame: CGRect(origin: .zero, - size: CGSize(width: frame.width, height: 1))) - } - - /// Change `self.tableFooterView` to an empty view in order to hide the `UITableView`'s - /// default row placeholders (with separators). - /// - /// This intentionally have an absurdingly long method name because we want to be clear that - /// we are replacing the `tableFooterView` property. - /// - func applyFooterViewForHidingExtraRowPlaceholders() { - tableFooterView = UIView(frame: .zero) - } -} diff --git a/WordPressAuthenticator/Extensions/UITableView+Helpers.swift b/WordPressAuthenticator/Extensions/UITableView+Helpers.swift new file mode 100644 index 000000000..972468aa3 --- /dev/null +++ b/WordPressAuthenticator/Extensions/UITableView+Helpers.swift @@ -0,0 +1,20 @@ +import UIKit + +extension UITableView { + /// Called in view controller's `viewDidLayoutSubviews`. If table view has a footer view, calculates the new height. + /// If new height is different from current height, updates the footer view with the new height and reassigns the table footer view. + /// Note: make sure the top-level footer view (`tableView.tableFooterView`) is frame based as a container of the Auto Layout based subview. + func updateFooterHeight() { + if let footerView = tableFooterView { + let targetSize = CGSize(width: footerView.frame.width, height: 0) + let newSize = footerView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow) + let newHeight = newSize.height + var currentFrame = footerView.frame + if newHeight != currentFrame.size.height { + currentFrame.size.height = newHeight + footerView.frame = currentFrame + tableFooterView = footerView + } + } + } +} From 48fbd1713d510b8140fb2ebd3dd0b55e20a7df2f Mon Sep 17 00:00:00 2001 From: Sharma Elanthiraiyan Date: Wed, 6 Jul 2022 11:53:29 +0530 Subject: [PATCH 12/12] Replace `WpCom` with `WPCom` for consistent naming. --- .../Analytics/AuthenticatorAnalyticsTracker.swift | 2 +- .../View Related/Get Started/GetStartedViewController.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift b/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift index 3ce0131fd..35acc271d 100644 --- a/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift +++ b/WordPressAuthenticator/Analytics/AuthenticatorAnalyticsTracker.swift @@ -144,7 +144,7 @@ public class AuthenticatorAnalyticsTracker { /// Tracked when the user clicks “What is WordPress.com?" button on the WordPress.com flow screen /// - case whatIsWpCom = "what_is_wordpress_com" + case whatIsWPCom = "what_is_wordpress_com" /// Tracked when the user clicks “Login with site address” on the Prologue screen /// diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index 57463a68c..5d252dcde 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -217,7 +217,7 @@ private extension GetStartedViewController { // MARK: - What is WordPress.com Button Action @IBAction func whatIsWPComButtonTapped(_ sender: UIButton) { - tracker.track(click: .whatIsWpCom) + tracker.track(click: .whatIsWPCom) guard let whatIsWPCom = WordPressAuthenticator.shared.configuration.whatIsWPComURL, let url = URL(string: whatIsWPCom) else { return