Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should re-present when sheet/fullScreenCover/popover identity changes #75

Open
stephencelis opened this issue Jan 30, 2023 · 5 comments

Comments

@stephencelis
Copy link
Member

stephencelis commented Jan 30, 2023

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 enumTag helper 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.

@stephencelis stephencelis changed the title Should re-present when sheet/confirmationDialog/popover identity changes Should re-present when sheet/fullScreenCover/popover identity changes Feb 1, 2023
@Zeta611
Copy link

Zeta611 commented Feb 26, 2023

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?

@stephencelis
Copy link
Member Author

@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.

@davdroman
Copy link

@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.

@Muhammed9991
Copy link

Is there a workaround for this until this work is done?

@stephencelis
Copy link
Member Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants