File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,7 +162,48 @@ private extension View {
162162 }
163163}
164164
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) " ) {
166207
167208 struct Preview : View {
168209
@@ -171,24 +212,7 @@ private extension View {
171212
172213 var body : some View {
173214 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)
192216 }
193217 . padding ( )
194218 }
You can’t perform that action at this time.
0 commit comments