diff --git a/Sources/Gala/Gala.swift b/Sources/Gala/Gala.swift index bdfc966..ca82026 100644 --- a/Sources/Gala/Gala.swift +++ b/Sources/Gala/Gala.swift @@ -26,9 +26,15 @@ public func Layouts(_ layouts: [Layout], _ name: String? = nil, @ViewBu @available(watchOS, unavailable) public func HorizontalSizeClasses(_ name: String? = nil, @ViewBuilder items: @escaping () -> A) -> some View { ForEach([UserInterfaceSizeClass.compact, .regular], id: \.self) { item in + #if swift(<5.3) items() .previewDisplayName(name.map { "\($0) \(item!)" } ?? "\(item!)") .environment(\.horizontalSizeClass, item) + #else + items() + .previewDisplayName(name.map { "\($0) \(item)" } ?? "\(item)") + .environment(\.horizontalSizeClass, item) + #endif } } @@ -38,9 +44,15 @@ public func HorizontalSizeClasses(_ name: String? = nil, @ViewBuilder i @available(watchOS, unavailable) public func VerticalSizeClasses(_ name: String? = nil, @ViewBuilder items: @escaping () -> A) -> some View { ForEach([UserInterfaceSizeClass.compact, .regular], id: \.self) { item in + #if swift(<5.3) items() .previewDisplayName(name.map { "\($0) \(item!)" } ?? "\(item!)") .environment(\.verticalSizeClass, item) + #else + items() + .previewDisplayName(name.map { "\($0) \(item)" } ?? "\(item)") + .environment(\.verticalSizeClass, item) + #endif } } @@ -56,9 +68,15 @@ public func LayoutDirections(_ name: String? = nil, @ViewBuilder items: public func LegibilityWeights(_ name: String? = nil, @ViewBuilder items: @escaping () -> A) -> some View { ForEach([LegibilityWeight.regular, .bold], id: \.self) { item in + #if swift(<5.3) items() .previewDisplayName(name.map { "\($0) \(item!)" } ?? "\(item!)") .environment(\.legibilityWeight, item) + #else + items() + .previewDisplayName(name.map { "\($0) \(item)" } ?? "\(item)") + .environment(\.legibilityWeight, item) + #endif } }