SwiftUIModal
SwiftUIModal copied to clipboard
Background's transformation effects glitchy when drag gesture is interrupted
When you're expanding modal view from .partiallyRevealed to .open, and the gesture is interrupted (i.e. Control Center is opened) background .scaleEffect, .mask and fading Rectangle() .opacity is stuck at the value when drag was interrupted.
Ways to replicate
- Quickly open Control Center
- Start opening modal and press Home button (minimize app)
Oh, this is the same problem I was having in #1. Same thing happens when you trigger the animation without dragging, it just acts weird and the values don't update.
I was trying to force it to update by storing the scale/offset/opacity values in @State variables and changing the values when the ModalPosition changed, but didn't have a lot of luck with that.
I don't have much idea of what I'm doing when coding SwiftUI stuff so there might be some other ways of achieving this ¯_(ツ)_/¯
I’ll take a look as soon as I commit the newest update to SwiftUIModal which adds a lot of flexibility and the ability to add as many modals as you want effortlessly. If I understood your issue correctly, it seems like it could be rectified with an ‘.onInterrupted’ on the DragGesture which doesn’t currently exist in SwiftUI. I’m pretty sure I have a workaround in mind. Does the modal still slide up, but other animations get interrupted?
Yeah, the modal works great. It's the other values that don't get "caught" correctly.
A new version sounds great then, looking forward =D