Skip to content

Commit

Permalink
style: add comments and GitHub issues references for typography modif…
Browse files Browse the repository at this point in the history
…ier (#347) (#348)

We are waitning for information from the design team about the use of line height and letter spacing tokens.
The source code now reflects the situation.

Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Dec 11, 2024
1 parent a18ee43 commit 1b4ba09
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,29 @@ struct TypographyModifier: ViewModifier {
}
}

// TODO: #51 - Call lineSpacing() and tracking() functions when values usable in FontRawTokens
/// Applies to the `Content` the *adaptive font* (i.e. *font family*, *font weight* and *font size*
/// depending to the current `MultipleFontCompositeRawTokens`.
/// **Does not apply _letter spacing_ nor _line height_ because raw tokens values are not usable!**
/// **Does not apply _letter spacing_ nor _line height_ yet!**
/// See:
/// - https://github.com/Orange-OpenSource/ouds-ios/issues/347
/// - https://github.com/Orange-OpenSource/ouds-ios/issues/348
func body(content: Content) -> some View {
// `tracking()` and `kerning()` only available for iOS 16+
// `minimumScaleFactor()` ensures text remains readable by allowing scaling down
// `.onChange(of: sizeCategory) { _ in }` triggers view update when Dynamic Type size changes
if #available(iOS 16.0, *) {
content
.font(adaptiveTypography())
.minimumScaleFactor(0.5) /// Ensures text remains readable by allowing scaling down
.onChange(of: sizeCategory) { _ in } /// Triggers view update when Dynamic Type size changes
// .lineSpacing(adaptiveTypography.lineHeight)
// .tracking(adaptiveTypography.letterSpacing)
} else { // tracking() and kerning() only available for iOS 16+
.minimumScaleFactor(0.5)
.onChange(of: sizeCategory) { _ in }
// Apply .lineSpacing() with expected value (see #348)
// Apply .tracking() or .kerning() (ese #347)
} else {
content
.font(adaptiveTypography())
.minimumScaleFactor(0.5) /// Ensures text remains readable by allowing scaling down
.onChange(of: sizeCategory) { _ in } /// Triggers view update when Dynamic Type size changes
// .lineSpacing(adaptiveTypography.lineHeight)
.minimumScaleFactor(0.5)
.onChange(of: sizeCategory) { _ in }
// Apply .lineSpacing() with expected value (see #348)
}
}
}
Expand Down

0 comments on commit 1b4ba09

Please sign in to comment.