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 possibility of separate text styles extension generation #113

Merged
merged 7 commits into from
Aug 17, 2021

Conversation

ttoxa-xa
Copy link
Contributor

@ttoxa-xa ttoxa-xa commented Aug 13, 2021

Description

In some cases we need to use exported separately from Label, for example - in text field etc.

Changes

Added an optional iOS param labelStyleSwift
Added generation of LabelStyle extensions with factory methods for each style
Make LabelStyle public
Updated CONFIG.md

@ttoxa-xa ttoxa-xa closed this Aug 13, 2021
@ttoxa-xa ttoxa-xa reopened this Aug 13, 2021
Copy link
Collaborator

@subdan subdan left a comment

Choose a reason for hiding this comment

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

  1. Fix unit-tests.
  2. Rename LabelStyle+Extension.swift to LabelStyle+extension.swift for consistency.
  3. Fix code duplication. You create LabelStyle for the same text style two times:

here:

public extension LabelStyle {
    
    static func body() -> LabelStyle {
        LabelStyle(
            font: UIFont.body(),
            fontMetrics: UIFontMetrics(forTextStyle: .body),
            lineHeight: 24.0
        )
    }
    ...

and here:

public final class BodyLabel: Label {

    override var style: LabelStyle? {
        LabelStyle(
            font: UIFont.body(),
            fontMetrics: UIFontMetrics(forTextStyle: .body),
            lineHeight: 24.0
        )
    }
}

For each *Label class just call static method of LabelStyle extension.

public final class BodyLabel: Label {

    override var style: LabelStyle? {
        .body()
    }
}

@ttoxa-xa ttoxa-xa requested a review from subdan August 17, 2021 07:26
@subdan subdan merged commit 0298a0d into RedMadRobot:master Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants