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

Commit df2916d

Browse files
authored
style (#30)
1 parent 141a907 commit df2916d

8 files changed

+25
-25
lines changed

Sources/Grid/Grid.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public struct Grid: View {
1616
width: self.style.frameWidth(at: index, with: geometry, itemsCount: self.items.count),
1717
height: self.style.frameHeight(at: index, with: geometry, itemsCount: self.items.count)
1818
)
19-
2019
.position(self.style.position(at: index, with: geometry, itemsCount: self.items.count))
2120
.anchorPreference(key: GridItemPreferences.Key.self, value: .rect(self.style.itemRect(at: index, with: geometry, itemsCount: self.items.count))) {
2221
[GridItemPreferences(index: index, bounds: $0)]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import SwiftUI
2+
3+
extension EnvironmentValues {
4+
var gridStyle: GridStyle {
5+
get {
6+
return self[GridStyleKey.self]
7+
}
8+
set {
9+
self[GridStyleKey.self] = newValue
10+
}
11+
}
12+
}

Sources/Grid/Grid+Style.swift renamed to Sources/Grid/Styles/Style/GridStyle.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,3 @@ extension GridStyle {
3737
return usableWidth / CGFloat(columns)
3838
}
3939
}
40-
41-
extension View {
42-
43-
/// Sets the style for `Grid` within the environment of `self`.
44-
public func gridStyle<S>(_ style: S) -> some View where S : GridStyle {
45-
self.environment(\.gridStyle, style)
46-
}
47-
48-
}
49-
50-
struct GridStyleKey: EnvironmentKey {
51-
static let defaultValue: GridStyle = AutoColumnsGridStyle()
52-
}
53-
54-
extension EnvironmentValues {
55-
var gridStyle: GridStyle {
56-
get {
57-
return self[GridStyleKey.self]
58-
}
59-
set {
60-
self[GridStyleKey.self] = newValue
61-
}
62-
}
63-
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import SwiftUI
2+
3+
struct GridStyleKey: EnvironmentKey {
4+
static let defaultValue: GridStyle = AutoColumnsGridStyle()
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import SwiftUI
2+
3+
extension View {
4+
/// Sets the style for `Grid` within the environment of `self`.
5+
public func gridStyle<S>(_ style: S) -> some View where S : GridStyle {
6+
self.environment(\.gridStyle, style)
7+
}
8+
}

0 commit comments

Comments
 (0)