🚀 First version
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user