From 26832ddb444a182addf5464f3125141ef5fef2aa Mon Sep 17 00:00:00 2001 From: James Frost Date: Fri, 2 Apr 2021 14:55:27 +0100 Subject: [PATCH 1/2] Allow NUXButtonView leading and trailing constraints to be overridden * This fixes an issue on the login prologue screen where the top shadow didn't reach all the way to the edges of the superview, as it was constrained to the edges of the button view. --- .../NUX/NUXButtonView.storyboard | 15 ++++++---- .../NUX/NUXButtonViewController.swift | 29 ++++++++++++++++++- .../Signin/LoginPrologueViewController.swift | 2 ++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/WordPressAuthenticator/NUX/NUXButtonView.storyboard b/WordPressAuthenticator/NUX/NUXButtonView.storyboard index efab307ca..c36107515 100644 --- a/WordPressAuthenticator/NUX/NUXButtonView.storyboard +++ b/WordPressAuthenticator/NUX/NUXButtonView.storyboard @@ -1,9 +1,9 @@ - + - + @@ -47,7 +47,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -76,6 +76,7 @@ + @@ -86,7 +87,6 @@ - @@ -96,6 +96,8 @@ + + @@ -105,5 +107,8 @@ + + + diff --git a/WordPressAuthenticator/NUX/NUXButtonViewController.swift b/WordPressAuthenticator/NUX/NUXButtonViewController.swift index 262b246f0..86e8b090c 100644 --- a/WordPressAuthenticator/NUX/NUXButtonViewController.swift +++ b/WordPressAuthenticator/NUX/NUXButtonViewController.swift @@ -34,13 +34,23 @@ open class NUXButtonViewController: UIViewController { // MARK: - Properties - @IBOutlet private var shadowView: UIImageView? @IBOutlet var stackView: UIStackView? @IBOutlet var bottomButton: NUXButton? @IBOutlet var topButton: NUXButton? @IBOutlet var tertiaryButton: NUXButton? @IBOutlet var buttonHolder: UIView? + @IBOutlet private var shadowView: UIImageView? + @IBOutlet private var shadowViewEdgeConstraints: [NSLayoutConstraint]! + + /// Used to constrain the shadow view outside of the + /// bounds of this view controller. + weak var shadowLayoutGuide: UILayoutGuide? { + didSet { + updateShadowViewEdgeConstraints() + } + } + open weak var delegate: NUXButtonViewControllerDelegate? open var backgroundColor: UIColor? @@ -91,6 +101,23 @@ open class NUXButtonViewController: UIViewController { } } + private func updateShadowViewEdgeConstraints() { + guard let layoutGuide = shadowLayoutGuide, + let shadowView = shadowView else { + return + } + + NSLayoutConstraint.deactivate(shadowViewEdgeConstraints) + shadowView.translatesAutoresizingMaskIntoConstraints = false + + shadowViewEdgeConstraints = [ + layoutGuide.leadingAnchor.constraint(equalTo: shadowView.leadingAnchor), + layoutGuide.trailingAnchor.constraint(equalTo: shadowView.trailingAnchor), + ] + + NSLayoutConstraint.activate(shadowViewEdgeConstraints) + } + // MARK: public API /// Public method to set the button titles. diff --git a/WordPressAuthenticator/Signin/LoginPrologueViewController.swift b/WordPressAuthenticator/Signin/LoginPrologueViewController.swift index 58dd366b4..729c6f9fb 100644 --- a/WordPressAuthenticator/Signin/LoginPrologueViewController.swift +++ b/WordPressAuthenticator/Signin/LoginPrologueViewController.swift @@ -163,6 +163,8 @@ class LoginPrologueViewController: LoginViewController { } buildUnifiedPrologueButtons(buttonViewController) + + buttonViewController.shadowLayoutGuide = view.safeAreaLayoutGuide } /// Displays the old UI prologue buttons. From 3f64695eaf173af3b2fa8b3c2c89c2813a16e462 Mon Sep 17 00:00:00 2001 From: James Frost Date: Fri, 2 Apr 2021 14:55:56 +0100 Subject: [PATCH 2/2] Bump podspec to 1.36.0-beta.4 --- WordPressAuthenticator.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressAuthenticator.podspec b/WordPressAuthenticator.podspec index a17173fb2..34b42f073 100644 --- a/WordPressAuthenticator.podspec +++ b/WordPressAuthenticator.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressAuthenticator" - s.version = "1.36.0-beta.3" + s.version = "1.36.0-beta.4" s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps." s.description = <<-DESC