Skip to content

Commit e36e801

Browse files
authored
Merge pull request #131 from woocommerce/feature/96-authenticator-appearance
Configure NUXButton using UIAppearance in AppDelegate
2 parents 75f3750 + 48b2ded commit e36e801

File tree

7 files changed

+100
-31
lines changed

7 files changed

+100
-31
lines changed

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ target 'WooCommerce' do
1818
#
1919
pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :tag => '0.2.3'
2020
pod 'Gridicons', '0.15'
21-
pod 'WordPressAuthenticator', :git => 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', :commit => '58ed623'
21+
pod 'WordPressAuthenticator', '~> 1.0'
2222

2323

2424
# External Libraries

Podfile.lock

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ PODS:
1313
- CocoaLumberjack/Default
1414
- CocoaLumberjack/Swift (3.4.2):
1515
- CocoaLumberjack/Default
16-
- Crashlytics (3.10.3):
17-
- Fabric (~> 1.7.8)
18-
- Fabric (1.7.8)
16+
- Crashlytics (3.10.4):
17+
- Fabric (~> 1.7.9)
18+
- Fabric (1.7.9)
1919
- FormatterKit/Resources (1.8.2)
2020
- FormatterKit/TimeIntervalFormatter (1.8.2):
2121
- FormatterKit/Resources
@@ -38,7 +38,7 @@ PODS:
3838
- Reachability (3.2)
3939
- SVProgressHUD (2.2.5)
4040
- UIDeviceIdentifier (0.5.0)
41-
- WordPressAuthenticator (1.0.0):
41+
- WordPressAuthenticator (1.0.1):
4242
- 1PasswordExtension (= 1.8.5)
4343
- Alamofire (= 4.7.2)
4444
- CocoaLumberjack (= 3.4.2)
@@ -62,7 +62,7 @@ PODS:
6262
- WordPressShared (1.0.8):
6363
- CocoaLumberjack (~> 3.4)
6464
- FormatterKit/TimeIntervalFormatter (= 1.8.2)
65-
- WordPressUI (1.0.5)
65+
- WordPressUI (1.0.6)
6666
- wpxmlrpc (0.8.3)
6767

6868
DEPENDENCIES:
@@ -72,7 +72,7 @@ DEPENDENCIES:
7272
- Crashlytics (~> 3.10)
7373
- Gridicons (= 0.15)
7474
- KeychainAccess (~> 3.1)
75-
- WordPressAuthenticator (from `https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git`, commit `58ed623`)
75+
- WordPressAuthenticator (~> 1.0)
7676

7777
SPEC REPOS:
7878
https://github.com/cocoapods/specs.git:
@@ -92,6 +92,7 @@ SPEC REPOS:
9292
- Reachability
9393
- SVProgressHUD
9494
- UIDeviceIdentifier
95+
- WordPressAuthenticator
9596
- WordPressKit
9697
- WordPressShared
9798
- WordPressUI
@@ -101,25 +102,19 @@ EXTERNAL SOURCES:
101102
Automattic-Tracks-iOS:
102103
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
103104
:tag: 0.2.3
104-
WordPressAuthenticator:
105-
:commit: 58ed623
106-
:git: https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git
107105

108106
CHECKOUT OPTIONS:
109107
Automattic-Tracks-iOS:
110108
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
111109
:tag: 0.2.3
112-
WordPressAuthenticator:
113-
:commit: 58ed623
114-
:git: https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git
115110

116111
SPEC CHECKSUMS:
117112
1PasswordExtension: 0e95bdea64ec8ff2f4f693be5467a09fac42a83d
118113
Alamofire: e4fa87002c137ba2d8d634d2c51fabcda0d5c223
119114
Automattic-Tracks-iOS: d8c6c6c1351b1905a73e45f431b15598d71963b5
120115
CocoaLumberjack: db7cc9e464771f12054c22ff6947c5a58d43a0fd
121-
Crashlytics: 2aea305161a2122492698c75af27f2b98aa49a25
122-
Fabric: fba4684a95df789565b0b27fc5b6e68f1755af32
116+
Crashlytics: 915a7787b84f635fb2a81f92a90e265c2c413f76
117+
Fabric: a2917d3895e4c1569b9c3170de7320ea1b1e6661
123118
FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98
124119
GoogleSignInRepacked: d357702618c555f38923576924661325eb1ef22b
125120
GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
@@ -131,12 +126,12 @@ SPEC CHECKSUMS:
131126
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
132127
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
133128
UIDeviceIdentifier: a959a6d4f51036b4180dd31fb26483a820f1cc46
134-
WordPressAuthenticator: 4c802aa18781858253daf984f873e3efe0dac7ef
129+
WordPressAuthenticator: 60c07bcfb6f1578afaf17621ae4393d688c2ede9
135130
WordPressKit: a24baaa783c3a221f2d9a51c19318cbb27333373
136131
WordPressShared: 063e1e8b1a7aaf635abf17f091a2d235a068abdc
137-
WordPressUI: ab90086350f1e26bf39e578e443d0abf0347e542
132+
WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3
138133
wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4
139134

140-
PODFILE CHECKSUM: b0058ebc467be802babc234b85e02282da5d9d42
135+
PODFILE CHECKSUM: 60104ed4eaf82cee487f83818dceb80f392ce97f
141136

142137
COCOAPODS: 1.5.3

WooCommerce/Classes/AppDelegate.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,18 @@ private extension AppDelegate {
116116
UINavigationBar.appearance().isTranslucent = false
117117
UINavigationBar.appearance().tintColor = .white
118118
UIApplication.shared.statusBarStyle = .lightContent
119+
120+
UIButton.appearance().setTitleColor(StyleManager.wooCommerceBrandColor, for: .normal)
119121
}
120122

121123
/// Sets up FancyButton's UIAppearance.
122124
///
123125
func setupFancyButtonAppearance() {
124126
let appearance = FancyButton.appearance()
125-
appearance.titleFont = UIFont.font(forStyle: .headline, weight: .bold)
126127
appearance.primaryNormalBackgroundColor = StyleManager.buttonPrimaryColor
127128
appearance.primaryNormalBorderColor = StyleManager.buttonPrimaryHighlightedColor
128129
appearance.primaryHighlightBackgroundColor = StyleManager.buttonPrimaryHighlightedColor
129130
appearance.primaryHighlightBorderColor = StyleManager.buttonPrimaryHighlightedColor
130-
appearance.disabledBorderColor = StyleManager.buttonPrimaryHighlightedColor
131-
appearance.disabledBackgroundColor = StyleManager.buttonPrimaryHighlightedColor
132131
}
133132

134133
/// Sets up the WordPress Authenticator.

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,23 @@ class AuthenticationManager {
1919
googleLoginClientId: ApiCredentials.googleClientId,
2020
googleLoginServerClientId: ApiCredentials.googleServerId,
2121
googleLoginScheme: ApiCredentials.googleAuthScheme,
22-
userAgent: UserAgent.defaultUserAgent,
23-
supportNotificationIndicatorFeatureFlag: false)
24-
25-
WordPressAuthenticator.initialize(configuration: configuration)
22+
userAgent: UserAgent.defaultUserAgent)
23+
24+
let style = WordPressAuthenticatorStyle(primaryNormalBackgroundColor: StyleManager.buttonPrimaryColor,
25+
primaryNormalBorderColor: StyleManager.buttonPrimaryHighlightedColor,
26+
primaryHighlightBackgroundColor: StyleManager.buttonPrimaryHighlightedColor,
27+
primaryHighlightBorderColor: StyleManager.buttonPrimaryHighlightedColor,
28+
secondaryNormalBackgroundColor: StyleManager.buttonSecondaryColor,
29+
secondaryNormalBorderColor: StyleManager.buttonSecondaryHighlightedColor,
30+
secondaryHighlightBackgroundColor: StyleManager.buttonSecondaryHighlightedColor,
31+
secondaryHighlightBorderColor: StyleManager.buttonSecondaryHighlightedColor,
32+
disabledBackgroundColor: StyleManager.buttonDisabledColor,
33+
disabledBorderColor: StyleManager.buttonDisabledHighlightedColor,
34+
primaryTitleColor: StyleManager.buttonPrimaryTitleColor,
35+
secondaryTitleColor: StyleManager.buttonSecondaryTitleColor,
36+
disabledTitleColor: StyleManager.buttonDisabledTitleColor)
37+
38+
WordPressAuthenticator.initialize(configuration: configuration, style: style)
2639
WordPressAuthenticator.shared.delegate = self
2740
}
2841

@@ -58,6 +71,14 @@ class AuthenticationManager {
5871
// MARK: - WordPressAuthenticator Delegate
5972
//
6073
extension AuthenticationManager: WordPressAuthenticatorDelegate {
74+
func presentSupportRequest(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) {
75+
// TODO: wire Zendesk
76+
}
77+
78+
func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) {
79+
// TODO: wire Zendesk
80+
}
81+
6182

6283
/// Indicates if the active Authenticator can be dismissed or not.
6384
///

WooCommerce/Classes/Authentication/Prologue/LoginPrologueViewController.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ private extension LoginPrologueViewController {
8282
func setupDisclaimerLabel() {
8383
disclaimerTextView.attributedText = disclaimerAttributedText
8484
disclaimerTextView.textContainerInset = .zero
85+
disclaimerTextView.linkTextAttributes = [
86+
NSAttributedStringKey.foregroundColor.rawValue: StyleManager.wooCommerceBrandColor,
87+
NSAttributedStringKey.underlineColor.rawValue: StyleManager.wooCommerceBrandColor,
88+
NSAttributedStringKey.underlineStyle.rawValue: NSUnderlineStyle.styleSingle.rawValue
89+
]
8590
}
8691

8792
func setupLoginButton() {
@@ -118,8 +123,7 @@ extension LoginPrologueViewController {
118123
/// Proceeds with the Login Flow.
119124
///
120125
@IBAction func loginWasPressed() {
121-
let loginViewController = WordPressAuthenticator.signinForWordPress()
122-
loginViewController.restrictToWPCom = true
126+
let loginViewController = WordPressAuthenticator.signinForWPCom()
123127
loginViewController.offerSignupOption = false
124128

125129
navigationController?.pushViewController(loginViewController, animated: true)
@@ -136,14 +140,16 @@ private extension LoginPrologueViewController {
136140
///
137141
var disclaimerAttributedText: NSAttributedString {
138142
let disclaimerText = NSLocalizedString("This app requires Jetpack to be able to connect to your WooCommerce Store.\nRead the ", comment: "Login Disclaimer Text and Jetpack config instructions")
139-
let disclaimerAttributes: [NSAttributedStringKey: Any] = [
143+
let disclaimerAttributes: [NSAttributedStringKey: Any] = [
140144
.font: UIFont.font(forStyle: .caption1, weight: .thin),
141145
.foregroundColor: UIColor.black
142146
]
143147

144148
let readText = NSLocalizedString("configuration instructions", comment: "Login Disclaimer Linked Text")
145-
var readAttributes = disclaimerAttributes
146-
readAttributes[.link] = URL(string: WooConstants.jetpackSetupUrl)
149+
let readAttributes: [NSAttributedStringKey: Any] = [
150+
.link: URL(string: WooConstants.jetpackSetupUrl) as Any,
151+
.font: UIFont.font(forStyle: .caption1, weight: .thin)
152+
]
147153
let readAttrText = NSMutableAttributedString(string: readText, attributes: readAttributes)
148154

149155
let endSentenceText = "."

WooCommerce/Classes/Authentication/Prologue/LoginPrologueViewController.xib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="o29-Vv-KDs" userLabel="Container View">
3939
<rect key="frame" x="0.0" y="601.66666666666663" width="375" height="176.33333333333337"/>
4040
<subviews>
41-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6pL-xH-OzE" customClass="FancyButton" customModule="WordPressUI">
41+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6pL-xH-OzE" customClass="NUXButton" customModule="WordPressAuthenticator">
4242
<rect key="frame" x="20" y="106.33333333333337" width="335" height="50"/>
4343
<color key="backgroundColor" red="0.58823529409999997" green="0.34509803919999998" blue="0.54117647059999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4444
<constraints>

WooCommerce/Classes/Styles/Style.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ protocol Style {
1717
var sectionTitleColor: UIColor { get }
1818
var buttonPrimaryColor: UIColor { get }
1919
var buttonPrimaryHighlightedColor: UIColor { get }
20+
var buttonPrimaryTitleColor: UIColor { get }
21+
var buttonSecondaryColor: UIColor { get }
22+
var buttonSecondaryHighlightedColor: UIColor { get }
23+
var buttonSecondaryTitleColor: UIColor { get }
24+
var buttonDisabledColor: UIColor { get }
25+
var buttonDisabledHighlightedColor: UIColor { get }
26+
var buttonDisabledTitleColor: UIColor { get }
2027
var cellSeparatorColor: UIColor { get }
2128
var wooGreyMid: UIColor { get }
29+
var alternativeLoginsTitleFont: UIFont { get }
2230
}
2331

2432
// MARK: - WooCommerce's Default Style
@@ -37,8 +45,16 @@ class DefaultStyle: Style {
3745
let sectionTitleColor = UIColor.darkGray
3846
let buttonPrimaryColor = UIColor(red: 0x96/255.0, green: 0x58/255.0, blue: 0x8A/255.0, alpha: 0xFF/255.0)
3947
let buttonPrimaryHighlightedColor = UIColor(red: 0x6E/255.0, green: 0x29/255.0, blue: 0x67/255.0, alpha: 0xFF/255.0)
48+
let buttonPrimaryTitleColor = UIColor.white
49+
let buttonSecondaryColor = UIColor.white
50+
let buttonSecondaryHighlightedColor = UIColor.gray
51+
let buttonSecondaryTitleColor = UIColor.gray
52+
let buttonDisabledColor = UIColor.white
53+
let buttonDisabledHighlightedColor = UIColor(red: 233.0/255.0, green: 239.0/255.0, blue: 234.0/255.0, alpha: 1.0) // equivalent to WPStyle.greyLighten30()
54+
let buttonDisabledTitleColor = UIColor(red: 233.0/255.0, green: 239.0/255.0, blue: 234.0/255.0, alpha: 1.0) // equivalent to WPStyle.greyLighten30()
4055
let cellSeparatorColor = UIColor.lightGray
4156
let wooGreyMid = UIColor(red: 150.0/255.0, green: 150.0/255.0, blue: 150.0/255.0, alpha: 1.0)
57+
let alternativeLoginsTitleFont = UIFont.font(forStyle: .subheadline, weight: .semibold)
4258
}
4359

4460

@@ -111,11 +127,43 @@ class StyleManager {
111127
return active.buttonPrimaryHighlightedColor
112128
}
113129

130+
static var buttonPrimaryTitleColor: UIColor {
131+
return active.buttonPrimaryTitleColor
132+
}
133+
134+
static var buttonSecondaryColor: UIColor {
135+
return active.buttonSecondaryColor
136+
}
137+
138+
static var buttonSecondaryHighlightedColor: UIColor {
139+
return active.buttonSecondaryHighlightedColor
140+
}
141+
142+
static var buttonSecondaryTitleColor: UIColor {
143+
return active.buttonSecondaryTitleColor
144+
}
145+
146+
static var buttonDisabledColor: UIColor {
147+
return active.buttonDisabledColor
148+
}
149+
150+
static var buttonDisabledHighlightedColor: UIColor {
151+
return active.buttonDisabledHighlightedColor
152+
}
153+
154+
static var buttonDisabledTitleColor: UIColor {
155+
return active.buttonDisabledTitleColor
156+
}
157+
114158
static var cellSeparatorColor: UIColor {
115159
return active.cellSeparatorColor
116160
}
117161

118162
static var wooGreyMid: UIColor {
119163
return active.wooGreyMid
120164
}
165+
166+
static var alternativeLoginsTitleFont: UIFont {
167+
return active.alternativeLoginsTitleFont
168+
}
121169
}

0 commit comments

Comments
 (0)