Skip to content

Commit d704f19

Browse files
committed
Initial commit
0 parents  commit d704f19

File tree

12 files changed

+845
-0
lines changed

12 files changed

+845
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## User settings
6+
xcuserdata/
7+
8+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9+
*.xcscmblueprint
10+
*.xccheckout
11+
12+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
13+
build/
14+
DerivedData/
15+
*.moved-aside
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
25+
## Obj-C/Swift specific
26+
*.hmap
27+
28+
## App packaging
29+
*.ipa
30+
*.dSYM.zip
31+
*.dSYM
32+
33+
## Playgrounds
34+
timeline.xctimeline
35+
playground.xcworkspace
36+
37+
# Swift Package Manager
38+
#
39+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40+
# Packages/
41+
# Package.pins
42+
# Package.resolved
43+
# *.xcodeproj
44+
#
45+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
46+
# hence it is not needed unless you have added a package configuration file to your project
47+
# .swiftpm
48+
49+
.build/
50+
51+
# CocoaPods
52+
#
53+
# We recommend against adding the Pods directory to your .gitignore. However
54+
# you should judge for yourself, the pros and cons are mentioned at:
55+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
56+
#
57+
# Pods/
58+
#
59+
# Add this line if you want to avoid checking in source code from the Xcode workspace
60+
# *.xcworkspace
61+
62+
# Carthage
63+
#
64+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
65+
# Carthage/Checkouts
66+
67+
Carthage/Build/
68+
69+
# Accio dependency management
70+
Dependencies/
71+
.accio/
72+
73+
# fastlane
74+
#
75+
# It is recommended to not store the screenshots in the git repo.
76+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
77+
# For more information about the recommended setup visit:
78+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
79+
80+
fastlane/report.xml
81+
fastlane/Preview.html
82+
fastlane/screenshots/**/*.png
83+
fastlane/test_output
84+
85+
# Code Injection
86+
#
87+
# After new code Injection tools there's a generated folder /iOSInjectionProject
88+
# https://github.com/johnno1962/injectionforxcode
89+
90+
iOSInjectionProject/

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# d3-custom-navigation-swiftui
2+
Cstom navigation swiftui
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "2x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "83.5x83.5"
82+
},
83+
{
84+
"idiom" : "ios-marketing",
85+
"scale" : "1x",
86+
"size" : "1024x1024"
87+
},
88+
{
89+
"idiom" : "mac",
90+
"scale" : "1x",
91+
"size" : "16x16"
92+
},
93+
{
94+
"idiom" : "mac",
95+
"scale" : "2x",
96+
"size" : "16x16"
97+
},
98+
{
99+
"idiom" : "mac",
100+
"scale" : "1x",
101+
"size" : "32x32"
102+
},
103+
{
104+
"idiom" : "mac",
105+
"scale" : "2x",
106+
"size" : "32x32"
107+
},
108+
{
109+
"idiom" : "mac",
110+
"scale" : "1x",
111+
"size" : "128x128"
112+
},
113+
{
114+
"idiom" : "mac",
115+
"scale" : "2x",
116+
"size" : "128x128"
117+
},
118+
{
119+
"idiom" : "mac",
120+
"scale" : "1x",
121+
"size" : "256x256"
122+
},
123+
{
124+
"idiom" : "mac",
125+
"scale" : "2x",
126+
"size" : "256x256"
127+
},
128+
{
129+
"idiom" : "mac",
130+
"scale" : "1x",
131+
"size" : "512x512"
132+
},
133+
{
134+
"idiom" : "mac",
135+
"scale" : "2x",
136+
"size" : "512x512"
137+
}
138+
],
139+
"info" : {
140+
"author" : "xcode",
141+
"version" : 1
142+
}
143+
}

Shared/Assets.xcassets/Contents.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

Shared/ContentView.swift

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//
2+
// ContentView.swift
3+
// Shared
4+
//
5+
// Created by Igor Shelopaev on 09.06.2022.
6+
// The link to the code is under the video
7+
//
8+
9+
10+
import SwiftUI
11+
12+
//experimenting with nav link
13+
struct ContentView: View {
14+
15+
@State var route : Router = .empty
16+
17+
var body: some View {
18+
NavigationView{
19+
VStack{
20+
Button("go1") { route = .go1}
21+
Button("go2") { route = .go2}
22+
Button("go3") { route = .go3}
23+
}.navigation(route: $route)
24+
}.navigationViewStyle(.stack)
25+
}
26+
}
27+
28+
extension View{
29+
@ViewBuilder
30+
func navigation(route : Binding<Router>) -> some View{
31+
if route.wrappedValue != .empty{
32+
modifier(NavigationModifire(route: route))
33+
}else { self }
34+
}
35+
}
36+
37+
// MARK: - define view modifire
38+
struct NavigationModifire : ViewModifier{
39+
40+
@State var isActive : Bool = true
41+
42+
@Binding var route : Router
43+
44+
func body(content: Content) -> some View {
45+
content
46+
.background{
47+
NavigationLink(destination : route.builder, isActive: $isActive ){
48+
EmptyView()
49+
}.hidden()
50+
}
51+
.onChange(of: isActive){
52+
if $0 == false { route = .empty }
53+
}
54+
}
55+
56+
}
57+
58+
// MARK: - Define routes
59+
60+
enum Router {
61+
case go1
62+
case go2
63+
case go3
64+
case empty
65+
66+
@ViewBuilder
67+
var builder: some View {
68+
switch(self) {
69+
case .go1: SubView(text: "go1")
70+
case .go2: SubView(text: "go2")
71+
case .go3: SubView(text: "go3")
72+
default: EmptyView()
73+
}
74+
}
75+
}
76+
77+
// MARK: - Define sub view
78+
79+
struct SubView: View {
80+
81+
let text: String
82+
83+
var body: some View {
84+
Text("\(text)")
85+
}
86+
}
87+
88+
89+
90+
struct ContentView_Previews: PreviewProvider {
91+
static var previews: some View {
92+
ContentView()
93+
}
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// d3_custom_navigation_swiftuiApp.swift
3+
// Shared
4+
//
5+
// Created by Igor Shelopaev on 09.06.2022.
6+
//
7+
8+
import SwiftUI
9+
10+
@main
11+
struct d3_custom_navigation_swiftuiApp: App {
12+
var body: some Scene {
13+
WindowGroup {
14+
ContentView()
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)