-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentView.swift
110 lines (100 loc) · 3.27 KB
/
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// ContentView.swift
// Ravens
//
// Created by Eric de Quartel on 08/01/2024.
//
import SwiftUI
import MapKit
import SwiftyBeaver
import BackgroundTasks
import UserNotifications
struct ContentView: View {
let log = SwiftyBeaver.self
@ObservedObject var observationUser : ObservationsViewModel
@ObservedObject var observationsLocation: ObservationsViewModel
@ObservedObject var observationsSpecies: ObservationsViewModel
@EnvironmentObject var locationManagerModel: LocationManagerModel
@EnvironmentObject var keyChainviewModel: KeychainViewModel
@State private var dataLoaded = false
var body: some View {
Group {
if keyChainviewModel.token.isEmpty {
// Login View
LoginView()
.onAppear {
log.info("No token, displaying login")
}
} else {
if dataLoaded {
RavensView(
observationUser: observationUser,
observationsLocation: observationsLocation,
observationsSpecies: observationsSpecies)
.onAppear {
log.info("Data loaded, navigating to main content")
}
} else {
SplashView(dataLoaded: $dataLoaded)
.onAppear {
log.info("Loading data in SplashView")
if let location = locationManagerModel.location {
log.error("Current Location: \(location.coordinate.latitude), \(location.coordinate.longitude)")
} else {
log.error("Location not available yet")
}
}
}
}
}
}
}
//struct ContentView: View {
// let log = SwiftyBeaver.self
// @EnvironmentObject var locationManagerModel: LocationManagerModel
// @EnvironmentObject var keyChainviewModel: KeychainViewModel
//
// @State private var dataLoaded = false
//
// var body: some View {
// Group {
// if keyChainviewModel.token.isEmpty {
// // Show login screen if the token is missing
// VStack {
// HStack {
// Text("Login waarneming.nl")
// .bold()
// .font(.title)
// .padding()
// Spacer()
// }
// LoginView()
// }
// .onAppear {
//// CLLocationManager().requestWhenInUseAuthorization()
// log.error("Token is empty, showing login screen")
// }
// } else {
// if dataLoaded {
// // Show the main content if data is loaded
// RavensView()
// .onAppear {
// log.error("Data loaded, navigating to main content")
// }
// } else {
// // Show splash view to load data
// SplashView(dataLoaded: $dataLoaded)
// .onAppear {
// log.error("Loading data via SplashView")
// }
// }
// }
// }
// }
//}
//struct ContentView_Previews: PreviewProvider {
// static var previews: some View {
// ContentView()
// .environmentObject(Settings())
// }
//}