🚀 First version

This commit is contained in:
Victor Bodinaud
2024-04-18 19:32:10 +02:00
parent 0a30000e8c
commit 9ec3ba818b
67 changed files with 1905 additions and 29 deletions

View File

@@ -9,9 +9,36 @@ import SwiftUI
@main
struct AlloVictorApp: App {
@StateObject private var viewModel = AlloVictorViewModel()
@StateObject private var appState = AppState()
private func fetchOffers() async {
do {
try await viewModel.getDatas()
} catch {
print(error.localizedDescription)
}
}
var body: some Scene {
WindowGroup {
ContentView()
NavigationStack(path: $appState.routes) {
OffersListScreen()
.navigationDestination(for: Route.self) { route in
switch route {
case .offers:
OffersListScreen()
case .detail(let offer):
OfferDetailsScreen(offerDetails: offer)
}
}
}
.task {
await fetchOffers()
}
.environmentObject(viewModel)
.environmentObject(appState)
}
}
}