-
Notifications
You must be signed in to change notification settings - Fork 206
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
[iOS] ♻️ Use the defined Typography on each screen. #1178
Conversation
…dled differently between Android and iOS.
import SwiftUI | ||
|
||
public extension Text { | ||
func textStyle(_ style: TextStyle) -> some View { | ||
return self.font(style.font) | ||
.lineSpacing(style.lineHeight) | ||
.modifier(LetterSpacingModifier(spacing: style.letterSpacing ?? 0)) | ||
} | ||
} | ||
|
||
public struct LetterSpacingModifier: ViewModifier { | ||
var spacing: CGFloat | ||
public func body(content: Content) -> some View { | ||
content.padding(.leading, spacing/2) | ||
.padding(.trailing, spacing/2) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An extension function to handle TextStyle defined in Typography has been added this time.
public static let bodyLarge = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 16), lineHeight: 24, letterSpacing: 0.15) | ||
public static let bodyMedium = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 14), lineHeight: 20, letterSpacing: 0.25) | ||
public static let bodySmall = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 12), lineHeight: 16, letterSpacing: 0.4) | ||
public static let displayLarge = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 57), lineHeight: 64 - 57) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of iOS, if the lineHeight value is used as it is, the display will be corrupted, so we have changed to use the value obtained by subtracting the lineHeight value from the Font size.
public static let bodyLarge = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 16), lineHeight: 24, letterSpacing: 0.15) | ||
public static let bodyMedium = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 14), lineHeight: 20, letterSpacing: 0.25) | ||
public static let bodySmall = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 12), lineHeight: 16, letterSpacing: 0.4) | ||
public static let displayLarge = TextStyle(font: SwiftUI.Font.custom("Montserrat-Regular", size: 57), lineHeight: 64 - 57) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed my review comment 🙏🏼
Can you apply this for all vairables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ry-itto
Sorry if I am wrong in my perception. 🙇
I only commented on one area, but I have already corrected all the variables this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Corvus400
My review comment is bad.. (That review comment has two meanings..)
What I want to say is "using static access to font name might be better way". 🙏🏼
Like this
FontAssets.Montserrat.regular.font(size: 57)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content.padding(.leading, spacing/2) | ||
.padding(.trailing, spacing/2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.horizontal
might be a better way. 👀 And maybe this modifier not needed if this line uses .horizontal
.
content.padding(.leading, spacing/2) | |
.padding(.trailing, spacing/2) | |
content.padding(.horizontal, spacing / 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks! 👍🏼
Issue
Overview (Required)
Movie (Optional)