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

Commit e0dc960

Browse files
authored
Merge pull request #18 from wordpress-mobile/feature/more-configurations
Expose view controller background colors for styling by host apps
2 parents c71b229 + 81e910b commit e0dc960

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

WordPressAuthenticator/Authenticator/WordPressAuthenticatorStyles.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
import UIKit
2+
import Gridicons
23

34
// MARK: - WordPress Authenticator Styles
45
//
@@ -41,9 +42,17 @@ public struct WordPressAuthenticatorStyle {
4142
///
4243
public let subheadlineColor: UIColor
4344

45+
/// Style: Login screen background colors
46+
///
47+
public let viewControllerBackgroundColor: UIColor
48+
49+
/// Style: nav bar logo
50+
///
51+
public let navBarImage: UIImage
52+
4453
/// Designated initializer
4554
///
46-
public init(primaryNormalBackgroundColor: UIColor, primaryNormalBorderColor: UIColor, primaryHighlightBackgroundColor: UIColor, primaryHighlightBorderColor: UIColor, secondaryNormalBackgroundColor: UIColor, secondaryNormalBorderColor: UIColor, secondaryHighlightBackgroundColor: UIColor, secondaryHighlightBorderColor: UIColor, disabledBackgroundColor: UIColor, disabledBorderColor: UIColor, primaryTitleColor: UIColor, secondaryTitleColor: UIColor, disabledTitleColor: UIColor, subheadlineColor: UIColor) {
55+
public init(primaryNormalBackgroundColor: UIColor, primaryNormalBorderColor: UIColor, primaryHighlightBackgroundColor: UIColor, primaryHighlightBorderColor: UIColor, secondaryNormalBackgroundColor: UIColor, secondaryNormalBorderColor: UIColor, secondaryHighlightBackgroundColor: UIColor, secondaryHighlightBorderColor: UIColor, disabledBackgroundColor: UIColor, disabledBorderColor: UIColor, primaryTitleColor: UIColor, secondaryTitleColor: UIColor, disabledTitleColor: UIColor, subheadlineColor: UIColor, viewControllerBackgroundColor: UIColor, navBarImage: UIImage) {
4756
self.primaryNormalBackgroundColor = primaryNormalBackgroundColor
4857
self.primaryNormalBorderColor = primaryNormalBorderColor
4958
self.primaryHighlightBackgroundColor = primaryHighlightBackgroundColor
@@ -58,6 +67,8 @@ public struct WordPressAuthenticatorStyle {
5867
self.secondaryTitleColor = secondaryTitleColor
5968
self.disabledTitleColor = disabledTitleColor
6069
self.subheadlineColor = subheadlineColor
70+
self.viewControllerBackgroundColor = viewControllerBackgroundColor
71+
self.navBarImage = navBarImage
6172
}
6273
}
6374

@@ -76,6 +87,9 @@ public extension WordPressAuthenticatorStyle {
7687
primaryTitleColor: UIColor.white,
7788
secondaryTitleColor: WPStyleGuide.darkGrey(),
7889
disabledTitleColor: WPStyleGuide.greyLighten30(),
79-
subheadlineColor: WPStyleGuide.wordPressBlue())
90+
subheadlineColor: WPStyleGuide.wordPressBlue(),
91+
viewControllerBackgroundColor: WPStyleGuide.lightGrey(),
92+
navBarImage: Gridicon.iconOfType(.mySites)
93+
)
8094
}
8195
}

WordPressAuthenticator/NUX/NUXViewControllerBase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
144144
/// Adds the WP logo to the nav controller
145145
///
146146
public func addWordPressLogoToNavController() {
147-
let image = Gridicon.iconOfType(.mySites)
147+
let image = WordPressAuthenticator.shared.style.navBarImage
148148
let imageView = UIImageView(image: image.imageWithTintColor(UIColor.white))
149149
navigationItem.titleView = imageView
150150
}

WordPressAuthenticator/Signin/Login.storyboard

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
</connections>
108108
</containerView>
109109
</subviews>
110-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
111110
<constraints>
112111
<constraint firstItem="6cw-FO-hjb" firstAttribute="leading" secondItem="EnO-7f-1yO" secondAttribute="leading" id="7Z8-mD-FWN"/>
113112
<constraint firstAttribute="trailing" secondItem="G3G-Ap-6ix" secondAttribute="trailing" id="96a-eB-JlD"/>
@@ -320,7 +319,6 @@
320319
</variation>
321320
</view>
322321
</subviews>
323-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
324322
<constraints>
325323
<constraint firstItem="ozJ-hT-OEw" firstAttribute="top" secondItem="bn3-aC-RIM" secondAttribute="bottom" id="S6n-FZ-9Yc"/>
326324
<constraint firstAttribute="trailing" secondItem="ozJ-hT-OEw" secondAttribute="trailing" id="Uuo-bm-Be2"/>
@@ -547,7 +545,6 @@
547545
</variation>
548546
</view>
549547
</subviews>
550-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
551548
<constraints>
552549
<constraint firstItem="Ktl-It-Kmo" firstAttribute="top" secondItem="dSZ-FR-Cdo" secondAttribute="bottom" id="1qL-V5-NRd"/>
553550
<constraint firstItem="dSZ-FR-Cdo" firstAttribute="leading" secondItem="HTO-Y8-god" secondAttribute="leadingMargin" constant="-20" id="E8T-56-rvq"/>
@@ -721,7 +718,6 @@
721718
</variation>
722719
</view>
723720
</subviews>
724-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
725721
<constraints>
726722
<constraint firstItem="7OQ-0t-1zq" firstAttribute="centerX" secondItem="tEh-Nj-xof" secondAttribute="centerX" id="1g8-p2-jnJ"/>
727723
<constraint firstItem="7OQ-0t-1zq" firstAttribute="top" secondItem="dAs-4b-ACP" secondAttribute="bottom" id="6Lb-n5-RrE"/>
@@ -885,7 +881,6 @@
885881
</variation>
886882
</view>
887883
</subviews>
888-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
889884
<constraints>
890885
<constraint firstAttribute="trailingMargin" secondItem="hTY-xb-H5h" secondAttribute="trailing" constant="-20" id="23h-QU-eyB"/>
891886
<constraint firstItem="hTY-xb-H5h" firstAttribute="centerX" secondItem="cm5-76-st7" secondAttribute="centerX" id="PRb-I7-O07"/>
@@ -983,7 +978,6 @@
983978
</connections>
984979
</button>
985980
</subviews>
986-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
987981
<constraints>
988982
<constraint firstItem="B6x-b7-hU9" firstAttribute="width" secondItem="HnR-5a-suO" secondAttribute="width" id="AAB-N8-Iyv"/>
989983
<constraint firstAttribute="trailingMargin" secondItem="Mq6-n0-6iO" secondAttribute="trailing" constant="20" id="CoO-Ax-hqg"/>
@@ -1133,7 +1127,6 @@
11331127
</variation>
11341128
</view>
11351129
</subviews>
1136-
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
11371130
<constraints>
11381131
<constraint firstItem="a59-c7-WBk" firstAttribute="centerX" secondItem="CvY-vN-fn9" secondAttribute="centerX" id="R8E-Gd-gVZ"/>
11391132
<constraint firstItem="a59-c7-WBk" firstAttribute="leading" secondItem="CvY-vN-fn9" secondAttribute="leadingMargin" constant="-20" id="atB-bL-5qa"/>
@@ -1182,10 +1175,10 @@
11821175
<inferredMetricsTieBreakers>
11831176
<segue reference="kRR-qz-Hu2"/>
11841177
<segue reference="ySQ-EM-6JI"/>
1185-
<segue reference="sIC-Hv-FJw"/>
1186-
<segue reference="1xT-tL-sp6"/>
1187-
<segue reference="iD4-VS-n3M"/>
1188-
<segue reference="EmH-Av-vhT"/>
1189-
<segue reference="HMT-Z5-QHr"/>
1178+
<segue reference="nCA-u7-fKm"/>
1179+
<segue reference="D3h-Su-Jwk"/>
1180+
<segue reference="swV-lc-6gI"/>
1181+
<segue reference="gD5-d0-X3t"/>
1182+
<segue reference="aSC-hU-lzE"/>
11901183
</inferredMetricsTieBreakers>
11911184
</document>

WordPressAuthenticator/Signin/LoginViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ open class LoginViewController: NUXViewController, LoginFacadeDelegate {
3838
super.viewDidLoad()
3939
displayError(message: "")
4040
setupNavBarIcon()
41+
styleBackground()
4142
styleInstructions()
4243

4344
if let error = errorToPresent {
@@ -57,6 +58,12 @@ open class LoginViewController: NUXViewController, LoginFacadeDelegate {
5758
addWordPressLogoToNavController()
5859
}
5960

61+
/// Styles the view's background color. Defaults to WPStyleGuide.lightGrey()
62+
///
63+
@objc func styleBackground() {
64+
view.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
65+
}
66+
6067
/// Configures instruction label font
6168
///
6269
func styleInstructions() {

0 commit comments

Comments
 (0)