This repository has been archived on 2024-05-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AlloVictor/AlloVictor/AlloVictorApp.swift
Victor Bodinaud 9ec3ba818b 🚀 First version
2024-04-18 19:32:10 +02:00

45 lines
1.1 KiB
Swift

//
// AlloVictorApp.swift
// AlloVictor
//
// Created by Bodinaud Victor on 13/04/2024.
//
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 {
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)
}
}
}