SlideOverCard
SlideOverCard copied to clipboard
Sheet onDismiss is called immediately when View appeared
Steps to repro
Case 1
- Attach .slideOverCard(item: ...) modifier to a View
- Implement onDismiss closure
- Closure is executed 5 times when sheet is not opened
Case 2
- Attach .slideOverCard(isPresented: ...) modifier to a View
- Implement onDismiss closure
- Closure is executed 2 times when sheet is not opened
Env Simulator iPhone 15 pro max, iOS 17.4
Code Sample 1
struct Sheet3: Identifiable {
var id: String { title }
let title: String
}
struct ContentView: View {
@State private var showSheet3: Sheet3? = nil
var body: some View {
VStack {
Button("Show sheet #3") { showSheet3 = .init(title: "Sheet #3") }
}
.slideOverCard(item: $showSheet3, onDismiss: { print("Sheet #3 dismiss") }) { sheet3 in
Text(sheet3.title)
}
}
}
Console Output 1
Sheet #3 dismiss
Sheet #3 dismiss
Sheet #3 dismiss
Sheet #3 dismiss
Sheet #3 dismiss
Code Sample 2
struct ContentView: View {
@State private var showSheet1 = false
var body: some View {
VStack {
Button("Show sheet #1") { showSheet1 = true }
}
.slideOverCard(isPresented: $showSheet1, onDismiss: { print("Sheet #1 dismiss") }) {
Text("Sheet #1")
}
}
}
Console Output 2
Sheet #1 dismiss
Sheet #1 dismiss
I encountered the same problem, have you found any solutions to it?
I encountered the same problem, have you found any solutions to it?
Hey, I haven't. Just continue sticking to a SwiftUI .sheet with presentation detents
Oh thought I have done something wrong, but seems like this is a common issue in version 3.0.1. Have you found any solutions or workarounds for this problem? Do we really have to go back to the previous version of this package? 🤔