@@ -18,30 +18,32 @@ enum PipelineState {
18
18
case failed( Error )
19
19
}
20
20
21
- //struct LabelToggleDisclosureGroupStyle: DisclosureGroupStyle {
22
- // func makeBody(configuration: Configuration) -> some View {
23
- // VStack {
24
- // HStack {
25
- // Button {
26
- // withAnimation {
27
- // configuration.isExpanded.toggle()
28
- // }
29
- // } label: {
30
- // Image(systemName: configuration.isExpanded ? "chevron.down.circle.fill" : "chevron.right.circle.fill")
31
- // }.buttonStyle(.plain).foregroundColor(.primary).colorInvert()
32
- // configuration.label.onTapGesture {
33
- // withAnimation {
34
- // configuration.isExpanded.toggle()
35
- // }
36
- // }
37
- // Spacer()
38
- // }
39
- // if configuration.isExpanded {
40
- // configuration.content
41
- // }
42
- // }
43
- // }
44
- //}
21
+ /// Mimics the native appearance, but labels are clickable.
22
+ /// To be removed (adding gestures to all labels) if we observe any UI shenanigans.
23
+ struct LabelToggleDisclosureGroupStyle : DisclosureGroupStyle {
24
+ func makeBody( configuration: Configuration ) -> some View {
25
+ VStack {
26
+ HStack {
27
+ Button {
28
+ withAnimation {
29
+ configuration. isExpanded. toggle ( )
30
+ }
31
+ } label: {
32
+ Image ( systemName: configuration. isExpanded ? " chevron.down " : " chevron.right " ) . frame ( width: 8 , height: 8 )
33
+ } . buttonStyle ( . plain) . font ( . footnote) . fontWeight ( . semibold) . foregroundColor ( . gray)
34
+ configuration. label. onTapGesture {
35
+ withAnimation {
36
+ configuration. isExpanded. toggle ( )
37
+ }
38
+ }
39
+ Spacer ( )
40
+ }
41
+ if configuration. isExpanded {
42
+ configuration. content
43
+ }
44
+ }
45
+ }
46
+ }
45
47
46
48
struct ControlsView : View {
47
49
@EnvironmentObject var generation : GenerationContext
@@ -111,11 +113,7 @@ struct ControlsView: View {
111
113
modelDidChange ( model: model)
112
114
}
113
115
} label: {
114
- Label ( " Model from Hub " , systemImage: " cpu " ) . foregroundColor ( . secondary) . onTapGesture {
115
- withAnimation {
116
- disclosedModel. toggle ( )
117
- }
118
- }
116
+ Label ( " Model from Hub " , systemImage: " cpu " ) . foregroundColor ( . secondary)
119
117
}
120
118
121
119
Divider ( )
@@ -131,11 +129,7 @@ struct ControlsView: View {
131
129
. textFieldStyle ( . squareBorder)
132
130
} . padding ( . leading, 10 )
133
131
} label: {
134
- Label ( " Prompts " , systemImage: " text.quote " ) . foregroundColor ( . secondary) . onTapGesture {
135
- withAnimation {
136
- disclosedPrompt. toggle ( )
137
- }
138
- }
132
+ Label ( " Prompts " , systemImage: " text.quote " ) . foregroundColor ( . secondary)
139
133
}
140
134
141
135
Divider ( )
@@ -147,11 +141,7 @@ struct ControlsView: View {
147
141
Text ( " \( Int ( generation. steps) ) " )
148
142
} . padding ( . leading, 10 )
149
143
} label: {
150
- Label ( " Step count " , systemImage: " square.3.layers.3d.down.left " ) . foregroundColor ( . secondary) . onTapGesture {
151
- withAnimation {
152
- disclosedSteps. toggle ( )
153
- }
154
- }
144
+ Label ( " Step count " , systemImage: " square.3.layers.3d.down.left " ) . foregroundColor ( . secondary)
155
145
}
156
146
Divider ( )
157
147
@@ -174,14 +164,11 @@ struct ControlsView: View {
174
164
Text ( " \( Int ( generation. seed) ) " )
175
165
} . padding ( . leading, 10 )
176
166
} label: {
177
- Label ( " Seed " , systemImage: " leaf " ) . foregroundColor ( . secondary) . onTapGesture {
178
- withAnimation {
179
- disclosedSeed. toggle ( )
180
- }
181
- }
167
+ Label ( " Seed " , systemImage: " leaf " ) . foregroundColor ( . secondary)
182
168
}
183
169
}
184
170
}
171
+ . disclosureGroupStyle ( LabelToggleDisclosureGroupStyle ( ) )
185
172
186
173
StatusView ( pipelineState: $pipelineState)
187
174
}
0 commit comments