You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/Custom-Transitions.md
+11-21Lines changed: 11 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,39 +47,23 @@ public struct Slide: NavigationTransition {
47
47
publicvar body: some NavigationTransition {
48
48
switch axis {
49
49
case .horizontal:
50
-
OnPush {
50
+
MirrorPush {
51
51
OnInsertion {
52
52
Move(edge: .trailing)
53
53
}
54
54
OnRemoval {
55
55
Move(edge: .leading)
56
56
}
57
57
}
58
-
OnPop {
59
-
OnInsertion {
60
-
Move(edge: .leading)
61
-
}
62
-
OnRemoval {
63
-
Move(edge: .trailing)
64
-
}
65
-
}
66
58
case .vertical:
67
-
OnPush {
59
+
MirrorPush {
68
60
OnInsertion {
69
61
Move(edge: .bottom)
70
62
}
71
63
OnRemoval {
72
64
Move(edge: .top)
73
65
}
74
66
}
75
-
OnPop {
76
-
OnInsertion {
77
-
Move(edge: .top)
78
-
}
79
-
OnRemoval {
80
-
Move(edge: .bottom)
81
-
}
82
-
}
83
67
}
84
68
}
85
69
}
@@ -227,9 +211,15 @@ All types conforming to `AtomicTransition` must implement what's known as a "tra
227
211
228
212
Next up, let's explore two ways of conforming to `NavigationTransition`.
229
213
230
-
The simplest (and most recommended) way happens by declaring our atomic transitions (if needed), and composing them via `var body: some NavigationTransition { ... }` like we saw [previously with `Slide`](#NavigationTransition).
214
+
The simplest (and most recommended) way is by declaring our atomic transitions (if needed), and composing them via `var body: some NavigationTransition { ... }` like we saw [previously with `Slide`](#NavigationTransition).
215
+
216
+
Check out the [documentation](https://swiftpackageindex.com/davdroman/swiftui-navigation-transitions/0.2.0/documentation/navigationtransitions/navigationtransition) to learn about the different `NavigationTransition` types and how they compose.
217
+
218
+
The Demo project in the repo is also a great source of learning about different types of custom transitions and the way to implement them.
219
+
220
+
---
231
221
232
-
But there's actually an **alternative** option for those who'd like to reach for a more wholistic API. `NavigationTransition` declares this other function that can be implemented instead of `body`:
222
+
Finally, let's explore an alternative option for those who'd like to reach for a more wholistic API. `NavigationTransition` declares a `transition` function that can be implemented instead of `body`:
@@ -241,7 +231,7 @@ Whilst `body` helps composing other transitions, this transition handler helps u
241
231
-`Operation` defines whether the operation being performed is a `push` or a `pop`. The concept of insertions or removals is entirely irrelevant to this function, since you can directly modify the property values for the views without needing atomic transitions.
242
232
-`Container` is the container view of type `UIView` where `fromView` and `toView` are added during the transition. There's no need to add either view to this container as the library does this for you. Even better, there's no way to even accidentally do it because `TransientView` is not a `UIView` subclass.
243
233
244
-
This approach is often a simple one to take in case you're working on an app that only requires one custom navigation transition. However, if you're working on an app that features multiple custom transitions, it is recommended that you model your navigation transitions via atomic transitions as described earlier. In the long term, this will be beneficial to your development and iteration speed, by promoting code reusability amongst your team.
234
+
This approach is a less cumbersome one to take in case you're working on an app that only requires one custom navigation transition. However, if you're working on an app that features multiple custom transitions, it is recommended that you model your navigation transitions via atomic transitions as described earlier. In the long term, this will be beneficial to your development and iteration speed, by promoting code reusability amongst your team.
0 commit comments