swiftui-navigation
swiftui-navigation copied to clipboard
Should re-present when `sheet`/`fullScreenCover`/`popover` identity changes
Our view modifier overloads currently call down to the isPresented: Binding<Bool> versions, which can lead to some unwanted behavior: for example, if a presented sheet changes to another presented sheet, this change occurs without animation (brought up in discussion #73).
We can fix this by calling down to the item: Binding<Item?> APIs instead. This means making sure that the "item" being presented is identifiable, but we can hopefully create a lightweight wrapper type to represent this info. Rather than requiring the value itself to conform to Identifiable, we can identify based off a combination of:
- The type of value (
ObjectIdentifier(Value.self)). - The enum case, where applicable (we can use this
enumTaghelper or something similar. - An underlying identifier by casting
Value as? any Identifiable.
If anyone wants to take a shot at supporting this, we'd gladly take a PR! Otherwise we'll try to get to it soon.
Is this the cause of a .sheet being (randomly) presented as a .fullScreenCover (or vice versa) when the case of the unwrapping enum changes from one to another?
@Zeta611 It shouldn't be! That sounds like a gnarly SwiftUI bug, though, if you want to share a repro and file a feedback with Apple.
@stephencelis I think he's referring to this https://stackoverflow.com/q/69101690 which I've stumbled upon whilst using the nav branch in TCA as well, so yeah I'm pretty sure it's a vanilla SwiftUI bug.
Is there a workaround for this until this work is done?
@Muhammed9991 You should always be able to stagger the updates, e.g. nil out the presentation, sleep 0.3 seconds, and then set state to some other value.