Skip to content

Commit 7ead5f0

Browse files
committed
WIP
1 parent fa782dd commit 7ead5f0

File tree

3 files changed

+64
-58
lines changed

3 files changed

+64
-58
lines changed

Examples/Showcase/Showcase.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
D5B829752999738200920EBD /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B829742999738200920EBD /* Helpers.swift */; };
1313
D5B864E82E72BF0F002F5243 /* ScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864E72E72BF0F002F5243 /* ScrollView.swift */; };
1414
D5B864EA2E72CE71002F5243 /* List.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864E92E72CE71002F5243 /* List.swift */; };
15+
D5B864EC2E72D9E1002F5243 /* Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864EB2E72D9E1002F5243 /* Navigation.swift */; };
1516
D5E3180329C132B6005847DC /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = D5E3180229C132B6005847DC /* SwiftUIIntrospect */; };
1617
/* End PBXBuildFile section */
1718

@@ -23,6 +24,7 @@
2324
D5B829742999738200920EBD /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
2425
D5B864E72E72BF0F002F5243 /* ScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollView.swift; sourceTree = "<group>"; };
2526
D5B864E92E72CE71002F5243 /* List.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = "<group>"; };
27+
D5B864EB2E72D9E1002F5243 /* Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Navigation.swift; sourceTree = "<group>"; };
2628
/* End PBXFileReference section */
2729

2830
/* Begin PBXFrameworksBuildPhase section */
@@ -62,6 +64,7 @@
6264
D53071F829983CEF00F1936C /* AppView.swift */,
6365
D5B864E92E72CE71002F5243 /* List.swift */,
6466
D5B864E72E72BF0F002F5243 /* ScrollView.swift */,
67+
D5B864EB2E72D9E1002F5243 /* Navigation.swift */,
6568
D5B829742999738200920EBD /* Helpers.swift */,
6669
);
6770
path = Showcase;
@@ -148,6 +151,7 @@
148151
D53071F929983CEF00F1936C /* AppView.swift in Sources */,
149152
D5B864E82E72BF0F002F5243 /* ScrollView.swift in Sources */,
150153
D5B829752999738200920EBD /* Helpers.swift in Sources */,
154+
D5B864EC2E72D9E1002F5243 /* Navigation.swift in Sources */,
151155
D5B864EA2E72CE71002F5243 /* List.swift in Sources */,
152156
D53071F729983CEF00F1936C /* App.swift in Sources */,
153157
);

Examples/Showcase/Showcase/AppView.swift

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ struct ContentView: View {
2727
ListShowcase()
2828
.tabItem { Text("List") }
2929
.tag(0)
30+
ScrollViewShowcase()
31+
.tabItem { Text("ScrollView") }
32+
.tag(1)
3033
#if !os(macOS)
3134
NavigationShowcase()
3235
.tabItem { Text("Navigation") }
33-
.tag(1)
36+
.tag(2)
3437
PresentationShowcase()
3538
.tabItem { Text("Presentation") }
36-
.tag(2)
37-
#endif
38-
ScrollViewShowcase()
39-
.tabItem { Text("ScrollView") }
4039
.tag(3)
41-
SimpleElementsShowcase()
42-
.tabItem { Text("Simple elements") }
40+
#endif
41+
ControlsShowcase()
42+
.tabItem { Text("Controls") }
4343
.tag(4)
4444
UIViewRepresentableShowcase()
4545
.tabItem { Text("UIViewRepresentables") }
@@ -58,56 +58,6 @@ struct ContentView: View {
5858
}
5959
}
6060

61-
struct NavigationShowcase: View {
62-
var body: some View {
63-
NavigationView {
64-
Text("Content")
65-
.modifier {
66-
if #available(iOS 15, tvOS 15, macOS 12, *) {
67-
$0.searchable(text: .constant(""))
68-
} else {
69-
$0
70-
}
71-
}
72-
#if os(iOS) || os(visionOS)
73-
.navigationBarTitle(Text("Customized"), displayMode: .inline)
74-
#elseif os(macOS)
75-
.navigationTitle(Text("Navigation"))
76-
#endif
77-
}
78-
#if os(iOS) || os(tvOS) || os(visionOS)
79-
.introspect(
80-
.navigationView(style: .stack),
81-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
82-
) { navigationController in
83-
navigationController.navigationBar.backgroundColor = .cyan
84-
}
85-
.introspect(
86-
.navigationView(style: .columns),
87-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
88-
) { splitViewController in
89-
#if os(visionOS)
90-
splitViewController.preferredDisplayMode = .oneBesideSecondary
91-
#else
92-
splitViewController.preferredDisplayMode = .oneOverSecondary
93-
#endif
94-
}
95-
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { navigationController in
96-
navigationController.navigationBar.backgroundColor = .cyan
97-
}
98-
.introspect(
99-
.searchField,
100-
on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
101-
) { searchBar in
102-
searchBar.backgroundColor = .red
103-
#if os(iOS)
104-
searchBar.searchTextField.backgroundColor = .purple
105-
#endif
106-
}
107-
#endif
108-
}
109-
}
110-
11161
#if !os(macOS)
11262
struct PresentationShowcase: View {
11363
@State var isSheetPresented = false
@@ -231,7 +181,7 @@ struct UIViewRepresentableShowcase: View {
231181
}
232182
}
233183

234-
struct SimpleElementsShowcase: View {
184+
struct ControlsShowcase: View {
235185

236186
@State private var textFieldValue = ""
237187
@State private var toggleValue = false
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import SwiftUI
2+
import SwiftUIIntrospect
3+
4+
struct NavigationShowcase: View {
5+
var body: some View {
6+
NavigationView {
7+
Text("Content")
8+
.modifier {
9+
if #available(iOS 15, tvOS 15, macOS 12, *) {
10+
$0.searchable(text: .constant(""))
11+
} else {
12+
$0
13+
}
14+
}
15+
#if os(iOS) || os(visionOS)
16+
.navigationBarTitle(Text("Customized"), displayMode: .inline)
17+
#elseif os(macOS)
18+
.navigationTitle(Text("Navigation"))
19+
#endif
20+
}
21+
#if os(iOS) || os(tvOS) || os(visionOS)
22+
.introspect(
23+
.navigationView(style: .stack),
24+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
25+
) { navigationController in
26+
navigationController.navigationBar.backgroundColor = .cyan
27+
}
28+
.introspect(
29+
.navigationView(style: .columns),
30+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
31+
) { splitViewController in
32+
#if os(visionOS)
33+
splitViewController.preferredDisplayMode = .oneBesideSecondary
34+
#else
35+
splitViewController.preferredDisplayMode = .oneOverSecondary
36+
#endif
37+
}
38+
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { navigationController in
39+
navigationController.navigationBar.backgroundColor = .cyan
40+
}
41+
.introspect(
42+
.searchField,
43+
on: .iOS(.v15, .v16, .v17, .v18, .v26), .tvOS(.v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
44+
) { searchBar in
45+
searchBar.backgroundColor = .red
46+
#if os(iOS)
47+
searchBar.searchTextField.backgroundColor = .purple
48+
#endif
49+
}
50+
#endif
51+
}
52+
}

0 commit comments

Comments
 (0)