diff --git a/Datadog/Example/Scenarios/RUM/SwiftUIInstrumentation/SwiftUIRootViewController.swift b/Datadog/Example/Scenarios/RUM/SwiftUIInstrumentation/SwiftUIRootViewController.swift index 269a3dfb23..90d837d201 100644 --- a/Datadog/Example/Scenarios/RUM/SwiftUIInstrumentation/SwiftUIRootViewController.swift +++ b/Datadog/Example/Scenarios/RUM/SwiftUIInstrumentation/SwiftUIRootViewController.swift @@ -26,21 +26,51 @@ class SwiftUIRootViewController: UIHostingController { struct RootView: View { var body: some View { TabView { + tabNavigationView + .tabItem { + Text("Navigation View") + } + + tabScreenView + .tabItem { + Text("Screen 100") + } + } + } + + @ViewBuilder + var tabNavigationView: some View { + if #available(iOS 14.5, *) { NavigationView { ScreenView(index: 1) - }.tabItem { - Text("Navigation View") } + } else if #available(iOS 14.2, *) { + NavigationView { + LazyVStack { + ScreenView(index: 1) + } + } + } else { + NavigationView { + ScreenView(index: 1) + } + } + } + @ViewBuilder + var tabScreenView: some View { + if #available(iOS 14.5, *) { ScreenView(index: 100) - .tabItem { - Text("Screen 100") + } else if #available(iOS 14.2, *) { + LazyVStack { + ScreenView(index: 100) } + } else { + ScreenView(index: 100) } } } - @available(iOS 13, *) /// A basic Screen View at a given index in the stack. ///