@@ -2,17 +2,25 @@ import SwiftUI
2
2
import DebugLayout
3
3
4
4
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 {
6
15
Text ( " Hello world " )
7
16
. debugLayout ( " Text " )
8
17
. padding ( 10 )
9
18
. debugLayout ( " padding " )
10
19
. border ( Color . green)
11
20
. debugLayout ( " border " )
12
-
13
21
}
14
22
15
- var hstack : some View {
23
+ var hStackExample : some View {
16
24
HStack ( spacing: 10 ) {
17
25
Rectangle ( ) . fill ( . green)
18
26
. debugLayout ( " green " )
@@ -24,40 +32,25 @@ struct ContentView: View {
24
32
. debugLayout ( " HStack " )
25
33
}
26
34
27
- var fixedSize : some View {
35
+ var fixedSizeExample : some View {
28
36
Text ( " Lorem ipsum dolor sit amet " )
29
37
. debugLayout ( " Text " )
30
38
. fixedSize ( )
31
39
. debugLayout ( " fixedSize " )
32
40
. frame ( width: 100 )
33
41
. debugLayout ( " frame " )
34
42
. border ( Color . green)
35
- }
36
-
37
- var body : some View {
38
- Inspector {
39
- hstack
40
- }
41
43
}
42
44
}
43
45
44
46
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**.
49
47
@ViewBuilder var subject : Subject
50
48
51
- init ( @ViewBuilder subject: ( ) -> Subject ) {
52
- self . subject = subject ( )
53
- }
54
-
55
49
@State private var width : CGFloat = 300
56
50
@State private var height : CGFloat = 100
57
51
@State private var selectedView : String ? = nil
58
52
@State private var generation : Int = 0
59
53
60
-
61
54
var body : some View {
62
55
VStack {
63
56
VStack {
0 commit comments