|
| 1 | +// |
| 2 | +// Text+Encapsulation.swift |
| 3 | +// OpenSwiftUICore |
| 4 | +// |
| 5 | +// Audited for 6.5.4 |
| 6 | +// Status: Complete |
| 7 | + |
| 8 | +public import OpenCoreGraphicsShims |
| 9 | +import UIFoundation_Private |
| 10 | + |
| 11 | +@_spi(Private) |
| 12 | +@available(OpenSwiftUI_v4_0, *) |
| 13 | +extension Text { |
| 14 | + public struct Encapsulation: Hashable, Sendable { |
| 15 | + var scale: Scale? |
| 16 | + var shape: Shape? |
| 17 | + var style: Style? |
| 18 | + var lineWeight: CGFloat? |
| 19 | + var color: Color? |
| 20 | + var minimumWidth: CGFloat? |
| 21 | + var platterSize: PlatterSize? |
| 22 | + |
| 23 | + @_disfavoredOverload |
| 24 | + public init( |
| 25 | + scale: Text.Encapsulation.Scale? = nil, |
| 26 | + shape: Text.Encapsulation.Shape? = nil, |
| 27 | + style: Text.Encapsulation.Style? = nil, |
| 28 | + lineWeight: CGFloat? = nil, |
| 29 | + color: Color? = nil, |
| 30 | + minimumWidth: CGFloat? = nil |
| 31 | + ) { |
| 32 | + self.scale = scale |
| 33 | + self.shape = shape |
| 34 | + self.style = style |
| 35 | + self.lineWeight = lineWeight |
| 36 | + self.color = color |
| 37 | + self.minimumWidth = minimumWidth |
| 38 | + } |
| 39 | + |
| 40 | + @available(OpenSwiftUI_v5_0, *) |
| 41 | + public init( |
| 42 | + scale: Text.Encapsulation.Scale? = nil, |
| 43 | + shape: Text.Encapsulation.Shape? = nil, |
| 44 | + style: Text.Encapsulation.Style? = nil, |
| 45 | + platterSize: Text.Encapsulation.PlatterSize? = nil, |
| 46 | + lineWeight: CGFloat? = nil, |
| 47 | + color: Color? = nil, |
| 48 | + minimumWidth: CGFloat? = nil |
| 49 | + ) { |
| 50 | + self.scale = scale |
| 51 | + self.shape = shape |
| 52 | + self.style = style |
| 53 | + self.platterSize = platterSize |
| 54 | + self.lineWeight = lineWeight |
| 55 | + self.color = color |
| 56 | + self.minimumWidth = minimumWidth |
| 57 | + } |
| 58 | + |
| 59 | + public struct Scale: Hashable, Sendable { |
| 60 | + let nsScale: NSTextEncapsulationScale |
| 61 | + |
| 62 | + public static let small: Text.Encapsulation.Scale = .init(nsScale: .small) |
| 63 | + |
| 64 | + public static let medium: Text.Encapsulation.Scale = .init(nsScale: .medium) |
| 65 | + |
| 66 | + public static let large: Text.Encapsulation.Scale = .init(nsScale: .large) |
| 67 | + } |
| 68 | + |
| 69 | + public struct Shape: Hashable, Sendable { |
| 70 | + let nsShape: NSTextEncapsulationShape |
| 71 | + |
| 72 | + public static let rectangle: Text.Encapsulation.Shape = .init(nsShape: .rectangle) |
| 73 | + |
| 74 | + public static let roundedRectangle: Text.Encapsulation.Shape = .init(nsShape: .roundedRectangle) |
| 75 | + |
| 76 | + public static let capsule: Text.Encapsulation.Shape = .init(nsShape: .capsule) |
| 77 | + } |
| 78 | + |
| 79 | + public struct Style: Hashable, Sendable { |
| 80 | + let nsStyle: NSTextEncapsulationStyle |
| 81 | + |
| 82 | + public static let outline: Text.Encapsulation.Style = .init(nsStyle: .outline) |
| 83 | + |
| 84 | + public static let fill: Text.Encapsulation.Style = .init(nsStyle: .fill) |
| 85 | + } |
| 86 | + |
| 87 | + @available(OpenSwiftUI_v5_0, *) |
| 88 | + public struct PlatterSize: Hashable, Sendable { |
| 89 | + let nsPlatterSize: NSTextEncapsulationPlatterSize |
| 90 | + |
| 91 | + public static let regular: Text.Encapsulation.PlatterSize = .init(nsPlatterSize: .regular) |
| 92 | + |
| 93 | + public static let large: Text.Encapsulation.PlatterSize = .init(nsPlatterSize: .large) |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments