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

Commit c740406

Browse files
authored
Merge pull request #586 from wordpress-mobile/fix/nux-button-shadows
Allow customization of NUX button view shadows constraints
2 parents eaa6b03 + 3f64695 commit c740406

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressAuthenticator"
3-
s.version = "1.36.0-beta.3"
3+
s.version = "1.36.0-beta.4"
44

55
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
66
s.description = <<-DESC

WordPressAuthenticator/NUX/NUXButtonView.storyboard

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.3" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99
</dependencies>
@@ -47,7 +47,7 @@
4747
</constraints>
4848
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
4949
<state key="normal" title="Primary Button">
50-
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
50+
<color key="titleColor" systemColor="darkTextColor"/>
5151
</state>
5252
<state key="highlighted">
5353
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -64,7 +64,7 @@
6464
</constraints>
6565
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
6666
<state key="normal" title="Cancel Button">
67-
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
67+
<color key="titleColor" systemColor="darkTextColor"/>
6868
</state>
6969
<state key="highlighted">
7070
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -76,6 +76,7 @@
7676
</subviews>
7777
</stackView>
7878
</subviews>
79+
<viewLayoutGuide key="safeArea" id="vC0-ge-46d"/>
7980
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
8081
<constraints>
8182
<constraint firstItem="RrB-Aa-ADd" firstAttribute="leading" secondItem="vC0-ge-46d" secondAttribute="leading" id="29Q-jd-hiu"/>
@@ -86,7 +87,6 @@
8687
<constraint firstItem="vC0-ge-46d" firstAttribute="trailing" secondItem="xzf-f5-7zQ" secondAttribute="trailing" constant="16" id="pdk-yI-G0O"/>
8788
<constraint firstItem="RrB-Aa-ADd" firstAttribute="top" secondItem="vC0-ge-46d" secondAttribute="top" constant="-10" id="qZc-jk-YRs"/>
8889
</constraints>
89-
<viewLayoutGuide key="safeArea" id="vC0-ge-46d"/>
9090
</view>
9191
<size key="freeformSize" width="375" height="136"/>
9292
<connections>
@@ -96,6 +96,8 @@
9696
<outlet property="stackView" destination="xzf-f5-7zQ" id="frG-Oo-nB4"/>
9797
<outlet property="tertiaryButton" destination="uAF-kU-f7P" id="B6D-lx-GhC"/>
9898
<outlet property="topButton" destination="knN-O6-M86" id="3fN-Bh-Z8O"/>
99+
<outletCollection property="shadowViewEdgeConstraints" destination="29Q-jd-hiu" collectionClass="NSMutableArray" id="Um7-mZ-AvI"/>
100+
<outletCollection property="shadowViewEdgeConstraints" destination="APL-hI-Fg5" collectionClass="NSMutableArray" id="K7W-dN-UTb"/>
99101
</connections>
100102
</viewController>
101103
<placeholder placeholderIdentifier="IBFirstResponder" id="7sJ-Ej-Lr7" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -105,5 +107,8 @@
105107
</scenes>
106108
<resources>
107109
<image name="darkgrey-shadow" width="10" height="10"/>
110+
<systemColor name="darkTextColor">
111+
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
112+
</systemColor>
108113
</resources>
109114
</document>

WordPressAuthenticator/NUX/NUXButtonViewController.swift

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,23 @@ open class NUXButtonViewController: UIViewController {
3434

3535
// MARK: - Properties
3636

37-
@IBOutlet private var shadowView: UIImageView?
3837
@IBOutlet var stackView: UIStackView?
3938
@IBOutlet var bottomButton: NUXButton?
4039
@IBOutlet var topButton: NUXButton?
4140
@IBOutlet var tertiaryButton: NUXButton?
4241
@IBOutlet var buttonHolder: UIView?
4342

43+
@IBOutlet private var shadowView: UIImageView?
44+
@IBOutlet private var shadowViewEdgeConstraints: [NSLayoutConstraint]!
45+
46+
/// Used to constrain the shadow view outside of the
47+
/// bounds of this view controller.
48+
weak var shadowLayoutGuide: UILayoutGuide? {
49+
didSet {
50+
updateShadowViewEdgeConstraints()
51+
}
52+
}
53+
4454
open weak var delegate: NUXButtonViewControllerDelegate?
4555
open var backgroundColor: UIColor?
4656

@@ -91,6 +101,23 @@ open class NUXButtonViewController: UIViewController {
91101
}
92102
}
93103

104+
private func updateShadowViewEdgeConstraints() {
105+
guard let layoutGuide = shadowLayoutGuide,
106+
let shadowView = shadowView else {
107+
return
108+
}
109+
110+
NSLayoutConstraint.deactivate(shadowViewEdgeConstraints)
111+
shadowView.translatesAutoresizingMaskIntoConstraints = false
112+
113+
shadowViewEdgeConstraints = [
114+
layoutGuide.leadingAnchor.constraint(equalTo: shadowView.leadingAnchor),
115+
layoutGuide.trailingAnchor.constraint(equalTo: shadowView.trailingAnchor),
116+
]
117+
118+
NSLayoutConstraint.activate(shadowViewEdgeConstraints)
119+
}
120+
94121
// MARK: public API
95122

96123
/// Public method to set the button titles.

WordPressAuthenticator/Signin/LoginPrologueViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ class LoginPrologueViewController: LoginViewController {
163163
}
164164

165165
buildUnifiedPrologueButtons(buttonViewController)
166+
167+
buttonViewController.shadowLayoutGuide = view.safeAreaLayoutGuide
166168
}
167169

168170
/// Displays the old UI prologue buttons.

0 commit comments

Comments
 (0)