Skip to content

Commit 25a7be4

Browse files
lks574interactord
authored andcommitted
fix: Singnavigator - Design
1 parent 3efc6a7 commit 25a7be4

13 files changed

Lines changed: 316 additions & 282 deletions

File tree

Examples/SingleNavigator/01-SingleBasic/01-SingleBasic.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
29704AD62B450B5800418967 /* Page1View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29704ACC2B450B5800418967 /* Page1View.swift */; };
2323
9328462B2B450372000243AC /* AppDependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9328462A2B450372000243AC /* AppDependency.swift */; };
2424
9328462D2B45037F000243AC /* AppRouterGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9328462C2B45037F000243AC /* AppRouterGroup.swift */; };
25+
932D1E852B46A988000E50C3 /* PathIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D1E842B46A988000E50C3 /* PathIndicator.swift */; };
2526
933012962B45634400893C91 /* LinkNavigator in Frameworks */ = {isa = PBXBuildFile; productRef = 933012952B45634400893C91 /* LinkNavigator */; };
2627
933012992B45634F00893C91 /* PageTemplate in Frameworks */ = {isa = PBXBuildFile; productRef = 933012982B45634F00893C91 /* PageTemplate */; };
2728
/* End PBXBuildFile section */
@@ -44,6 +45,7 @@
4445
29704ACC2B450B5800418967 /* Page1View.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Page1View.swift; sourceTree = "<group>"; };
4546
9328462A2B450372000243AC /* AppDependency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDependency.swift; sourceTree = "<group>"; };
4647
9328462C2B45037F000243AC /* AppRouterGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppRouterGroup.swift; sourceTree = "<group>"; };
48+
932D1E842B46A988000E50C3 /* PathIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PathIndicator.swift; sourceTree = "<group>"; };
4749
/* End PBXFileReference section */
4850

4951
/* Begin PBXFrameworksBuildPhase section */
@@ -78,6 +80,7 @@
7880
29141E0F2B44E13900D3ABE7 /* SingleBasic */ = {
7981
isa = PBXGroup;
8082
children = (
83+
932D1E832B46A97C000E50C3 /* Component */,
8184
29704ABD2B450B5800418967 /* Page */,
8285
29141E102B44E13900D3ABE7 /* SingleBasicApp.swift */,
8386
9328462A2B450372000243AC /* AppDependency.swift */,
@@ -154,6 +157,14 @@
154157
path = Page1;
155158
sourceTree = "<group>";
156159
};
160+
932D1E832B46A97C000E50C3 /* Component */ = {
161+
isa = PBXGroup;
162+
children = (
163+
932D1E842B46A988000E50C3 /* PathIndicator.swift */,
164+
);
165+
path = Component;
166+
sourceTree = "<group>";
167+
};
157168
/* End PBXGroup section */
158169

159170
/* Begin PBXNativeTarget section */
@@ -236,6 +247,7 @@
236247
9328462B2B450372000243AC /* AppDependency.swift in Sources */,
237248
29704ACD2B450B5800418967 /* HomeView.swift in Sources */,
238249
29704AD02B450B5800418967 /* Page2RouteBuilder.swift in Sources */,
250+
932D1E852B46A988000E50C3 /* PathIndicator.swift in Sources */,
239251
29704AD32B450B5800418967 /* Page4View.swift in Sources */,
240252
29704AD62B450B5800418967 /* Page1View.swift in Sources */,
241253
29704ACF2B450B5800418967 /* Page2View.swift in Sources */,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import SwiftUI
2+
3+
public struct PathIndicator: View {
4+
let currentPath: String
5+
6+
public var body: some View {
7+
VStack(spacing: 16) {
8+
Text("currentPath")
9+
.font(.headline)
10+
11+
Text(currentPath)
12+
.font(.subheadline)
13+
}
14+
.padding()
15+
.frame(maxWidth: .infinity)
16+
.background(
17+
RoundedRectangle(cornerRadius: 12).fill(.green.opacity(0.3)))
18+
.padding(.horizontal)
19+
}
20+
}

Examples/SingleNavigator/01-SingleBasic/SingleBasic/Page/Home/HomeView.swift

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,50 @@ struct HomeView: View {
66
let navigator: RootNavigatorType
77

88
var body: some View {
9-
ScrollView {
10-
VStack(spacing: 40) {
11-
Button(action: {
12-
navigator.backOrNext(linkItem: .init(path: "page1"), isAnimated: true)
13-
}) {
14-
Text("go to next Page")
15-
}
16-
17-
Button(action: {
18-
navigator.backOrNext(linkItem: .init(pathList: ["page1", "page2", "page3"]), isAnimated: true)
19-
}) {
20-
Text("go to last Page")
21-
}
22-
23-
Button(action: {
24-
let alertModel = Alert(
25-
title: "Title",
26-
message: "message",
27-
buttons: [.init(title: "OK", style: .default, action: { print("OK tapped") })],
28-
flagType: .default)
29-
navigator.alert(target: .default, model: alertModel)
30-
}) {
31-
Text("show alert")
32-
.foregroundColor(.orange)
33-
}
34-
35-
Button(action: {
36-
navigator.sheet(linkItem: .init(pathList: ["page1", "page2"]), isAnimated: true)
37-
}) {
38-
Text("open Page 2 as Sheet")
39-
.foregroundColor(.purple)
40-
}
41-
42-
Button(action: {
43-
navigator.fullSheet(linkItem: .init(pathList: ["page1", "page2"]), isAnimated: true, prefersLargeTitles: true)
44-
}) {
45-
Text("open Page 2 as Full Screen Sheet")
46-
.foregroundColor(.purple)
47-
}
48-
49-
Spacer()
9+
VStack(spacing: 30) {
10+
PathIndicator(currentPath: navigator.getCurrentPaths().joined(separator: " -> "))
11+
.padding(.top, 32)
12+
13+
Button(action: {
14+
navigator.backOrNext(linkItem: .init(path: "page1"), isAnimated: true)
15+
}) {
16+
Text("go to next Page")
5017
}
51-
.padding()
18+
19+
Button(action: {
20+
navigator.backOrNext(linkItem: .init(pathList: ["page1", "page2", "page3"]), isAnimated: true)
21+
}) {
22+
Text("go to last Page")
23+
}
24+
25+
Button(action: {
26+
let alertModel = Alert(
27+
title: "Title",
28+
message: "message",
29+
buttons: [.init(title: "OK", style: .default, action: { print("OK tapped") })],
30+
flagType: .default)
31+
navigator.alert(target: .default, model: alertModel)
32+
}) {
33+
Text("show alert")
34+
.foregroundColor(.orange)
35+
}
36+
37+
Button(action: {
38+
navigator.sheet(linkItem: .init(pathList: ["page1", "page2"]), isAnimated: true)
39+
}) {
40+
Text("open Page 2 as Sheet")
41+
.foregroundColor(.purple)
42+
}
43+
44+
Button(action: {
45+
navigator.fullSheet(linkItem: .init(pathList: ["page1", "page2"]), isAnimated: true, prefersLargeTitles: true)
46+
}) {
47+
Text("open Page 2 as Full Screen Sheet")
48+
.foregroundColor(.purple)
49+
}
50+
51+
Spacer()
5252
}
53+
.padding()
5354
}
5455
}

Examples/SingleNavigator/01-SingleBasic/SingleBasic/Page/Page1/Page1View.swift

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,44 @@ struct Page1View: View {
66
let navigator: RootNavigatorType
77

88
var body: some View {
9-
ScrollView {
10-
VStack(spacing: 40) {
11-
Text("1")
12-
.font(.system(size: 70, weight: .thin))
13-
14-
Text(navigator.getCurrentPaths().map { $0.replacingOccurrences(of: "page", with: "") }.joined(separator: ""))
15-
.padding()
16-
17-
Button(action: {
18-
navigator.next(linkItem: .init(path: "page2"), isAnimated: true)
19-
}) {
20-
Text("go to next Page")
21-
}
22-
23-
Button(action: {
24-
navigator.backOrNext(linkItem: .init(path: Bool.random() ? "home" : "page2"), isAnimated: true)
25-
}) {
26-
Text("backOrNext")
27-
}
28-
29-
Button(action: {
30-
navigator.rootBackOrNext(linkItem: .init(path: Bool.random() ? "home" : "page2"), isAnimated: true)
31-
}) {
32-
Text("**root** backOrNext")
33-
}
34-
35-
Button(action: {
36-
navigator.back(isAnimated: true)
37-
}) {
38-
Text("back")
39-
}
40-
41-
Button(action: {
42-
navigator.close(isAnimated: true, completeAction: { })
43-
}) {
44-
Text("close (only available in modal)")
45-
.foregroundColor(.red)
46-
}
47-
48-
Spacer()
9+
VStack(spacing: 30) {
10+
PathIndicator(currentPath: navigator.getCurrentPaths().joined(separator: " -> "))
11+
.padding(.top, 32)
12+
13+
Button(action: {
14+
navigator.next(linkItem: .init(path: "page2"), isAnimated: true)
15+
}) {
16+
Text("go to next Page")
4917
}
50-
.padding()
18+
19+
Button(action: {
20+
navigator.backOrNext(linkItem: .init(path: Bool.random() ? "home" : "page2"), isAnimated: true)
21+
}) {
22+
Text("backOrNext")
23+
}
24+
25+
Button(action: {
26+
navigator.rootBackOrNext(linkItem: .init(path: Bool.random() ? "home" : "page2"), isAnimated: true)
27+
}) {
28+
Text("**root** backOrNext")
29+
}
30+
31+
Button(action: {
32+
navigator.back(isAnimated: true)
33+
}) {
34+
Text("back")
35+
}
36+
37+
Button(action: {
38+
navigator.close(isAnimated: true, completeAction: { })
39+
}) {
40+
Text("close (only available in modal)")
41+
.foregroundColor(.red)
42+
}
43+
44+
Spacer()
5145
}
46+
.padding()
5247
}
5348
}
5449

Examples/SingleNavigator/01-SingleBasic/SingleBasic/Page/Page2/Page2View.swift

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,41 @@ struct Page2View: View {
77
@State private var paths: [String] = []
88

99
var body: some View {
10-
ScrollView {
11-
VStack(spacing: 40) {
12-
Text("2")
13-
.font(.system(size: 70, weight: .thin))
14-
15-
Text(paths.map { $0.replacingOccurrences(of: "page", with: "") }.joined(separator: ""))
16-
.padding()
17-
18-
Button(action: {
19-
navigator.next(linkItem: .init(path: "page3"), isAnimated: true)
20-
}) {
21-
Text("go to next Page")
22-
}
23-
24-
Button(action: {
25-
navigator.rootNext(linkItem: .init(path: "page3"), isAnimated: true)
26-
}) {
27-
Text("**root** next")
28-
}
29-
30-
Button(action: {
31-
navigator.remove(pathList: ["page1"])
32-
paths = navigator.getCurrentPaths()
33-
}) {
34-
Text("remove Page 1")
35-
.foregroundColor(.red)
36-
}
37-
38-
Button(action: {
39-
navigator.back(isAnimated: true)
40-
}) {
41-
Text("back")
42-
}
43-
44-
Spacer()
10+
VStack(spacing: 30) {
11+
PathIndicator(currentPath: navigator.getCurrentPaths().joined(separator: " -> "))
12+
.padding(.top, 32)
13+
14+
Button(action: {
15+
navigator.next(linkItem: .init(path: "page3"), isAnimated: true)
16+
}) {
17+
Text("go to next Page")
4518
}
46-
.padding()
47-
.onAppear {
19+
20+
Button(action: {
21+
navigator.rootNext(linkItem: .init(path: "page3"), isAnimated: true)
22+
}) {
23+
Text("**root** next")
24+
}
25+
26+
Button(action: {
27+
navigator.remove(pathList: ["page1"])
4828
paths = navigator.getCurrentPaths()
29+
}) {
30+
Text("remove Page 1")
31+
.foregroundColor(.red)
4932
}
33+
34+
Button(action: {
35+
navigator.back(isAnimated: true)
36+
}) {
37+
Text("back")
38+
}
39+
40+
Spacer()
41+
}
42+
.padding()
43+
.onAppear {
44+
paths = navigator.getCurrentPaths()
5045
}
5146
}
5247
}

0 commit comments

Comments
 (0)