payfrit-food-ios/PayfritFood/Views/RootView.swift
John Pinkyfloyd 71e7ec34f6 Initial commit: PayfritFood iOS app
- SwiftUI + async/await architecture
- Barcode scanning with AVFoundation
- Product display with score ring, NOVA badge, nutrition
- Alternatives with sort/filter
- Auth (login/register)
- Favorites & history
- Account management
- Dark theme
- Connected to food.payfrit.com API (Open Food Facts proxy)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-16 16:58:21 -07:00

58 lines
1.9 KiB
Swift

import SwiftUI
struct RootView: View {
@EnvironmentObject var appState: AppState
var body: some View {
TabView(selection: $appState.selectedTab) {
ScanScreen()
.tabItem {
Label(AppState.Tab.scan.title, systemImage: AppState.Tab.scan.icon)
}
.tag(AppState.Tab.scan)
FavoritesScreen()
.tabItem {
Label(AppState.Tab.favorites.title, systemImage: AppState.Tab.favorites.icon)
}
.tag(AppState.Tab.favorites)
HistoryScreen()
.tabItem {
Label(AppState.Tab.history.title, systemImage: AppState.Tab.history.icon)
}
.tag(AppState.Tab.history)
AccountScreen()
.tabItem {
Label(AppState.Tab.account.title, systemImage: AppState.Tab.account.icon)
}
.tag(AppState.Tab.account)
}
.tint(.green)
.sheet(isPresented: $appState.showLoginSheet) {
LoginSheet()
.environmentObject(appState)
}
.sheet(isPresented: $appState.showRegisterSheet) {
RegisterSheet()
.environmentObject(appState)
}
.overlay {
if let error = appState.errorMessage {
VStack {
Spacer()
Text(error)
.font(.subheadline)
.foregroundColor(.white)
.padding()
.background(Color.red.opacity(0.9))
.cornerRadius(10)
.padding(.bottom, 100)
}
.transition(.move(edge: .bottom).combined(with: .opacity))
.animation(.easeInOut, value: appState.errorMessage)
}
}
}
}