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

[ad_1]

Drawback

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

My thought course of was that this needs to 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 might simply be introduced as a sheet full display screen modally on the ContentView (or most important touchdown View).

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

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

Code:

TabView in App

import SwiftUI

@most important
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 most important ContentView

import SwiftUI

@most important
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 a fantastic day!

[ad_2]

Leave a Reply