Repository Public
1//2// Fabri-Ka iOS v23// File: FabriKa/App/RootView.swift4// Description: onglets adaptatifs (barre d'onglets sur iPhone, barre latérale sur iPad) et destinations partagées.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8//910import SwiftUI1112struct RootView: View {13 @Environment(AppModel.self) private var model14 @Environment(Library.self) private var library1516 var body: some View {17 @Bindable var model = model18 TabView(selection: $model.tab) {19 Tab("Découvrir", image: "ic-boutique", value: AppTab.home) {20 stack(.home) { HomeView() }21 }22 Tab("Chercher", systemImage: "magnifyingglass", value: AppTab.search) {23 stack(.search) { SearchHomeView() }24 }25 Tab("Boutiques", image: "ic-carte", value: AppTab.stores) {26 stack(.stores) { StoresView() }27 }28 Tab("Favoris", image: "ic-favori", value: AppTab.saved) {29 stack(.saved) { SavedView() }30 }31 }32 .tabViewStyle(.sidebarAdaptable)33 .overlay(alignment: .bottom) { toast }34 .animation(.snappy, value: model.toast)35 }3637 private func stack<Content: View>(_ tab: AppTab, @ViewBuilder _ content: () -> Content) -> some View {38 NavigationStack(path: model.path(for: tab)) {39 content()40 .navigationDestination(for: Route.self) { route in41 destination(route)42 }43 }44 }4546 @ViewBuilder47 private func destination(_ route: Route) -> some View {48 switch route {49 case .product(let uid): ProductView(uid: uid)50 case .search(let f): SearchResultsView(filters: f)51 case .categories: CategoriesView()52 case .store(let id): StoreView(id: id)53 case .regions: RegionsView()54 case .region(let slug): PlaceView(slug: slug, kind: .region)55 case .city(let slug): PlaceView(slug: slug, kind: .city)56 case .recents: RecentsView()57 case .settings: SettingsView()58 case .about: AboutView()59 case .method: MethodView()60 case .privacy: PrivacyView()61 case .register: RegisterView()62 }63 }6465 @ViewBuilder66 private var toast: some View {67 if let text = model.toast {68 HStack(spacing: 10) {69 BrandSymbol(style: .mono(Theme.bg), micro: true).frame(width: 16, height: 16)70 Text(text)71 }72 .font(.subheadline.weight(.medium))73 .foregroundStyle(Theme.bg)74 .padding(.horizontal, 16).padding(.vertical, 12)75 .background(Theme.ink, in: RoundedRectangle(cornerRadius: Theme.radius, style: .continuous))76 .padding(.bottom, 72)77 .transition(.move(edge: .bottom).combined(with: .opacity))78 .accessibilityAddTraits(.isStaticText)79 .accessibilityIdentifier("toast")80 }81 }82}83