Skip to content

Commit 34cc930

Browse files
committed
Add a bug fix for the flip view list rendering issue
1 parent 71182ec commit 34cc930

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Sources/SwiftUIKit/Flip/FlipView.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ import SwiftUI
1414
/// For now, this view only supports horizontal flips, since
1515
/// flipping views both horizontally and vertically can mess
1616
/// it up, since the view can become upside down.
17+
///
18+
/// > Important: This view currently handles flip animations
19+
/// incorrectly when it is used within a `List`. This can be
20+
/// fixed by wrapping it in a `ZStack`. I tried to create an
21+
/// additional layer within this component, but that did not
22+
/// work. Until we come up with another solution, there is a
23+
/// `.withListRenderingBugFix()` view modifier that performs
24+
/// the `ZStack` wrap.
1725
public struct FlipView<FrontView: View, BackView: View>: View {
1826

1927
public init(
@@ -71,6 +79,15 @@ public struct FlipView<FrontView: View, BackView: View>: View {
7179
}
7280
}
7381

82+
public extension FlipView {
83+
84+
func withListRenderingBugFix() -> some View {
85+
ZStack {
86+
self
87+
}
88+
}
89+
}
90+
7491
private extension View {
7592

7693
typealias FlipAction = (FlipDirection) -> Void
@@ -175,6 +192,8 @@ func previewContent(isFlipped: Binding<Bool>) -> some View {
175192
tapDirection: .right,
176193
swipeDirections: [.left, .right, .up, .down]
177194
)
195+
.withListRenderingBugFix() // OBS!
196+
.frame(minHeight: 100)
178197
.cornerRadius(10)
179198
.shadow(radius: 0, x: 0, y: 2)
180199

0 commit comments

Comments
 (0)