Loading repository data…
Loading repository data…
POIKUS-LLC / repository
PKSNavigation is a simple yet powerful navigation framework designed for SwiftUI applications. It helps you manage complex navigation flows with ease, supporting stack-based navigation, sheet presentations, and full-screen covers.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
PKSNavigation is a simple yet powerful navigation framework designed for SwiftUI applications. It helps you manage complex navigation flows with ease, supporting stack-based navigation, sheet presentations, and full-screen covers. Whether you're building a small app or a large-scale project, PKSNavigation streamlines your navigation logic, making your code cleaner and more maintainable.
A demo app is available in the PKSNavigationDemo repository. Please check it out for more examples and usage scenarios.
AppleStoreDemo is a mock Apple Store application designed to demonstrate the integration and capabilities of the PKSNavigation framework
You can install PKSNavigation using the Swift Package Manager:
Here's a simple example demonstrating how to use PKSNavigation for stack-based navigation:
import SwiftUI
import PKSNavigation
struct ContentView: View {
@StateObject private var navigationManager = PKSNavigationManager()
var body: some View {
PKSNavigationContainer(navigationManager: navigationManager) {
HomeView()
}
}
}
struct HomeView: View {
@EnvironmentObject var navigationManager: PKSNavigationManager
var body: some View {
VStack {
Text("Home View")
.font(.largeTitle)
Button("Go to Detail in Stack") {
navigationManager.navigate(to: RootPages.detail)
}
Button("Go to Detail on Sheet") {
navigationManager.navigate(to: RootPages.detail, presentation: .sheet)
}
Button("Go to Detail in Stack") {
navigationManager.navigate(to: RootPages.detail, presentation: .cover)
}
}
}
}
struct DetailView: View {
@Environment(\.pksDismiss) var dismiss
var body: some View {
VStack {
Text("Detail View")
.font(.largeTitle)
Button("Go Back") {
dismiss()
}
}
}
}
// Define your pages conforming to PKSPage
enum RootPages: PKSPage {
case detail
var description: String {
switch self {
case detail:
return "Detail Page"
}
}
@ViewBuilder
var body: some View {
switch self {
case detail:
DetailView()
}
}
}
PKSNavigation simplifies navigation in SwiftUI by providing three main navigation types:
All these navigation types are managed through a single, unified API, making your navigation logic consistent and easy to handle. PKSNavigation enhances the fundamental navigation mechanisms by allowing seamless integration and interaction between different navigation styles. This is achieved through intelligent management of navigation states and presentation methods, ensuring that transitions between navigation types are smooth and intuitive.
PKSNavigation builds upon the basic navigation types by offering enhanced capabilities:
Enhancements with PKSNavigation:
Enhancements with PKSNavigation:
registerSheetStack().Enhancements with PKSNavigation:
registerCoverStack().PKSNavigationManager intelligently manages the switching between different presentation methods to ensure smooth and consistent navigation flows within your app. Here's how the logic works:
Single Unified API: All navigation actions are performed through the navigate(to:presentation:isRoot:) method, regardless of the current presentation method. This simplifies the navigation logic by providing a consistent interface.
Active Presentation Tracking: The navigation manager keeps track of the currently active presentation method (.stack, .sheet, .cover). This determines which navigation stack (rootPath, sheetPath, or coverPath) should handle the navigation action.
Context-Aware Navigation:
.stack, the navigation action affects the root stack..sheet, the navigation action affects the sheet's navigation stack (sheetPath). If a sheet stack is not registered, the action is delegated to the parent manager..cover, the navigation action affects the cover's navigation stack (coverPath). If a cover stack is not registered, the action is delegated to the parent manager.Nested Presentation Handling:
Registration of Additional Stacks: By registering sheet and cover stacks using registerSheetStack() and registerCoverStack(), you inform the navigation manager to handle multiple sheets or covers, each with their own navigation stacks. This enables presenting multiple sheets or covers simultaneously without navigation conflicts.
Delegation to Parent Managers: For hierarchical or nested navigation flows, navigation actions can be delegated to a parent navigation manager. This allows for organized navigation management in large-scale applications with complex navigation requirements.
Automatic Presentation Method Switching: The navigation manager automatically switches the active presentation method based on the current navigation state and the type of navigation action being performed. This ensures that navigation transitions are handled smoothly without requiring manual intervention from the developer.
Example Scenario:
.stack), allowing users to navigate from Home to Detail views..sheet). The sheet itself has its own stack-based navigation, allowing users to navigate within the sheet..cover). The cover also maintains its own stack-based navigation.