Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose view controller background colors for styling by host apps #18

Merged
merged 11 commits into from
Aug 7, 2018
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import UIKit
import Gridicons

// MARK: - WordPress Authenticator Styles
//
Expand Down Expand Up @@ -41,9 +42,17 @@ public struct WordPressAuthenticatorStyle {
///
public let subheadlineColor: UIColor

/// Style: Login screen background colors
///
public let viewControllerBackgroundColor: UIColor

/// Style: nav bar logo
///
public let navBarImage: UIImage

/// Designated initializer
///
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) {
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) {
self.primaryNormalBackgroundColor = primaryNormalBackgroundColor
self.primaryNormalBorderColor = primaryNormalBorderColor
self.primaryHighlightBackgroundColor = primaryHighlightBackgroundColor
Expand All @@ -58,6 +67,8 @@ public struct WordPressAuthenticatorStyle {
self.secondaryTitleColor = secondaryTitleColor
self.disabledTitleColor = disabledTitleColor
self.subheadlineColor = subheadlineColor
self.viewControllerBackgroundColor = viewControllerBackgroundColor
self.navBarImage = navBarImage
}
}

Expand All @@ -76,6 +87,9 @@ public extension WordPressAuthenticatorStyle {
primaryTitleColor: UIColor.white,
secondaryTitleColor: WPStyleGuide.darkGrey(),
disabledTitleColor: WPStyleGuide.greyLighten30(),
subheadlineColor: WPStyleGuide.wordPressBlue())
subheadlineColor: WPStyleGuide.wordPressBlue(),
viewControllerBackgroundColor: WPStyleGuide.lightGrey(),
navBarImage: Gridicon.iconOfType(.mySites)
)
}
}
2 changes: 1 addition & 1 deletion WordPressAuthenticator/NUX/NUXViewControllerBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
/// Adds the WP logo to the nav controller
///
public func addWordPressLogoToNavController() {
let image = Gridicon.iconOfType(.mySites)
let image = WordPressAuthenticator.shared.style.navBarImage
let imageView = UIImageView(image: image.imageWithTintColor(UIColor.white))
navigationItem.titleView = imageView
}
Expand Down
17 changes: 5 additions & 12 deletions WordPressAuthenticator/Signin/Login.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
</connections>
</containerView>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="6cw-FO-hjb" firstAttribute="leading" secondItem="EnO-7f-1yO" secondAttribute="leading" id="7Z8-mD-FWN"/>
<constraint firstAttribute="trailing" secondItem="G3G-Ap-6ix" secondAttribute="trailing" id="96a-eB-JlD"/>
Expand Down Expand Up @@ -320,7 +319,6 @@
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="ozJ-hT-OEw" firstAttribute="top" secondItem="bn3-aC-RIM" secondAttribute="bottom" id="S6n-FZ-9Yc"/>
<constraint firstAttribute="trailing" secondItem="ozJ-hT-OEw" secondAttribute="trailing" id="Uuo-bm-Be2"/>
Expand Down Expand Up @@ -547,7 +545,6 @@
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="Ktl-It-Kmo" firstAttribute="top" secondItem="dSZ-FR-Cdo" secondAttribute="bottom" id="1qL-V5-NRd"/>
<constraint firstItem="dSZ-FR-Cdo" firstAttribute="leading" secondItem="HTO-Y8-god" secondAttribute="leadingMargin" constant="-20" id="E8T-56-rvq"/>
Expand Down Expand Up @@ -721,7 +718,6 @@
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="7OQ-0t-1zq" firstAttribute="centerX" secondItem="tEh-Nj-xof" secondAttribute="centerX" id="1g8-p2-jnJ"/>
<constraint firstItem="7OQ-0t-1zq" firstAttribute="top" secondItem="dAs-4b-ACP" secondAttribute="bottom" id="6Lb-n5-RrE"/>
Expand Down Expand Up @@ -885,7 +881,6 @@
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="hTY-xb-H5h" secondAttribute="trailing" constant="-20" id="23h-QU-eyB"/>
<constraint firstItem="hTY-xb-H5h" firstAttribute="centerX" secondItem="cm5-76-st7" secondAttribute="centerX" id="PRb-I7-O07"/>
Expand Down Expand Up @@ -983,7 +978,6 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="B6x-b7-hU9" firstAttribute="width" secondItem="HnR-5a-suO" secondAttribute="width" id="AAB-N8-Iyv"/>
<constraint firstAttribute="trailingMargin" secondItem="Mq6-n0-6iO" secondAttribute="trailing" constant="20" id="CoO-Ax-hqg"/>
Expand Down Expand Up @@ -1133,7 +1127,6 @@
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.95294117649999999" green="0.96470588239999999" blue="0.97254901959999995" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="a59-c7-WBk" firstAttribute="centerX" secondItem="CvY-vN-fn9" secondAttribute="centerX" id="R8E-Gd-gVZ"/>
<constraint firstItem="a59-c7-WBk" firstAttribute="leading" secondItem="CvY-vN-fn9" secondAttribute="leadingMargin" constant="-20" id="atB-bL-5qa"/>
Expand Down Expand Up @@ -1182,10 +1175,10 @@
<inferredMetricsTieBreakers>
<segue reference="kRR-qz-Hu2"/>
<segue reference="ySQ-EM-6JI"/>
<segue reference="sIC-Hv-FJw"/>
<segue reference="1xT-tL-sp6"/>
<segue reference="iD4-VS-n3M"/>
<segue reference="EmH-Av-vhT"/>
<segue reference="HMT-Z5-QHr"/>
<segue reference="nCA-u7-fKm"/>
<segue reference="D3h-Su-Jwk"/>
<segue reference="swV-lc-6gI"/>
<segue reference="gD5-d0-X3t"/>
<segue reference="aSC-hU-lzE"/>
</inferredMetricsTieBreakers>
</document>
7 changes: 7 additions & 0 deletions WordPressAuthenticator/Signin/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ open class LoginViewController: NUXViewController, LoginFacadeDelegate {
super.viewDidLoad()
displayError(message: "")
setupNavBarIcon()
styleBackground()
styleInstructions()

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

/// Styles the view's background color. Defaults to WPStyleGuide.lightGrey()
///
@objc func styleBackground() {
view.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
}

/// Configures instruction label font
///
func styleInstructions() {
Expand Down