diff --git a/Sources/Orbit/Components/Icon.swift b/Sources/Orbit/Components/Icon.swift index e4c04a6590d..4f67d8c1b3b 100644 --- a/Sources/Orbit/Components/Icon.swift +++ b/Sources/Orbit/Components/Icon.swift @@ -64,8 +64,10 @@ public struct Icon: View, TextBuildable, PotentiallyEmptyView { @Environment(\.iconColor) private var iconColor @Environment(\.iconSize) private var iconSize + @Environment(\.lineSpacing) private var lineSpacing @Environment(\.locale) private var locale @Environment(\.localizationBundle) private var localizationBundle + @Environment(\.multilineTextAlignment) private var multilineTextAlignment @Environment(\.textColor) private var textColor @Environment(\.textFontWeight) private var textFontWeight @Environment(\.textSize) private var textSize @@ -112,11 +114,13 @@ public struct Icon: View, TextBuildable, PotentiallyEmptyView { .init( iconColor: iconColor, iconSize: iconSize, + lineSpacing: lineSpacing, locale: locale, localizationBundle: localizationBundle, textAccentColor: nil, + textAlignment: multilineTextAlignment, textColor: textColor, - textFontWeight: textFontWeight, + textFontWeight: textFontWeight, textLineHeight: nil, textSize: textSize, sizeCategory: sizeCategory diff --git a/Sources/Orbit/Components/Text.swift b/Sources/Orbit/Components/Text.swift index dc3b0051274..63c50d5fc68 100644 --- a/Sources/Orbit/Components/Text.swift +++ b/Sources/Orbit/Components/Text.swift @@ -200,9 +200,11 @@ public struct Text: View, FormattedTextBuildable, PotentiallyEmptyView, CustomSt .init( iconColor: nil, iconSize: nil, + lineSpacing: lineSpacing, locale: locale, localizationBundle: localizationBundle, textAccentColor: textAccentColor, + textAlignment: multilineTextAlignment, textColor: textColor, textFontWeight: textFontWeight, textLineHeight: lineHeight, @@ -331,7 +333,7 @@ public struct Text: View, FormattedTextBuildable, PotentiallyEmptyView, CustomSt ) -> NSAttributedString { TagAttributedStringBuilder.all.attributedString( content(environment), - alignment: multilineTextAlignment, + alignment: environment.textAlignment ?? .leading, fontSize: environment.scaledSize(size), fontWeight: environment.resolvedFontWeight(fontWeight, isBold: isBold), lineSpacing: lineSpacingAdjusted(environment: environment), @@ -343,7 +345,7 @@ public struct Text: View, FormattedTextBuildable, PotentiallyEmptyView, CustomSt } private func lineSpacingAdjusted(environment: TextRepresentableEnvironment) -> CGFloat { - environment.lineSpacingAdjusted(lineSpacing, lineHeight: lineHeight, size: size) + environment.lineSpacingAdjusted(environment.lineSpacing ?? 0, lineHeight: lineHeight, size: size) } private init(localization: TextLocalization?, description: String) { diff --git a/Sources/Orbit/Support/Text/ConcatenatedText.swift b/Sources/Orbit/Support/Text/ConcatenatedText.swift index 756f39a37ce..9814437353b 100644 --- a/Sources/Orbit/Support/Text/ConcatenatedText.swift +++ b/Sources/Orbit/Support/Text/ConcatenatedText.swift @@ -7,6 +7,7 @@ struct ConcatenatedText: View { @Environment(\.lineSpacing) var lineSpacing @Environment(\.locale) var locale @Environment(\.localizationBundle) var localizationBundle + @Environment(\.multilineTextAlignment) var multilineTextAlignment @Environment(\.sizeCategory) var sizeCategory @Environment(\.textAccentColor) var textAccentColor @Environment(\.textColor) var textColor @@ -34,9 +35,11 @@ struct ConcatenatedText: View { .init( iconColor: iconColor, iconSize: iconSize, + lineSpacing: lineSpacing, locale: locale, localizationBundle: localizationBundle, textAccentColor: textAccentColor, + textAlignment: multilineTextAlignment, textColor: textColor, textFontWeight: textFontWeight, textLineHeight: textLineHeight, diff --git a/Sources/Orbit/Support/Text/TextRepresentable.swift b/Sources/Orbit/Support/Text/TextRepresentable.swift index f1f64ae9bba..faf85e6523a 100644 --- a/Sources/Orbit/Support/Text/TextRepresentable.swift +++ b/Sources/Orbit/Support/Text/TextRepresentable.swift @@ -14,9 +14,11 @@ public struct TextRepresentableEnvironment { public let iconColor: Color? public let iconSize: CGFloat? + public let lineSpacing: CGFloat? public let locale: Locale public let localizationBundle: Bundle public let textAccentColor: Color? + public let textAlignment: TextAlignment? public let textColor: Color? public let textFontWeight: Font.Weight? public let textLineHeight: CGFloat? @@ -26,9 +28,11 @@ public struct TextRepresentableEnvironment { public init( iconColor: Color?, iconSize: CGFloat?, + lineSpacing: CGFloat?, locale: Locale, localizationBundle: Bundle, textAccentColor: Color?, + textAlignment: TextAlignment?, textColor: Color?, textFontWeight: Font.Weight?, textLineHeight: CGFloat?, @@ -37,9 +41,11 @@ public struct TextRepresentableEnvironment { ) { self.iconColor = iconColor self.iconSize = iconSize + self.lineSpacing = lineSpacing self.locale = locale self.localizationBundle = localizationBundle self.textAccentColor = textAccentColor + self.textAlignment = textAlignment self.textColor = textColor self.textFontWeight = textFontWeight self.textLineHeight = textLineHeight @@ -51,9 +57,11 @@ public struct TextRepresentableEnvironment { public init(locale: Locale, localizationBundle: Bundle) { self.iconColor = nil self.iconSize = nil + self.lineSpacing = nil self.locale = locale self.localizationBundle = localizationBundle self.textAccentColor = nil + self.textAlignment = nil self.textColor = nil self.textFontWeight = nil self.textLineHeight = nil