ios – Is there a motive to place the TabView within the App part fairly the primary ContentView based mostly on performance?

[ad_1]

Drawback

I needed to search out out if there was a standard sample with TabViews in a SwiftUI’s construction.

My thought course of was that this must be contained inside the primary ContentView if an app has an onboarding sequence, because the onboarding sequence shouldn’t have a TabView. However then I noticed that the Onboarding Screens/Views may simply be offered as a sheet full display screen modally on the ContentView (or primary touchdown View).

I additionally checked out Apple’s Human Interface Pointers, and I didn’t appear to search out something significantly helpful.

That is utterly standard based mostly which must be backed up with some reasoning on how one must be used over one other.

Code:

TabView in App

import SwiftUI

@primary
struct Globo_FitnessApp: App {
    var physique: some Scene {
        WindowGroup {
            TabView {
                ContentView()
                    .tabItem {
                        Label("Dwelling", systemImage: "home")
                    }
                
                BMICalculatorView()
                    .tabItem {
                        Label("BMI", systemImage: "scalemass.fill")
                    }
            }
        }
    }
}

TabView in primary ContentView

import SwiftUI

@primary
struct Globo_FitnessApp: App {
    var physique: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    var physique: some View {
        TabView {
            HomeView()
                .tabItem {
                    Label("Dwelling", systemImage: "home")
                }
                
                BMICalculatorView()
                    .tabItem {
                        Label("BMI", systemImage: "scalemass.fill")
                    }
            }
    }
}

struct HomeView: View { }

Thanks a lot, and have an ideal day!

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *