Skip to content
This repository was archived by the owner on Dec 27, 2020. It is now read-only.

Commit 623f995

Browse files
Add compatibility checks (#120)
1 parent 97f9d65 commit 623f995

10 files changed

+12
-0
lines changed

Sources/Grid/Grid+Inits.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
34
extension Grid {
45
public init<Data, Item>(_ data: Data, @ViewBuilder item: @escaping (Data.Element) -> Item) where Content == ForEach<Data, Data.Element.ID, Item>, Data : RandomAccessCollection, Item : View, Data.Element : Identifiable {
56
self.items = data.map { GridItem(view: AnyView(item($0)), id: AnyHashable($0.id)) }
@@ -14,6 +15,7 @@ extension Grid {
1415
}
1516
}
1617

18+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1719
extension Grid {
1820
public init<C0: View, C1: View>(@ViewBuilder content: () -> Content) where Content == TupleView<(C0, C1)> {
1921
self.items = [GridItem(view: AnyView(content().value.0), id: AnyHashable(0)),

Sources/Grid/Grid.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22

33
/// A view that arranges its children in a grid.
4+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
45
public struct Grid<Content>: View where Content: View {
56
@Environment(\.gridStyle) private var style
67
@State var preferences: GridPreferences = GridPreferences(size: .zero, items: [])

Sources/Grid/GridItem.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
34
struct GridItem: Identifiable {
45
let view: AnyView
56
let id: AnyHashable

Sources/Grid/Styles/ModularGridStyle.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22

33
/// Modular `Grid` style.
4+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
45
public struct ModularGridStyle: GridStyle {
56
public var columns: Tracks
67
public var rows: Tracks

Sources/Grid/Styles/StaggeredGridStyle.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22

33
/// Staggered `Grid` style.
4+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
45
public struct StaggeredGridStyle: GridStyle {
56
public var tracks: Tracks
67
public var axis: Axis

Sources/Grid/Styles/Style/EnvironmentValues+GridStyle.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
34
public extension EnvironmentValues {
45
var gridStyle: GridStyle {
56
get {

Sources/Grid/Styles/Style/GridPreferencesModifier.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
34
struct GridPreferencesModifier: View {
45
let id: AnyHashable
56
let bounds: CGRect

Sources/Grid/Styles/Style/GridStyle.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import SwiftUI
22

33
/// A specification for the appearance of a `Grid`.
4+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
45
public protocol GridStyle {
56
var axis: Axis { get }
67
var autoWidth: Bool { get }
78
var autoHeight: Bool { get }
89
func transform(preferences: inout GridPreferences, in size: CGSize)
910
}
1011

12+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1113
public extension GridStyle {
1214
var axes: Axis.Set {
1315
self.axis == .horizontal ? .horizontal : .vertical
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
34
struct GridStyleKey: EnvironmentKey {
45
static let defaultValue: GridStyle = ModularGridStyle(columns: .min(100), rows: .fixed(100))
56
}

Sources/Grid/Styles/Style/View+GridStyle.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
34
public extension View {
45
/// Sets the style for `Grid` within the environment of `self`.
56
@inlinable func gridStyle<S>(_ style: S) -> some View where S : GridStyle {

0 commit comments

Comments
 (0)