From 5a4566059d82f899911c0e4b15c74304f253b182 Mon Sep 17 00:00:00 2001 From: Cesar Tardaguila <2722505+ctarda@users.noreply.github.com> Date: Mon, 14 Dec 2020 07:21:21 +0800 Subject: [PATCH 1/4] Expose a public method to hide the TOS button while leaving the cell in place --- .../Get Started/GetStartedViewController.swift | 11 ++++++----- .../Reusable Views/TextWithLinkTableViewCell.swift | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index a4a9525aa..158370426 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -206,12 +206,8 @@ private extension GetStartedViewController { /// Describes how the tableView rows should be rendered. /// func loadRows() { - rows = [.instructions, .email] + rows = [.instructions, .email, .tos] - if let authenticationDelegate = WordPressAuthenticator.shared.delegate, authenticationDelegate.wpcomTermsOfServiceEnabled { - rows.append(.tos) - } - if let errorText = errorMessage, !errorText.isEmpty { rows.append(.errorMessage) } @@ -277,6 +273,11 @@ private extension GetStartedViewController { /// Configure the link cell. /// func configureTextWithLink(_ cell: TextWithLinkTableViewCell) { + guard let authenticationDelegate = WordPressAuthenticator.shared.delegate, authenticationDelegate.wpcomTermsOfServiceEnabled else { + cell.hideButton() + return + } + cell.configureButton(markedText: WordPressAuthenticator.shared.displayStrings.loginTermsOfService) cell.actionHandler = { [weak self] in diff --git a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift index 5a1a80cbb..f41a2295d 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift @@ -42,4 +42,8 @@ class TextWithLinkTableViewCell: UITableViewCell { button.accessibilityTraits = accessibilityTrait } + func hideButton() { + button.isHidden = true + } + } From b019fa1c20d86d13c2c8b77a2913c30764c3f1d0 Mon Sep 17 00:00:00 2001 From: Cesar Tardaguila <2722505+ctarda@users.noreply.github.com> Date: Mon, 14 Dec 2020 07:21:48 +0800 Subject: [PATCH 2/4] Bump podspec --- WordPressAuthenticator.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index 06cc4d883..c4e8c3fda 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressAuthenticator" - s.version = "1.31.0-beta.5" + s.version = "1.31.0-beta.6" s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps." s.description = <<-DESC From 64b1ce5f30465ce511d3a0c3f742291f2fda766a Mon Sep 17 00:00:00 2001 From: Cesar Tardaguila <2722505+ctarda@users.noreply.github.com> Date: Mon, 14 Dec 2020 07:39:05 +0800 Subject: [PATCH 3/4] Use an spacer cell instead --- .../project.pbxproj | 8 +++++++ .../GetStartedViewController.swift | 21 ++++++++++------ .../Reusable Views/SpacerTableViewCell.swift | 7 ++++++ .../Reusable Views/SpacerTableViewCell.xib | 24 +++++++++++++++++++ .../TextWithLinkTableViewCell.swift | 5 ---- 5 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.swift create mode 100644 WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib diff --git a/WordPressAuthenticator.xcodeproj/project.pbxproj b/WordPressAuthenticator.xcodeproj/project.pbxproj index b129888eb..a6b29365e 100644 --- a/WordPressAuthenticator.xcodeproj/project.pbxproj +++ b/WordPressAuthenticator.xcodeproj/project.pbxproj @@ -163,6 +163,8 @@ D8610CEC2570A60C00A5DF27 /* NavigationToRootTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8610CEB2570A60C00A5DF27 /* NavigationToRootTests.swift */; }; D8611A63257622ED00A5DF27 /* NavigateBack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8611A62257622ED00A5DF27 /* NavigateBack.swift */; }; D8611A672576236800A5DF27 /* NavigateBackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8611A662576236800A5DF27 /* NavigateBackTests.swift */; }; + D87F120B2586DA26005675C5 /* SpacerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87F12092586DA26005675C5 /* SpacerTableViewCell.swift */; }; + D87F120C2586DA26005675C5 /* SpacerTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D87F120A2586DA26005675C5 /* SpacerTableViewCell.xib */; }; D881A30D256B5A7900FE5605 /* NavigationCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A30C256B5A7900FE5605 /* NavigationCommand.swift */; }; D881A311256B5B4700FE5605 /* NavigateToEnterSite.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A310256B5B4700FE5605 /* NavigateToEnterSite.swift */; }; D881A315256B5B5800FE5605 /* NavigateToEnterAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = D881A314256B5B5800FE5605 /* NavigateToEnterAccount.swift */; }; @@ -375,6 +377,8 @@ D8610CEB2570A60C00A5DF27 /* NavigationToRootTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationToRootTests.swift; sourceTree = ""; }; D8611A62257622ED00A5DF27 /* NavigateBack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateBack.swift; sourceTree = ""; }; D8611A662576236800A5DF27 /* NavigateBackTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateBackTests.swift; sourceTree = ""; }; + D87F12092586DA26005675C5 /* SpacerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpacerTableViewCell.swift; sourceTree = ""; }; + D87F120A2586DA26005675C5 /* SpacerTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SpacerTableViewCell.xib; sourceTree = ""; }; D881A30C256B5A7900FE5605 /* NavigationCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationCommand.swift; sourceTree = ""; }; D881A310256B5B4700FE5605 /* NavigateToEnterSite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateToEnterSite.swift; sourceTree = ""; }; D881A314256B5B5800FE5605 /* NavigateToEnterAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateToEnterAccount.swift; sourceTree = ""; }; @@ -876,6 +880,8 @@ CE6BCD3724A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.xib */, 98F40AEF24F5E13200A72911 /* TextWithLinkTableViewCell.swift */, 98F40AEE24F5E13200A72911 /* TextWithLinkTableViewCell.xib */, + D87F12092586DA26005675C5 /* SpacerTableViewCell.swift */, + D87F120A2586DA26005675C5 /* SpacerTableViewCell.xib */, ); path = "Reusable Views"; sourceTree = ""; @@ -1065,6 +1071,7 @@ CE1BBF8D24D48580001D2E3E /* GravatarEmailTableViewCell.xib in Resources */, B560913F208A563800399AE4 /* Login.storyboard in Resources */, CE6BCD3924A3CB5E001BCDC5 /* TextLinkButtonTableViewCell.xib in Resources */, + D87F120C2586DA26005675C5 /* SpacerTableViewCell.xib in Resources */, CE6BCD2F24A3A235001BCDC5 /* TextLabelTableViewCell.xib in Resources */, 98CF18F9248725620047B66C /* GoogleSignupConfirmation.storyboard in Resources */, B5609137208A563800399AE4 /* EmailMagicLink.storyboard in Resources */, @@ -1262,6 +1269,7 @@ 98CF18F7248725370047B66C /* GoogleSignupConfirmationViewController.swift in Sources */, BA53D65324DFEA58001F1ABF /* OnePasswordResultsFetcher.swift in Sources */, 1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */, + D87F120B2586DA26005675C5 /* SpacerTableViewCell.swift in Sources */, CEC77C6624854F2E00FB9050 /* SiteAddressViewController.swift in Sources */, CEDE0D952420121D00CB3345 /* UIStoryboard+Helpers.swift in Sources */, B5ED7920207E993E00A8FD8C /* WPAuthenticatorLogging.m in Sources */, diff --git a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift index 158370426..fe3a94fac 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift @@ -195,7 +195,8 @@ private extension GetStartedViewController { let cells = [ TextLabelTableViewCell.reuseIdentifier: TextLabelTableViewCell.loadNib(), TextFieldTableViewCell.reuseIdentifier: TextFieldTableViewCell.loadNib(), - TextWithLinkTableViewCell.reuseIdentifier: TextWithLinkTableViewCell.loadNib() + TextWithLinkTableViewCell.reuseIdentifier: TextWithLinkTableViewCell.loadNib(), + SpacerTableViewCell.reuseIdentifier: SpacerTableViewCell.loadNib() ] for (reuseIdentifier, nib) in cells { @@ -206,7 +207,13 @@ private extension GetStartedViewController { /// Describes how the tableView rows should be rendered. /// func loadRows() { - rows = [.instructions, .email, .tos] + rows = [.instructions, .email] + + if let authenticationDelegate = WordPressAuthenticator.shared.delegate, authenticationDelegate.wpcomTermsOfServiceEnabled { + rows.append(.tos) + } else { + rows.append(.spacer) + } if let errorText = errorMessage, !errorText.isEmpty { rows.append(.errorMessage) @@ -223,6 +230,8 @@ private extension GetStartedViewController { configureEmailField(cell) case let cell as TextWithLinkTableViewCell: configureTextWithLink(cell) + case cell as SpacerTableViewCell: + break case let cell as TextLabelTableViewCell where row == .errorMessage: configureErrorLabel(cell) default: @@ -273,11 +282,6 @@ private extension GetStartedViewController { /// Configure the link cell. /// func configureTextWithLink(_ cell: TextWithLinkTableViewCell) { - guard let authenticationDelegate = WordPressAuthenticator.shared.delegate, authenticationDelegate.wpcomTermsOfServiceEnabled else { - cell.hideButton() - return - } - cell.configureButton(markedText: WordPressAuthenticator.shared.displayStrings.loginTermsOfService) cell.actionHandler = { [weak self] in @@ -301,6 +305,7 @@ private extension GetStartedViewController { case instructions case email case tos + case spacer case errorMessage var reuseIdentifier: String { @@ -311,6 +316,8 @@ private extension GetStartedViewController { return TextFieldTableViewCell.reuseIdentifier case .tos: return TextWithLinkTableViewCell.reuseIdentifier + case .spacer: + return SpacerTableViewCell.reuseIdentifier } } } diff --git a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.swift b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.swift new file mode 100644 index 000000000..cfd5f022e --- /dev/null +++ b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.swift @@ -0,0 +1,7 @@ +import UIKit + +/// SpacerTableViewCell: an empty cell, used as separator and to introduce padding. +/// +final class SpacerTableViewCell: UITableViewCell { + static let reuseIdentifier = "SpacerTableViewCell" +} diff --git a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib new file mode 100644 index 000000000..b377eea8e --- /dev/null +++ b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift index f41a2295d..5c27c15c5 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift +++ b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift @@ -41,9 +41,4 @@ class TextWithLinkTableViewCell: UITableViewCell { button.setAttributedTitle(highlightAttributedString, for: .highlighted) button.accessibilityTraits = accessibilityTrait } - - func hideButton() { - button.isHidden = true - } - } From 9cca208e4c440215dba6ef3e020bfaf0439b03c8 Mon Sep 17 00:00:00 2001 From: Cesar Tardaguila <2722505+ctarda@users.noreply.github.com> Date: Tue, 15 Dec 2020 10:06:54 +0800 Subject: [PATCH 4/4] De-activate userInteractionEnabled --- .../View Related/Reusable Views/SpacerTableViewCell.xib | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib index b377eea8e..01a21079d 100644 --- a/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib +++ b/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/SpacerTableViewCell.xib @@ -18,6 +18,9 @@ + + +