Skip to content

Commit ace502a

Browse files
authored
Deprecate split view modifiers (#29)
After some experimentation I came to the conclusion that split view "transitions" are not meant to be modified directly. They're not even a thing in itself, really. Instead, it should be the stack navigation view *within* the split view that can and should have their transition modified directly. So I deprecated all the split view modifiers and flattened the 2 stack modifiers into one: `.navigationTransition`. In addition to this, a useful runtime warning will let you know when you're holding it wrong. This drastically simplifies the API surface to a single entry point and is, I believe, a step in the right direction to easing the entry barrier for this library.
1 parent 0ac3c1a commit ace502a

File tree

4 files changed

+81
-252
lines changed

4 files changed

+81
-252
lines changed

Demo/Demo/Pages.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ struct PageOne: View {
3535
struct PageTwo: View {
3636
var body: some View {
3737
let content = Group {
38-
Text("The library is fully compatible with **NavigationView** in iOS 13+, and the new **NavigationStack** and **NavigationSplitView** in iOS 16.")
38+
Text("The library is fully compatible with **NavigationView** in iOS 13+, and the new **NavigationStack** in iOS 16.")
3939
Text("In fact, that entire transition you just saw can be implemented in **one line** of SwiftUI code:")
4040
Code("""
41-
NavigationView {
41+
NavigationStack {
4242
...
4343
}
44-
.navigationViewStackTransition(.slide)
44+
.navigationTransition(.slide)
4545
"""
4646
)
4747
}
@@ -62,7 +62,7 @@ struct PageThree: View {
6262
Text("The API is designed to resemble that of built-in SwiftUI Transitions for maximum **familiarity** and **ease of use**.")
6363
Text("You can apply **custom animations** just like with standard SwiftUI transitions:")
6464
Code("""
65-
.navigationViewStackTransition(
65+
.navigationTransition(
6666
.fade(.in).animation(
6767
.easeInOut(duration: 0.3)
6868
)
@@ -71,7 +71,7 @@ struct PageThree: View {
7171
)
7272
Text("... and you can even **combine** them too:")
7373
Code("""
74-
.navigationViewStackTransition(
74+
.navigationTransition(
7575
.slide.combined(with: .fade(.in))
7676
)
7777
"""

Demo/Demo/RootView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct RootView: View {
1717
.navigationViewStyle(.stack)
1818
}
1919
}
20-
.navigationViewStackTransition(
20+
.navigationTransition(
2121
appState.transition().animation(appState.animation()),
2222
interactivity: appState.interactivity()
2323
)

README.md

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77
<p align="center">
88
<img width="320" src="https://user-images.githubusercontent.com/2538074/199754334-7f2f801d-1d9e-4cc4-a7a0-bb22c9835007.gif">
99
</p>
10-
1110
**NavigationTransitions** is a library that integrates seamlessly with SwiftUI's **Navigation** views, allowing complete customization over **push and pop transitions**!
1211

1312
The library is fully compatible with:
1413

15-
- **`NavigationView`** (iOS 13+)
16-
- **`NavigationStack`** & **`NavigationSplitView`** (iOS 16)
14+
- **`NavigationView`** (iOS 13, 14, 15)
15+
- **`NavigationStack`** (iOS 16)
1716

1817
## Overview
1918

20-
Instead of reinventing entire navigation components in order to customize its transitions, `NavigationTransitions` ships as a simple set of 2 modifiers that can be applied directly to SwiftUI's very own first-party navigation components.
19+
Instead of reinventing entire navigation components in order to customize its transitions, `NavigationTransitions` ships with a simple modifier that can be applied directly to SwiftUI's very own first-party navigation component.
2120

2221
### The Basics
2322

@@ -28,15 +27,7 @@ NavigationView {
2827
// ...
2928
}
3029
.navigationViewStyle(.stack)
31-
.navigationViewStackTransition(.slide)
32-
```
33-
34-
```swift
35-
NavigationView {
36-
// ...
37-
}
38-
.navigationViewStyle(.columns)
39-
.navigationViewColumnTransition(.slide, forColumns: .all)
30+
.navigationTransition(.slide)
4031
```
4132

4233
#### iOS 16
@@ -45,14 +36,7 @@ NavigationView {
4536
NavigationStack {
4637
// ...
4738
}
48-
.navigationStackTransition(.slide)
49-
```
50-
51-
```swift
52-
NavigationSplitView {
53-
// ...
54-
}
55-
.navigationSplitViewTransition(.slide, forColumns: .all)
39+
.navigationTransition(.slide)
5640
```
5741

5842
---
@@ -62,23 +46,23 @@ The API is designed to resemble that of built-in SwiftUI Transitions for maximum
6246
You can apply **custom animations** just like with standard SwiftUI transitions:
6347

6448
```swift
65-
.navigationViewStackTransition(
49+
.navigationTransition(
6650
.fade(.in).animation(.easeInOut(duration: 0.3))
6751
)
6852
```
6953

7054
You can **combine** them:
7155

7256
```swift
73-
.navigationViewStackTransition(
57+
.navigationTransition(
7458
.slide.combined(with: .fade(.in))
7559
)
7660
```
7761

7862
And you can **dynamically** choose between transitions based on logic:
7963

8064
```swift
81-
.navigationViewStackTransition(
65+
.navigationTransition(
8266
reduceMotion ? .fade(.in).animation(.linear) : .slide(.vertical)
8367
)
8468
```
@@ -129,13 +113,13 @@ The [**Demo**](Demo) app showcases some of these transitions in action.
129113
A sweet additional feature is the ability to override the behavior of the **pop gesture** on the navigation view:
130114

131115
```swift
132-
.navigationViewStackTransition(.slide, interactivity: .pan) // full-pan screen gestures!
116+
.navigationTransition(.slide, interactivity: .pan) // full-pan screen gestures!
133117
```
134118

135119
This even works to override its behavior while maintaining the **default system transition** in iOS:
136120

137121
```swift
138-
.navigationViewStackTransition(.default, interactivity: .pan) //
122+
.navigationTransition(.default, interactivity: .pan) //
139123
```
140124

141125
## Documentation

0 commit comments

Comments
 (0)