@@ -17,9 +17,15 @@ struct DebugLayoutWrapper: ViewModifier {
17
17
@Environment ( \. debugLayoutSelection) private var selection : String ?
18
18
19
19
func body( content: Content ) -> some View {
20
- let isSelected = label == selection
21
20
content
22
- . border ( isSelected ? Color . pink : . clear, width: 2 )
21
+ . overlay {
22
+ let isSelected = label == selection
23
+ if isSelected {
24
+ Rectangle ( )
25
+ . strokeBorder ( style: StrokeStyle ( lineWidth: 1 , dash: [ 5 ] ) )
26
+ . foregroundColor ( . pink)
27
+ }
28
+ }
23
29
}
24
30
}
25
31
@@ -156,61 +162,55 @@ struct Selection<Value: Equatable>: PreferenceKey {
156
162
157
163
struct ConsoleView : View {
158
164
@ObservedObject var console = Console . shared
159
- @State private var selection : String ? = " Text "
165
+ @State private var selection : String ? = nil
160
166
161
167
var body : some View {
162
168
ScrollView ( . vertical) {
163
- VStack ( alignment: . leading, spacing: 16 ) {
164
- Text ( " Layout Log " )
165
- . font ( . headline)
166
- . padding ( . top, 16 )
169
+ Grid ( alignment: . leadingFirstTextBaseline, horizontalSpacing: 0 , verticalSpacing: 0 ) {
170
+ GridRow {
171
+ Text ( " View " )
172
+ Text ( " Proposal " )
173
+ Text ( " Response " )
174
+ }
175
+ . font ( . headline)
176
+ . padding ( . vertical, 4 )
177
+ . padding ( . horizontal, 8 )
178
+
179
+ Rectangle ( ) . fill ( . secondary)
180
+ . frame ( height: 1 )
181
+ . gridCellUnsizedAxes ( . horizontal)
182
+ . padding ( . vertical, 4 )
167
183
. padding ( . horizontal, 8 )
168
184
169
- Grid ( alignment: . leadingFirstTextBaseline, horizontalSpacing: 0 , verticalSpacing: 0 ) {
185
+ ForEach ( console. log) { item in
186
+ let isSelected = selection == item. label
170
187
GridRow {
171
- Text ( " View " )
172
- Text ( " Proposal " )
173
- Text ( " Response " )
188
+ Text ( item. label)
189
+ . font ( . body)
190
+ . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . leading)
191
+
192
+ Text ( item. proposal? . pretty ?? " … " )
193
+ . monospacedDigit ( )
194
+ . fixedSize ( )
195
+ . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . leading)
196
+
197
+ Text ( item. response? . pretty ?? " … " )
198
+ . monospacedDigit ( )
199
+ . fixedSize ( )
200
+ . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . leading)
174
201
}
175
- . font ( . headline )
202
+ . font ( . callout )
176
203
. padding ( . vertical, 4 )
177
204
. padding ( . horizontal, 8 )
178
-
179
- Rectangle ( ) . fill ( . secondary)
180
- . frame ( height: 1 )
181
- . gridCellUnsizedAxes ( . horizontal)
182
- . padding ( . vertical, 4 )
183
- . padding ( . horizontal, 8 )
184
-
185
- ForEach ( console. log) { item in
186
- let isSelected = selection == item. label
187
- GridRow {
188
- Text ( item. label)
189
- . font ( . body)
190
- . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . leading)
191
-
192
- Text ( item. proposal? . pretty ?? " … " )
193
- . monospacedDigit ( )
194
- . fixedSize ( )
195
- . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . leading)
196
-
197
- Text ( item. response? . pretty ?? " … " )
198
- . monospacedDigit ( )
199
- . fixedSize ( )
200
- . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . leading)
201
- }
202
- . font ( . callout)
203
- . padding ( . vertical, 4 )
204
- . padding ( . horizontal, 8 )
205
- . foregroundColor ( isSelected ? . white : nil )
206
- . background ( isSelected ? Color . accentColor : . clear)
207
- . contentShape ( Rectangle ( ) )
208
- . onTapGesture {
209
- selection = isSelected ? nil : item. label
210
- }
205
+ . foregroundColor ( isSelected ? . white : nil )
206
+ . background ( isSelected ? Color . accentColor : . clear)
207
+ . contentShape ( Rectangle ( ) )
208
+ . onTapGesture {
209
+ selection = isSelected ? nil : item. label
211
210
}
212
211
}
213
212
}
213
+ . padding ( . vertical, 8 )
214
214
}
215
215
. background ( Color ( uiColor: . secondarySystemBackground) )
216
216
. preference ( key: Selection . self, value: selection)
0 commit comments