Skip to content

Commit 71c28f3

Browse files
authored
Add SpacingLayout support (#602)
1 parent 78e8a28 commit 71c28f3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// SpacingLayout.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for 6.5.4
6+
// Status: Complete
7+
8+
import OpenCoreGraphicsShims
9+
10+
struct SpacingLayout: UnaryLayout {
11+
var spacing: Spacing
12+
13+
func spacing(in context: SizeAndSpacingContext, child: LayoutProxy) -> Spacing {
14+
spacing
15+
}
16+
17+
func placement(of child: LayoutProxy, in context: PlacementContext) -> _Placement {
18+
_Placement(
19+
proposedSize: context.proposedSize,
20+
aligning: .center,
21+
in: context.size
22+
)
23+
}
24+
25+
func sizeThatFits(in proposedSize: _ProposedSize, context: SizeAndSpacingContext, child: LayoutProxy) -> CGSize {
26+
child.size(in: proposedSize)
27+
}
28+
}
29+
30+
extension View {
31+
package func spacing(_ spacing: Spacing) -> some View {
32+
modifier(SpacingLayout(spacing: spacing))
33+
}
34+
}

0 commit comments

Comments
 (0)