File tree 1 file changed +43
-19
lines changed
1 file changed +43
-19
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,48 @@ private extension View {
162
162
}
163
163
}
164
164
165
- #Preview {
165
+ @MainActor
166
+ @ViewBuilder
167
+ func previewContent( isFlipped: Binding < Bool > ) -> some View {
168
+ Text ( " Is Flipped: \( isFlipped. wrappedValue) " )
169
+
170
+ FlipView (
171
+ front: Color . green. overlay ( Text ( " Front " ) ) ,
172
+ back: Color . red. overlay ( Text ( " Back " ) ) ,
173
+ isFlipped: isFlipped,
174
+ flipDuration: 0.5 ,
175
+ tapDirection: . right,
176
+ swipeDirections: [ . left, . right, . up, . down]
177
+ )
178
+ . cornerRadius ( 10 )
179
+ . shadow ( radius: 0 , x: 0 , y: 2 )
180
+
181
+ Button ( " Flip " ) {
182
+ withAnimation {
183
+ isFlipped. wrappedValue. toggle ( )
184
+ }
185
+ }
186
+ }
187
+
188
+ #Preview( " Stack " ) {
189
+
190
+ struct Preview : View {
191
+
192
+ @State
193
+ private var isFlipped = false
194
+
195
+ var body : some View {
196
+ VStack {
197
+ previewContent ( isFlipped: $isFlipped)
198
+ }
199
+ . padding ( )
200
+ }
201
+ }
202
+
203
+ return Preview ( )
204
+ }
205
+
206
+ #Preview( " List (BUG) " ) {
166
207
167
208
struct Preview : View {
168
209
@@ -171,24 +212,7 @@ private extension View {
171
212
172
213
var body : some View {
173
214
List {
174
- Text ( " Is Flipped: \( isFlipped) " )
175
-
176
- FlipView (
177
- front: Color . green. overlay ( Text ( " Front " ) ) ,
178
- back: Color . red. overlay ( Text ( " Back " ) ) ,
179
- isFlipped: $isFlipped,
180
- flipDuration: 0.5 ,
181
- tapDirection: . right,
182
- swipeDirections: [ . left, . right, . up, . down]
183
- )
184
- . cornerRadius ( 10 )
185
- . shadow ( radius: 0 , x: 0 , y: 2 )
186
-
187
- Button ( " Flip " ) {
188
- withAnimation {
189
- isFlipped. toggle ( )
190
- }
191
- }
215
+ previewContent ( isFlipped: $isFlipped)
192
216
}
193
217
. padding ( )
194
218
}
You can’t perform that action at this time.
0 commit comments