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
87 changes: 0 additions & 87 deletions Documentation.docc/Documentation.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"colors" : [
{
"color" : {
"platform" : "universal",
"reference" : "systemMintColor"
},
"idiom" : "universal"
}
],
Expand Down
84 changes: 56 additions & 28 deletions NavigateTesting/NavigateTesting/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
struct ContentView: View {

@State
var router = Router()
private var router = Router()

var body: some View {
ModalStack(path: $router.modalPath) {
Expand All @@ -20,57 +20,85 @@ struct ContentView: View {
NavigationStack(path: $router.homeTabPath) {
FeatureAView()
.myNavigtationDestinations()
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
SheetLink(destination: .settings) {
Image(systemName: "gearshape")
}
}
}
}
}

Tab("Tab", systemImage: "pencil", value: .tab) {
Tab("Feature B", systemImage: "pencil", value: .tab) {
NavigationStack(path: $router.tabPath) {
FeatureAView()
.myNavigtationDestinations()
}
}
}
.modalDestination(for: MyDestination.self) { destination in
switch destination {
case .featureA:
NavigationStack {
FeatureAView()
.myNavigtationDestinations()
}
case .featureB:
NavigationStack {
FeatureBView()
.myNavigtationDestinations()
}
case .settings:
NavigationStack {
SettingsView()
.myNavigtationDestinations()
}
case .subSettings:
NavigationStack {
SubSettingsView()
.myNavigtationDestinations()
}
}
}
.myModalDestinations()
}
.environment(router)
}
}

extension View {

/// SwiftUI navigation destination convenience
func myNavigtationDestinations() -> some View {
self.navigationDestination(for: MyDestination.self) { destination in
switch destination {
case .featureA:
FeatureAView()
case .featureB:
FeatureBView()
case .featureC:
FeatureCView()
case .featureD:
FeatureDView()
case .settings:
SettingsView()
case .subSettings:
SubSettingsView()
case .profile:
ProfileView()
}
}
}

/// All ModalDestinations wrapped in NavigationStack to support SwiftUI navigation and toolbar
func myModalDestinations() -> some View {
self.modalDestination(for: MyDestination.self) { destination in
switch destination {
case .featureA:
NavigationStack {
FeatureAView()
.myNavigtationDestinations()
}
case .featureB:
NavigationStack {
FeatureBView()
.myNavigtationDestinations()
}
case .featureC:
NavigationStack {
FeatureCView()
.myNavigtationDestinations()
}
case .featureD:
NavigationStack {
FeatureDView()
.myNavigtationDestinations()
}
case .settings:
NavigationStack {
SettingsView()
.myNavigtationDestinations()
}
case .profile:
NavigationStack {
ProfileView()
.myNavigtationDestinations()
}
}
}
}
Expand Down
26 changes: 14 additions & 12 deletions NavigateTesting/NavigateTesting/Features/FeatureAView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import SwiftUI

struct FeatureAView: View {
var body: some View {
Text("Feature A")

NavigationLink(destination: .featureB) {
Text("Go to feature b")
}

SheetLink(destination: .featureB) {
Text("Sheet to feature b")
}

FullScreenCoverLink(destination: .settings) {
Text("Go to settings :)")
List {
NavigationLink(destination: .featureB) {
Text("Go to feature B")
}
SheetLink(destination: .featureB) {
Text("Sheet to feature B")
}
FullScreenCoverLink(destination: .featureB) {
Text("FullScreenCover to feature B")
}
}
.navigationTitle("Feature A")
.navigationBarTitleDisplayMode(.inline)
}
}

Expand Down
24 changes: 14 additions & 10 deletions NavigateTesting/NavigateTesting/Features/FeatureBView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ struct FeatureBView: View {
var router: Router

var body: some View {
Text("Feature B")

SheetLink(destination: .featureB) {
Text("Feature B again ...")
}

Button("Dismiss all") {
router.homeTabPath = []
router.tabPath = []
router.modalPath = []
List {
NavigationLink(destination: .featureC) {
Text("Go to feature C")
}

SheetLink(destination: .featureC) {
Text("Sheet to feature C")
}

FullScreenCoverLink(destination: .featureC) {
Text("FullScreenCover to feature C")
}
}
.navigationTitle("Feature B")
.navigationBarTitleDisplayMode(.inline)
}
}

Expand Down
37 changes: 37 additions & 0 deletions NavigateTesting/NavigateTesting/Features/FeatureCView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// FeatureCView.swift
// NavigateTesting
//
// Created by Alexander Kauer on 17.07.25.
//

import Navigate
import SwiftUI

struct FeatureCView: View {

@Environment(Router.self)
var router: Router

var body: some View {
List {
NavigationLink(destination: .featureD) {
Text("Go to feature D")
}

SheetLink(destination: .featureD) {
Text("Sheet to feature D")
}

FullScreenCoverLink(destination: .featureD) {
Text("FullScreenCover to feature D")
}
}
.navigationTitle("Feature C")
.navigationBarTitleDisplayMode(.inline)
}
}

#Preview {
FeatureBView()
}
31 changes: 31 additions & 0 deletions NavigateTesting/NavigateTesting/Features/FeatureDView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// FeatureDView.swift
// NavigateTesting
//
// Created by Alexander Kauer on 17.07.25.
//

import Navigate
import SwiftUI

struct FeatureDView: View {

@Environment(Router.self)
var router: Router

var body: some View {
List {
Button("Dismiss modal path") {
router.homeTabPath = []
router.tabPath = []
router.modalPath = []
}
}
.navigationTitle("Feature D")
.navigationBarTitleDisplayMode(.inline)
}
}

#Preview {
FeatureBView()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import SwiftUI

struct SubSettingsView: View {
struct ProfileView: View {
var body: some View {
Text("Sub Settings")
.navigationTitle("Sub Settings")
List {

}
.navigationTitle("Profile View")
}
}

#Preview {
SubSettingsView()
ProfileView()
}
Loading
Loading