Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Assets/RoutingBannerArt.png
Binary file not shown.
10 changes: 5 additions & 5 deletions ExampleApp/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//
// ContentView.swift
// Routing
// SwiftUI-Navigation
//
// Created by James Sedlacek on 5/7/25.
//

import Routing
import Navigation
import SwiftUI

@MainActor
public struct ContentView: View {
@Router private var router: [TestRoute] = []
@DestinationState private var destinations: [TestDestination] = []

public init() {}

public var body: some View {
RoutingView(path: $router) {
Navigator(path: $destinations) {
VStack {
Button("Push Screen", action: pushScreenAction)
}
Expand All @@ -24,7 +24,7 @@ public struct ContentView: View {

@MainActor
private func pushScreenAction() {
router.navigate(to: .example("Hello World!"))
destinations.navigate(to: .example("Hello World!"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ExampleApp/ExampleApp.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ExampleApp.swift
// Routing
// SwiftUI-Navigation
//
// Created by James Sedlacek on 5/7/25.
//
Expand Down
22 changes: 11 additions & 11 deletions ExampleApp/ExampleView.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Routing
import Navigation
import SwiftUI

public struct ExampleView: View {
@Router private var router: [TestRoute] = []
@State private var sheetRoute: SheetRoute? = nil
@DestinationState private var destinations: [TestDestination] = []
@State private var sheetDestination: SheetDestination? = nil
private let title: String

@MainActor
Expand All @@ -19,21 +19,21 @@ public struct ExampleView: View {

Button("Present Sheet", action: presentSheetAction)
}
.sheet(item: $sheetRoute)
.sheet(item: $sheetDestination)
}

@MainActor
private func pushScreenAction() {
router.navigate(to: .lastExample)
destinations.navigate(to: .lastExample)
}

private func presentSheetAction() {
sheetRoute = .sheetExample("It's a whole new world!")
sheetDestination = .sheetExample("It's a whole new world!")
}
}

public struct SheetExampleView: View {
@State private var route: AnotherRoute? = nil
@State private var destination: AnotherDestination? = nil
private let title: String

public init(title: String) {
Expand All @@ -47,12 +47,12 @@ public struct SheetExampleView: View {

Text(title)
}
.navigationDestination(item: $route)
.navigationDestination(item: $destination)
}
}

private func pushScreenAction() {
route = .anotherExample("Testing")
destination = .anotherExample("Testing")
}
}

Expand All @@ -69,7 +69,7 @@ public struct AnotherExampleView: View {
}

public struct LastExampleView: View {
@Router private var router: [TestRoute] = []
@DestinationState private var destinations: [TestDestination] = []

@MainActor
public init() {}
Expand All @@ -80,6 +80,6 @@ public struct LastExampleView: View {

@MainActor
private func navigateToRootAction() {
router.navigateToRoot()
destinations.navigateToRoot()
}
}
14 changes: 7 additions & 7 deletions ExampleApp/TestRoute.swift → ExampleApp/TestDestination.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// TestRoute.swift
// Routing
// TestDestination.swift
// SwiftUI-Navigation
//
// Created by James Sedlacek on 5/7/25.
//

import Routing
import Navigation
import SwiftUI

public enum TestRoute: Routable {
public enum TestDestination: Destination {
case example(String)
case lastExample

Expand All @@ -22,7 +22,7 @@ public enum TestRoute: Routable {
}
}

public enum SheetRoute: Routable {
public enum SheetDestination: Destination {
case sheetExample(String)

public var body: some View {
Expand All @@ -33,11 +33,11 @@ public enum SheetRoute: Routable {
}
}

extension SheetRoute: Identifiable {
extension SheetDestination: Identifiable {
public nonisolated var id: Self { self }
}

public enum AnotherRoute: Routable {
public enum AnotherDestination: Destination {
case anotherExample(String)

public var body: some View {
Expand Down
14 changes: 7 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription

let package = Package(
name: "Routing",
name: "SwiftUI-Navigation",
platforms: [
.iOS(.v16),
.macOS(.v13),
Expand All @@ -13,24 +13,24 @@ let package = Package(
],
products: [
.library(
name: "Routing",
targets: ["Routing"]
name: "Navigation",
targets: ["Navigation"]
),
.executable(
name: "ExampleApp",
targets: ["ExampleApp"]
)
],
targets: [
.target(name: "Routing"),
.target(name: "Navigation"),
.executableTarget(
name: "ExampleApp",
dependencies: ["Routing"],
dependencies: ["Navigation"],
path: "ExampleApp"
),
.testTarget(
name: "RoutingTests",
dependencies: ["Routing"]
name: "SwiftUINavigationTests",
dependencies: ["Navigation"]
),
]
)
Loading