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

Feature/readme update #6

Closed
wants to merge 2 commits into from
Closed

Feature/readme update #6

wants to merge 2 commits into from

Conversation

piterwilson
Copy link
Contributor

SwiftUI is still a bit new. This is why I believe this minor edit would be a useful addition to your documentation.

@matteopuc
Copy link
Owner

Hi @piterwilson thanks for your pull request. There's something that sounds wrong to me in the note you added. I'll try to explain my doubts to you, tell me if I'm missing something: in my opinion the sentence

If you want to specify a different transition for push and pop, you can use .asymmetric

is wrong. If you specify an asymmetric transition you're not actually specifying a transition for the push operation and a transition for the pop operation. You're specifying a transition for an insertion operation and a transition for a removal operation, which is different. In SwiftUI an asymmetric transition is a transition that (from https://developer.apple.com/documentation/swiftui/anytransition/3076193-asymmetric):

Returns a composite transition that uses a different transition for insertion versus removal.

This means that asymmetric has nothing to do with the push/pop concept. Both in a push operation and in a pop operation you have an insertion and a removal. Let's make a simple example. Let's say we have this asymmetric transition for the navigation stack:

AnyTransition.asymmetric(insertion: .scale, removal: .opacity)

Now let's say we are in a View1 and we push to a View2. You will have:

  • .scale applied to View2 (the view that is getting in)
  • .opacity applied to View1 (the view that is being removed)

Now we are in the View2 and we want to come back to View1 with a pop operation. You will have:

  • .scale applied to View1 (the view that is getting in)
  • .opacity applied to View2 (the view that is being removed)

So, insertion != push and removal != pop, insertion and removal are just both applied in push and pop operations.

Does this make sense to you?

@piterwilson
Copy link
Contributor Author

It totally makes sense. Thanks for clarifying.

@piterwilson piterwilson deleted the feature/README_Update branch February 28, 2020 11:19
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

Successfully merging this pull request may close these issues.

None yet

2 participants