Skip to content

Commit e756832

Browse files
authored
Fix macOS Showcase (#480)
1 parent 6d9e829 commit e756832

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

Examples/Showcase/Showcase/AppView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ struct ContentView: View {
2626
TabView(selection: $selection) {
2727
ListShowcase()
2828
.tabItem { Label("List", systemImage: "1.circle") }
29+
.tag(0)
2930
ScrollViewShowcase()
3031
.tabItem { Label("ScrollView", systemImage: "2.circle") }
32+
.tag(1)
3133
#if !os(macOS)
3234
NavigationShowcase()
3335
.tabItem { Label("Navigation", systemImage: "3.circle") }
36+
.tag(2)
3437
PresentationShowcase()
3538
.tabItem { Label("Presentation", systemImage: "4.circle") }
39+
.tag(3)
3640
#endif
3741
ControlsShowcase()
3842
.tabItem { Label("Controls", systemImage: "5.circle") }
43+
.tag(4)
3944
UIViewRepresentableShowcase()
4045
.tabItem { Label("UIViewRepresentable", systemImage: "6.circle") }
46+
.tag(5)
4147
}
4248
#if os(iOS) || os(tvOS)
4349
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { tabBarController in

Examples/Showcase/Showcase/UIViewRepresentable.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ import SwiftUI
22
@_spi(Internals) import SwiftUIIntrospect
33

44
struct UIViewRepresentableShowcase: View {
5+
let colors: [Color] = [.red, .green, .blue]
6+
57
var body: some View {
68
VStack(spacing: 10) {
7-
GenericViewRepresentable()
8-
#if os(iOS) || os(tvOS) || os(visionOS)
9-
.introspect(
10-
.view,
11-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
12-
) { view in
13-
view.backgroundColor = .cyan
14-
}
15-
#elseif os(macOS)
16-
.introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { view in
17-
view.layer?.backgroundColor = NSColor.cyan.cgColor
18-
}
19-
#endif
9+
ForEach(colors, id: \.self) { color in
10+
GenericViewRepresentable()
11+
#if os(iOS) || os(tvOS) || os(visionOS)
12+
.introspect(
13+
.view,
14+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
15+
) { view in
16+
view.backgroundColor = UIColor(color)
17+
}
18+
#elseif os(macOS)
19+
.introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { view in
20+
view.layer?.backgroundColor = NSColor(color).cgColor
21+
}
22+
#endif
23+
}
2024
}
2125
.padding()
2226
#if os(iOS) || os(tvOS) || os(visionOS)

0 commit comments

Comments
 (0)