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

Added factory functions for creating TextStyles based off existing values #18

Closed
wants to merge 11 commits into from

Conversation

hkellaway
Copy link

  • Added factory functions for creating new TextStyles based on existing values (e.g. textStyle.with(newTextColor:)
  • Added factory function for create TextStyle with new font size
  • Added factory functions for creating new TextStyle with bold/italic as font
  • Updated TextStyle and TextTransform to be Equatable
  • Tests for factory functions and equality

XCTAssertEqual(capitalized, capitalized)
}

func testTextStyle_isNotEqual_whenCustom() {
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 kinda weird and I don't think there is really a good way to test equality for functions. Can you leave a comment noting this in the file where you are doing Equatable conformation?

/// - Parameter color: Underline color. Defaults to textColor.
/// - Parameter style: Underline style. Defaults to single line.
/// - Returns: New TextStyle with underline.
public func underlined(color: UIColor? = nil, style: NSUnderlineStyle = .styleSingle) -> TextStyle {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should create individual functions for bold, italic and underlined... It might lead us down to a rabbit hole that we might not necessarily wanna go down.

let strikethroughColorToUse = (newStrikethroughColor == nil) ? self.strikethroughColor : newStrikethroughColor!
let underlineStyleToUse = (newUnderlineStyle == nil) ? self.underlineStyle : newUnderlineStyle!
let underlineColorToUse = (newUnderlineColor == nil) ? self.underlineColor : newUnderlineColor!
let textTransformToUse = (newTextTransform == nil) ? self.textTransform : newTextTransform!
Copy link
Contributor

Choose a reason for hiding this comment

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

Would using ?? operator make these slightly nicer to read?

@htinlinn
Copy link
Contributor

Closing this and reopening a new PR based on the latest master changes in #21...

@htinlinn htinlinn closed this Jul 19, 2017
@htinlinn htinlinn deleted the feature/factory_functions branch July 19, 2017 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants