import SwiftUI enum TabLabel: String { case bikes case trains case cars var title: String { rawValue.capitalized } var image: String { switch self { case .bikes: "bicycle" case .trains: "train.side.front.car" case .cars: "hand.draw.fill" } } } func tab(_ contentType: C.Type ) -> Tab { Tab(C.title, systemImage: C.image ) { C() } } struct ContentView: View { @AppStorage("tabSelection") var tabSelection = TabLabel.bikes var body: some View { //TabView(selection: $tabSelection) { TabView() { // Tab(TabLabel.bikes.title, systemImage: TabLabel.bikes.image) { // BikeView() // } // Tab(TabLabel.bikes.title, systemImage: TabLabel.trains.image) { // TrainView() // } // Tab("drücken", systemImage: TabLabel.cars.image) { // SwapperView() // } tab(ListView.self) tab(CountView.self) tab(BikeView.self) tab(TrainView.self) tab(SwapperView.self) tab(PaddingView.self) }.tabViewStyle(.sidebarAdaptable) } } #Preview { ContentView() }