diff --git a/Examples/Showcase/Showcase/AppView.swift b/Examples/Showcase/Showcase/AppView.swift index 89622050..6b34087d 100644 --- a/Examples/Showcase/Showcase/AppView.swift +++ b/Examples/Showcase/Showcase/AppView.swift @@ -26,18 +26,24 @@ struct ContentView: View { TabView(selection: $selection) { ListShowcase() .tabItem { Label("List", systemImage: "1.circle") } + .tag(0) ScrollViewShowcase() .tabItem { Label("ScrollView", systemImage: "2.circle") } + .tag(1) #if !os(macOS) NavigationShowcase() .tabItem { Label("Navigation", systemImage: "3.circle") } + .tag(2) PresentationShowcase() .tabItem { Label("Presentation", systemImage: "4.circle") } + .tag(3) #endif ControlsShowcase() .tabItem { Label("Controls", systemImage: "5.circle") } + .tag(4) UIViewRepresentableShowcase() .tabItem { Label("UIViewRepresentable", systemImage: "6.circle") } + .tag(5) } #if os(iOS) || os(tvOS) .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { tabBarController in diff --git a/Examples/Showcase/Showcase/UIViewRepresentable.swift b/Examples/Showcase/Showcase/UIViewRepresentable.swift index 421d2fe8..c5b43255 100644 --- a/Examples/Showcase/Showcase/UIViewRepresentable.swift +++ b/Examples/Showcase/Showcase/UIViewRepresentable.swift @@ -2,21 +2,25 @@ import SwiftUI @_spi(Internals) import SwiftUIIntrospect struct UIViewRepresentableShowcase: View { + let colors: [Color] = [.red, .green, .blue] + var body: some View { VStack(spacing: 10) { - GenericViewRepresentable() - #if os(iOS) || os(tvOS) || os(visionOS) - .introspect( - .view, - on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) - ) { view in - view.backgroundColor = .cyan - } - #elseif os(macOS) - .introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { view in - view.layer?.backgroundColor = NSColor.cyan.cgColor - } - #endif + ForEach(colors, id: \.self) { color in + GenericViewRepresentable() + #if os(iOS) || os(tvOS) || os(visionOS) + .introspect( + .view, + on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26) + ) { view in + view.backgroundColor = UIColor(color) + } + #elseif os(macOS) + .introspect(.view, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { view in + view.layer?.backgroundColor = NSColor(color).cgColor + } + #endif + } } .padding() #if os(iOS) || os(tvOS) || os(visionOS)