[WIP]
This library provides a custom container view for SwiftUI that offers an alternative to the standard NavigationStack. It aims to improve the customizability of transitions during screen navigation by moving away from the behaviors of UINavigationController and UINavigationBar.
- Customizable transitions during screen navigation
- Contextual animations similar to iOS home screen app icons and app screens
To use this library, you'll need to work with three main symbols: Stack, StackLink, and StackUnwindLink.
- Import the SwiftUIStack module in your SwiftUI view file:
import SwiftUIStack
- Use the Stack container in your view hierarchy:
var body: some View {
Stack {
// Your views here...
}
}
- Create navigation links using StackLink with your desired transition and destination:
StackLink(transition: .slide, value: someValue) {
Text("Navigate to detail view")
}
You can also set the matched transition in the transition parameter using a unique identifier and a namespace:
StackLink(transition: .matched(identifier: user.id, in: local), value: someValue) {
Text("Navigate to detail view with matched transition")
}
- Optionally, use StackUnwindLink to create a navigation link back to the previous view:
StackUnwindLink {
Text("Back to previous view")
}
In stacked views, you can access the unwindContext as an EnvironmentValue. You can pass the unwindContext to a StackUnwindLink. This allows you to explicitly specify the stack that triggers the unwind.
@Environment(\.stackUnwindContext) var unwindContext
StackUnwindLink(target: .specific(unwindContext)) {
Text("Back to Menu")
}
StackUnwindLink now supports different modes for navigation. To navigate back to the root of the target stack, use the .all mode.
StackUnwindLink(mode: .all) {
Text("Back to Root")
}
This technique is useful for nested stacks when you need to send a message across multiple levels of the hierarchy. By using the unwindContext in conjunction with StackUnwindLink, you can effectively communicate between nested stacks and navigate through different levels of the view hierarchy.
(Include instructions for installation via Swift Package Manager, CocoaPods, or other methods, if applicable)
(Include instructions for contributing to the project, such as opening issues, submitting pull requests, and any other relevant information)
(Include information about the project's license)