import SwiftUI
import DynamicOverlay
struct ContentView: View {
@State var notch: Notch = .min
@State var showContent2 = false
enum Notch: CaseIterable, Equatable { case min }
var body: some View {
Color.white
.dynamicOverlay(overlayView)
.dynamicOverlayBehavior(behavior)
}
private var behavior: some DynamicOverlayBehavior {
MagneticNotchOverlayBehavior<Notch> { _ in .absolute(showContent2 ? 400 : 200) }
}
private var overlayView: some View {
VStack(spacing: 0) {
Color.blue.frame(height: 50).draggable()
if showContent2 {
OverlayContent(title: "Content 1", color: Color.red, action: { withAnimation { showContent2.toggle() }})
} else {
OverlayContent(title: "Content 1", color: Color.red, action: { withAnimation { showContent2.toggle() }})
}
}
}
}
struct OverlayContent: View {
let title: String
let color: Color
let action: () -> Void
var body: some View {
ZStack(alignment: .top) {
color
VStack {
Text(title).font(.title)
Button(action: action, label: { Text("Action crash") }).padding()
List {
Button(action: action, label: { Text("Action fine") }).padding()
}.drivingScrollView() // remove me fix everything
}
}
}
}
@main
struct MapApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Pressing Action fine is fine. (But we witness the same animation bug reported in #18)
Pressing Action crash crashed the app with an exception: "-[OverlayContainer.OverlayScrollViewDelegateProxy tableView:didEndDisplayingCell:forRowAtIndexPath:]: unrecognized selector sent to instance 0x281a179c0"
Obviously, the crash being in ScrollViewdelegateProxy, not applying a drivingScrollView to the list fixes the issue as well.
Rolling back to 1.0.0-beta.8 fixes the crash but obviously does not include the fix in #20.
Being new to DynamicOverlay and Swift in general I am having a hard time understanding what is going on.
Hi,
I think #20 introduced an issue when combining dynamic view composition with
drivingScrollView
. Considering the following code, heavily inspired by https://github.com/faberNovel/DynamicOverlay/issues/18Action fine
is fine. (But we witness the same animation bug reported in #18)Action crash
crashed the app with an exception:"-[OverlayContainer.OverlayScrollViewDelegateProxy tableView:didEndDisplayingCell:forRowAtIndexPath:]: unrecognized selector sent to instance 0x281a179c0"
Obviously, the crash being in
ScrollViewdelegateProxy
, not applying adrivingScrollView
to the list fixes the issue as well.Rolling back to
1.0.0-beta.8
fixes the crash but obviously does not include the fix in #20.Being new to DynamicOverlay and Swift in general I am having a hard time understanding what is going on.