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

Conversation

@jleandroperez
Copy link
Contributor

@jleandroperez jleandroperez commented Jul 5, 2018

Resubmitting #7 (by @mindgraffiti)

Not sure how the former one got closed (apparently, happened automatically after i've deleted new-woo-apis).

I'm pasting, below, the former PR's description.


⚠️ The secondary button's default configurations have not been tested against the original button designs for WPiOS. Since it's branched from new-woo-apis it isn't compatible with WPiOS just yet and was breaking when I attempted to test the secondary button. fully tested and compatible ✅

This PR makes the NUXButton configurable using UIAppearance. To run a full test, check out the WCiOS PR instructions.

Copy link
Contributor Author

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti Few comments, looking great!

var frm = activityIndicator.frame
frm.origin.x = (frame.width - frm.width) / 2.0
frm.origin.y = (frame.height - frm.height) / 2.0
activityIndicator.frame = frm
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activityIndicator.frame = frm.integral

Reason: floating positions don't really exist (the screen requires integer coordinates). Anything that has a comma value results in a blurry view.

cc @mindgraffiti

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing. x, y, and frame all accept CGFloat values. Why do they make it like that if they really want ints?

Copy link
Contributor Author

@jleandroperez jleandroperez Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti actually, my explanation was wrong. Lemme rephrase: positions are expressed in terms of Points, not Pixels. The problem is:

  • Non Retina Devices: PositionX = 0.5 maps to half a pixel in the X axis
  • @2x Devices: PositionX = 0.5 maps to one pixel
  • @3x Devices: Position X = 0.5 maps to one pixel and a half

Any "Pixel Position" that's not integral, when rendered, gets antialias applied. Which is why you usually wanna avoid non integral positions (because they may look blurry).

Exception is: when you're actually calculating things, so it maps to integral pixels. Sometimes you may wanna draw a line 1 pixel width, and there are super simple ways to do so.

A little bit more about this here.

static let normalBackgroundColor = UIColor.white
static let normalBorderColor = WPStyleGuide.greyLighten20()
static let highlightBackgroundColor = WPStyleGuide.greyLighten20()
static let highlightBorderColor = highlightBackgroundColor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti shouldn't all of the values here come from the new Style struct? (Primary.*Color / Secondary.*Color)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

struct Title {
static let primaryColor = UIColor.white
static let secondaryColor = WPStyleGuide.darkGrey()
static let disabledColor = WPStyleGuide.greyLighten30()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above: Shouldn't these come from the new Style struct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@jleandroperez jleandroperez added the enhancement New feature or request label Jul 5, 2018

/// Alternative logins highlight color
///
let highlightColor: UIColor
Copy link
Contributor Author

@jleandroperez jleandroperez Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set linkColor and highlightColor as public, otherwise they won't be accessible from outside the framework.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

}

public extension WordPressAuthenticatorStyle {
static var defaultStyle: WordPressAuthenticatorStyle {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti please set to public

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

/// Initializes the WordPressAuthenticator with the specified Configuration.
///
public static func initialize(configuration: WordPressAuthenticatorConfiguration) {
public static func initialize(configuration: WordPressAuthenticatorConfiguration, style: WordPressAuthenticatorStyle) {
Copy link
Contributor Author

@jleandroperez jleandroperez Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti Can we have style: WordPressAuthenticatorStyle = .defaultStyle ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

import WordPressUI

/// A protocol for an element that can display a UIActivityIndicatorView
@objc public protocol ActivityIndicatorButton {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti since the protocol ActivityIndicatorButton isn't really used anywhere (there are no ivars / vars anywhere with that specific Type), can we nuke it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

fileprivate let maxFontSize: CGFloat = 22
@objc open class NUXButton: UIButton, ActivityIndicatorButton {
@objc var isAnimating: Bool {
get {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti you can drop the get { } block. If a property is readOnly, you can just do something like this:

var isAnimating: Bool {
   return activityIndicator.isAnimating
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@@ -1,20 +1,5 @@
PODS:
- 1PasswordExtension (1.8.5)
- AFNetworking (3.2.1):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why the Podfile changes so much without Podfile changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's due to all the mucking about I did with making some of the pods local. I think I need to pull the original Podfile and Podfile.lock and overwrite the changes made in my PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been working on nuking AFNetworking (with Sergio) during last Hack Week, from WordPressKit. This change is just (or should be!!) a side effect of running pod install.

No need to bring back the old Podfile.lock, this is a beautiful thing actually!!! (one less dependency).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. 👍

Copy link
Contributor

@nheagy nheagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really interested to see how these work in WPiOS—code cleanup in that area sounds great.

I think we should holdoff on merging this until the WPiOS implementation is available. Let me know if you think otherwise.

/// A stylized button used by Login controllers. It also can display a `UIActivityIndicatorView`.
@objc open class NUXButton: NUXSubmitButton {
// MARK: - Configuration
fileprivate let horizontalInset: CGFloat = 20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where'd these config values go?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They moved to here: https://github.com/wordpress-mobile/WordPressUI-iOS/blob/develop/WordPressUI/Extensions/UIImage%2BAssets.swift#L87

The NUXButton was using the same sizing and configurations as FancyButton, so I moved the definitions out of FancyButton and into the UIImage+Assets extension. This PR has more details wordpress-mobile/WordPressUI-iOS#8

@mindgraffiti mindgraffiti self-assigned this Jul 5, 2018
@mindgraffiti
Copy link
Contributor

I think we should holdoff on merging this until the WPiOS implementation is available. Let me know if you think otherwise.

Agreed! I want to thoroughly test this now that the new-woo-apis branch has been integrated. Was looking for some initial impressions on the work so far, to make sure I'm on the right track.

Copy link
Contributor Author

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti looks great!! few nipticky comments. I'll get to testing the WCiOS Integration PR!!

super.traitCollectionDidChange(previousTraitCollection)
if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory {
titleLabel?.font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)
titleLabel?.textColor = WPStyleGuide.wordPressBlue()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti since Woo is using this, shouldn't we probably grab this one from the Style struct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@@ -1,20 +1,5 @@
PODS:
- 1PasswordExtension (1.8.5)
- AFNetworking (3.2.1):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been working on nuking AFNetworking (with Sergio) during last Hack Week, from WordPressKit. This change is just (or should be!!) a side effect of running pod install.

No need to bring back the old Podfile.lock, this is a beautiful thing actually!!! (one less dependency).

}
}


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ this change!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

setBackgroundImage(highlightedImage, for: .highlighted)
setBackgroundImage(disabledImage, for: .disabled)

activityIndicator.activityIndicatorViewStyle = .gray
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should go into configureActivityIndicator() (since it's not really a Background?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

frm.origin.x = (frame.width - frm.width) / 2.0
frm.origin.y = (frame.height - frm.height) / 2.0
activityIndicator.frame = frm.integral
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!! but now that i realize about it: why not just Autolayout? (centerXAnchor / centerYAnchor)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm drawing the line here. Need to get this PR closed. :)

Copy link
Contributor Author

@jleandroperez jleandroperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindgraffiti looking great overall!!. Added just one important comment. Switching to WPiOS testing as of now, will get back to this one in a bit


/// Setup: shorter reference for style
///
private let style = WordPressAuthenticator.shared.style
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typealias Style = WordPressAuthenticator.shared.style

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: Static var 'shared' is not a member type of 'WordPressAuthenticator'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhhhhhh right, it's not a type!!!. My apologies!!. Only alternative is having this as a calculated property. But "meh", really no difference in there.

Sorry about the fuzz!!

}

override open func configureBorderColor() {
struct Metrics {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be private

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

}
configureBackgrounds()
configureTitleColors()
activityIndicator.activityIndicatorViewStyle = .gray
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably wanna move these three lines (configureBackgrounds, configureTitleColors and configureActivityIndicator) elsewhere. Perhaps to awakeFromNib.

Reason: Each time you call this, configureBackgrounds will re-add the activityIndicator as a subview. This should probably print a warning or so, but it's something we should run just once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@mindgraffiti mindgraffiti removed their request for review July 9, 2018 17:10
Copy link
Contributor

@nheagy nheagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, @mindgraffiti let's go!

:shipit:

@mindgraffiti mindgraffiti merged commit 0554279 into develop Jul 10, 2018
@mindgraffiti mindgraffiti deleted the feature/nux-button-appearance branch July 10, 2018 20:26
@mindgraffiti
Copy link
Contributor

Thank you for helping me out with the NUXButton @nheagy!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants