Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPressAuthenticator.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressAuthenticator"
s.version = "1.6.0-beta.2"
s.version = "1.7.0-beta.1"
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."

s.description = <<-DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public struct WordPressAuthenticatorStyle {

/// Style: Text Buttons
///
public let textButton: UIColor
public let textButtonColor: UIColor

public let textButtonHighlight: UIColor
public let textButtonHighlightColor: UIColor

/// Style: Labels
///
Expand Down Expand Up @@ -71,7 +71,7 @@ public struct WordPressAuthenticatorStyle {

/// 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, textButton: UIColor, textButtonHighlight: UIColor, instructionColor: UIColor, subheadlineColor: UIColor, placeholderColor: UIColor, viewControllerBackgroundColor: UIColor, navBarImage: UIImage, prologueBackgroundColor: UIColor = WPStyleGuide.wordPressBlue(), prologueTitleColor: UIColor = .white) {
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, textButtonColor: UIColor, textButtonHighlightColor: UIColor, instructionColor: UIColor, subheadlineColor: UIColor, placeholderColor: UIColor, viewControllerBackgroundColor: UIColor, navBarImage: UIImage, prologueBackgroundColor: UIColor = WPStyleGuide.wordPressBlue(), prologueTitleColor: UIColor = .white) {
self.primaryNormalBackgroundColor = primaryNormalBackgroundColor
self.primaryNormalBorderColor = primaryNormalBorderColor
self.primaryHighlightBackgroundColor = primaryHighlightBackgroundColor
Expand All @@ -85,8 +85,8 @@ public struct WordPressAuthenticatorStyle {
self.primaryTitleColor = primaryTitleColor
self.secondaryTitleColor = secondaryTitleColor
self.disabledTitleColor = disabledTitleColor
self.textButton = textButton
self.textButtonHighlight = textButtonHighlight
self.textButtonColor = textButtonColor
self.textButtonHighlightColor = textButtonHighlightColor
self.instructionColor = instructionColor
self.subheadlineColor = subheadlineColor
self.placeholderColor = placeholderColor
Expand Down
14 changes: 7 additions & 7 deletions WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ final class SubheadlineButton: UIButton {
super.traitCollectionDidChange(previousTraitCollection)
if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory {
titleLabel?.font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)
setTitleColor(WordPressAuthenticator.shared.style.textButton, for: .normal)
setTitleColor(WordPressAuthenticator.shared.style.textButtonHighlight, for: .highlighted)
setTitleColor(WordPressAuthenticator.shared.style.textButtonColor, for: .normal)
setTitleColor(WordPressAuthenticator.shared.style.textButtonHighlightColor, for: .highlighted)
}
}
}
Expand Down Expand Up @@ -104,8 +104,8 @@ extension WPStyleGuide {
class func googleLoginButton() -> UIButton {
let baseString = NSLocalizedString("{G} Log in with Google.", comment: "Label for button to log in using Google. The {G} will be replaced with the Google logo.")

let attrStrNormal = googleButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButton)
let attrStrHighlight = googleButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButtonHighlight)
let attrStrNormal = googleButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButtonColor)
let attrStrHighlight = googleButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButtonHighlightColor)

let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)

Expand All @@ -119,8 +119,8 @@ extension WPStyleGuide {
class func selfHostedLoginButton() -> UIButton {
let baseString = NSLocalizedString("Log in by entering your site address.", comment: "Label for button to log in using your site address.")

let attrStrNormal = selfHostedButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButton)
let attrStrHighlight = selfHostedButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButtonHighlight)
let attrStrNormal = selfHostedButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButtonColor)
let attrStrHighlight = selfHostedButtonString(baseString, linkColor: WordPressAuthenticator.shared.style.textButtonHighlightColor)

let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)

Expand Down Expand Up @@ -211,7 +211,7 @@ extension WPStyleGuide {

let labelString = NSMutableAttributedString(string: "")

if let originalDomainsIcon = Gridicon.iconOfType(.domains).imageWithTintColor(WPStyleGuide.greyLighten10()) {
if let originalDomainsIcon = Gridicon.iconOfType(.domains).imageWithTintColor(WordPressAuthenticator.shared.style.placeholderColor) {
var domainsIcon = originalDomainsIcon.cropping(to: CGRect(x: Constants.domainsIconPaddingToRemove,
y: Constants.domainsIconPaddingToRemove,
width: originalDomainsIcon.size.width - Constants.domainsIconPaddingToRemove * 2,
Expand Down
2 changes: 0 additions & 2 deletions WordPressAuthenticator/NUX/WPWalkthroughTextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ IB_DESIGNABLE
@property (nonatomic) IBInspectable BOOL showTopLineSeparator;
@property (nonatomic) IBInspectable BOOL showSecureTextEntryToggle;
@property (nonatomic) IBInspectable UIImage *leftViewImage;
@property (nonatomic, strong) UIButton *secureTextEntryToggle;

/// Width for the left view. Set to 0 to use the given frame in the view.
/// Default is: 30
Expand Down Expand Up @@ -39,6 +38,5 @@ IB_DESIGNABLE
@property (nonatomic) UIEdgeInsets contentInsets;

- (instancetype)initWithLeftViewImage:(UIImage *)image;
- (void)setupPlaceholder;

@end
8 changes: 3 additions & 5 deletions WordPressAuthenticator/NUX/WPWalkthroughTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import Gridicons;

@interface WPWalkthroughTextField ()
@property (nonatomic, strong) UIButton *secureTextEntryToggle;
@property (nonatomic, strong) UIImage *secureTextEntryImageVisible;
@property (nonatomic, strong) UIImage *secureTextEntryImageHidden;
@end
Expand Down Expand Up @@ -85,13 +86,9 @@ - (void)commonInit
self.showTopLineSeparator = NO;
self.showSecureTextEntryToggle = NO;

[self setupPlaceholder];
}

- (void)setupPlaceholder
{
// Apply styles to the placeholder if one was set in IB.
if (self.placeholder) {
// colors here are overridden in LoginTextField
NSDictionary *attributes = @{
NSForegroundColorAttributeName : WPStyleGuide.greyLighten10,
NSFontAttributeName : self.font,
Expand All @@ -114,6 +111,7 @@ - (void)configureSecureTextEntryToggle {

self.secureTextEntryToggle = [UIButton buttonWithType:UIButtonTypeCustom];
self.secureTextEntryToggle.clipsToBounds = true;
// colors here are overridden in LoginTextField
self.secureTextEntryToggle.tintColor = [WPStyleGuide greyLighten10];
[self.secureTextEntryToggle addTarget:self action:@selector(secureTextEntryToggleAction:) forControlEvents:UIControlEventTouchUpInside];

Expand Down
1 change: 1 addition & 0 deletions WordPressAuthenticator/Signin/Login.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@
<rect key="frame" x="0.0" y="44" width="383" height="44"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="passwordField"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" returnKeyType="next" enablesReturnKeyAutomatically="YES" secureTextEntry="YES" textContentType="one-time-code"/>
<userDefinedRuntimeAttributes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class LoginPrologueSignupMethodViewController: NUXViewController {
self?.present(safariViewController, animated: true, completion: nil)
}
buttonViewController.stackView?.insertArrangedSubview(termsButton, at: 0)
buttonViewController.backgroundColor = WPStyleGuide.lightGrey()
buttonViewController.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
}

@IBAction func dismissTapped() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class LoginPrologueViewController: LoginViewController {
self?.dismiss(animated: true, completion: nil)
}
}
buttonViewController.backgroundColor = WPStyleGuide.lightGrey()
buttonViewController.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
}

// MARK: - Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class LoginSelfHostedViewController: LoginViewController, NUXKeyboardResponder {
siteHeaderView.subtitleIsHidden = true

siteHeaderView.blavatarBorderIsHidden = true
siteHeaderView.blavatarImage = .linkFieldImage
siteHeaderView.blavatarImage = UIImage.linkFieldImage.imageWithTintColor(WordPressAuthenticator.shared.style.placeholderColor)
}


Expand Down
2 changes: 1 addition & 1 deletion WordPressAuthenticator/Signin/LoginSocialErrorCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ open class LoginSocialErrorCell: UITableViewCell {
descriptionLabel.text = errorDescription
}

backgroundColor = WPStyleGuide.greyLighten30()
backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class LoginSocialErrorViewController: NUXTableViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = WPStyleGuide.greyLighten30()
view.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
addWordPressLogoToNavController()
}

Expand Down Expand Up @@ -140,7 +140,7 @@ extension LoginSocialErrorViewController {

override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let footer = UIView()
footer.backgroundColor = WPStyleGuide.greyLighten20()
footer.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
return footer
}

Expand Down
28 changes: 12 additions & 16 deletions WordPressAuthenticator/UI/LoginTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import WordPressShared

open class LoginTextField: WPWalkthroughTextField {

override open func awakeFromNib() {
super.awakeFromNib()
guard let secureTextEntryToggle = secureTextEntryToggle else {
return
}
secureTextEntryToggle.tintColor = WordPressAuthenticator.shared.style.placeholderColor
}

override open func draw(_ rect: CGRect) {
if showTopLineSeparator {
guard let context = UIGraphicsGetCurrentContext() else {
Expand All @@ -22,15 +14,19 @@ open class LoginTextField: WPWalkthroughTextField {
}
}

override open func setupPlaceholder() {
guard let placeholder = placeholder else {
return
override open var placeholder: String? {
didSet {
guard let placeholder = placeholder,
let font = font else {
return
}

let attributes: [NSAttributedString.Key : Any] = [
.foregroundColor: WordPressAuthenticator.shared.style.placeholderColor,
.font: font
]
attributedPlaceholder = NSAttributedString(string: placeholder, attributes: attributes)
}
let attributes: [NSAttributedString.Key: Any] = [
.foregroundColor: WordPressAuthenticator.shared.style.placeholderColor,
.font: font
]
self.attributedPlaceholder = NSAttributedString(string: placeholder, attributes: attributes)
}

override open var leftViewImage: UIImage! {
Expand Down
5 changes: 3 additions & 2 deletions WordPressAuthenticator/UI/SearchTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ open class SearchTableViewCell: UITableViewCell {
textField.returnKeyType = .search
textField.contentInsets = Constants.textInsetsWithIcon
textField.accessibilityIdentifier = "Search field"
textField.leftViewImage = textField?.leftViewImage?.imageWithTintColor(Constants.leftImageTintColor)
textField.leftViewImage = textField?.leftViewImage?.imageWithTintColor(WordPressAuthenticator.shared.style.placeholderColor)

contentView.backgroundColor = WordPressAuthenticator.shared.style.viewControllerBackgroundColor
}
}

Expand All @@ -57,7 +59,6 @@ open class SearchTableViewCell: UITableViewCell {
private extension SearchTableViewCell {
enum Constants {
static let textInsetsWithIcon = WPStyleGuide.edgeInsetForLoginTextFields()
static let leftImageTintColor = WPStyleGuide.grey()
}
}

Expand Down
4 changes: 2 additions & 2 deletions WordPressAuthenticator/UI/SiteInfoHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ private extension SiteInfoHeaderView {
blavatarImageView.layer.borderWidth = 0
blavatarImageView.tintColor = .clear
} else {
blavatarImageView.layer.borderColor = WPStyleGuide.greyLighten20().cgColor
blavatarImageView.layer.borderColor = WordPressAuthenticator.shared.style.instructionColor.cgColor
blavatarImageView.layer.borderWidth = 1
blavatarImageView.tintColor = WPStyleGuide.greyLighten10()
blavatarImageView.tintColor = WordPressAuthenticator.shared.style.placeholderColor
}
}
}