Skip to content

Commit 93213b4

Browse files
committed
Gardening
1 parent fcf420b commit 93213b4

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

LayoutInspector/ContentView.swift

+12-19
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import SwiftUI
22
import DebugLayout
33

44
struct ContentView: View {
5-
var suggestedExamplePadding: some View {
5+
var body: some View {
6+
Inspector {
7+
/// The view tree whose layout you want to inspect. Add `.debugLayout()` calls at
8+
/// each point where you want to inspect the layout algorithm, i.e. what sizes are
9+
/// being proposed and returned. We call these **inspection points**.
10+
hStackExample
11+
}
12+
}
13+
14+
var paddingExample: some View {
615
Text("Hello world")
716
.debugLayout("Text")
817
.padding(10)
918
.debugLayout("padding")
1019
.border(Color.green)
1120
.debugLayout("border")
12-
1321
}
1422

15-
var hstack: some View {
23+
var hStackExample: some View {
1624
HStack(spacing: 10) {
1725
Rectangle().fill(.green)
1826
.debugLayout("green")
@@ -24,40 +32,25 @@ struct ContentView: View {
2432
.debugLayout("HStack")
2533
}
2634

27-
var fixedSize: some View {
35+
var fixedSizeExample: some View {
2836
Text("Lorem ipsum dolor sit amet")
2937
.debugLayout("Text")
3038
.fixedSize()
3139
.debugLayout("fixedSize")
3240
.frame(width: 100)
3341
.debugLayout("frame")
3442
.border(Color.green)
35-
}
36-
37-
var body: some View {
38-
Inspector {
39-
hstack
40-
}
4143
}
4244
}
4345

4446
struct Inspector<Subject: View>: View {
45-
46-
/// The view tree whose layout you want to inspect. Add `.debugLayout()` calls at
47-
/// each point where you want to inspect the layout algorithm, i.e. what sizes are
48-
/// being proposed and returned. We call these **inspection points**.
4947
@ViewBuilder var subject: Subject
5048

51-
init(@ViewBuilder subject: () -> Subject) {
52-
self.subject = subject()
53-
}
54-
5549
@State private var width: CGFloat = 300
5650
@State private var height: CGFloat = 100
5751
@State private var selectedView: String? = nil
5852
@State private var generation: Int = 0
5953

60-
6154
var body: some View {
6255
VStack {
6356
VStack {

0 commit comments

Comments
 (0)