Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
edequartel committed Apr 5, 2024
1 parent 9091bab commit 9fbf58c
Show file tree
Hide file tree
Showing 17 changed files with 367 additions and 235 deletions.
2 changes: 1 addition & 1 deletion Ravens.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@
4757E0752B7F3426003F148E /* LoginView.swift */,
474C409B2B500AE90038B3A5 /* ObservationsView.swift */,
4704110E2BB1EF1B00A498F5 /* ObservationsLocationsView.swift */,
47568D302B59BABB00E69B1A /* ObservationsSpeciesView.swift */,
4785CD222B965237002F52BE /* ObservationUserView.swift */,
47568D302B59BABB00E69B1A /* ObservationsSpeciesView.swift */,
477ECF132B98897100D96BE9 /* NetworkView.swift */,
474093812B558F82004F10C5 /* ObservationDetailsView.swift */,
47079EBD2BB9D81F003D2E11 /* ObsExtendedView.swift */,
Expand Down
101 changes: 36 additions & 65 deletions Ravens/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,19 @@ struct ContentView: View {
@StateObject private var observationsViewModel = ObservationsViewModel(settings: Settings())
@StateObject private var observationsSpeciesViewModel = ObservationsSpeciesViewModel(settings: Settings())

@State private var isSheetObservationsViewPresented = false
@State private var isSheetObservationsLocationsViewPresented = false

@State private var locationId: Int?
@State private var locationStr: String?

var body: some View {
TabView {
// Tab 0
// LottieView(lottieFile: "LottieFile")
// .tabItem {
// Text("Lottie")
// Image(systemName: "globe")
// }

// Tab 0
// AudioView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }
// Tab 0
// LookUpsView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }
// Tab 0
// LocationLatLongView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }
// Tab 0
// POIsView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }

// Tab 1
ZStack {
MapObservationView()
ObservationCircle(toggle: $isSheetObservationsViewPresented, colorHex: "f7b731")
}
MapObservationView()
.tabItem {
Text("Radius")
Image(systemName: "circle")
}

// Tab 2
ZStack {
MapObservationsLocationView(
sharedLocationId: Binding<Int>(get: { self.locationId ?? 0 }, set: { self.locationId = $0 }),
sharedLocationStr: Binding<String>(get: { self.locationStr ?? "---" }, set: { self.locationStr = $0 })
)
ObservationCircle(toggle: $isSheetObservationsLocationsViewPresented, colorHex: "a7b731")
}
MapObservationsLocationView()
.tabItem {
Text("Area")
Image(systemName: "pentagon")
Expand All @@ -88,19 +43,13 @@ struct ContentView: View {
Image(systemName: "tree")
}

// Tab 3
// Tab 4
MapObservationsUserView()
.tabItem {
Text("Me")
Image(systemName: "person.fill")
}

// // Tab 4
// EmptyView()
// .tabItem {
// Text("Explorers")
// Image(systemName: "person.2.fill")
// }


// Tab 5
SettingsView()
Expand All @@ -109,16 +58,6 @@ struct ContentView: View {
Image(systemName: "gearshape")
}
}

.sheet(isPresented: $isSheetObservationsViewPresented) {
ObservationsView(isShowing: $isSheetObservationsViewPresented)
}
.sheet(isPresented: $isSheetObservationsLocationsViewPresented) {
ObservationsLocationView(
locationId: Binding<Int>(get: { self.locationId ?? 0 }, set: { self.locationId = $0 }),
locationStr: Binding<String>(get: { self.locationStr ?? "test" }, set: { self.locationStr = $0 }),
isShowing: $isSheetObservationsLocationsViewPresented)
}
.onAppear() {
log.warning("*** NEW LAUNCH ***")
CLLocationManager().requestWhenInUseAuthorization()
Expand Down Expand Up @@ -180,4 +119,36 @@ struct ContentView_Previews: PreviewProvider {
// Text("Book")
// Image(systemName: "book")
// }

//Tab 0
// LottieView(lottieFile: "LottieFile")
// .tabItem {
// Text("Lottie")
// Image(systemName: "globe")
// }
//
// Tab 0
// AudioView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }
// Tab 0
// LookUpsView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }
// Tab 0
// LocationLatLongView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }
// Tab 0
// POIsView()
// .tabItem {
// Text("weather")
// Image(systemName: "globe")
// }

2 changes: 1 addition & 1 deletion Ravens/Data/poi.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"latitude": 51.965423,
"longitude": 5.215302
}
}
},
]
}

Expand Down
1 change: 1 addition & 0 deletions Ravens/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
}
},
"Default Name" : {
"extractionState" : "stale",
"localizations" : {
"nl" : {
"stringUnit" : {
Expand Down
2 changes: 1 addition & 1 deletion Ravens/Models/ObservationsLocationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ObservationsLocationViewModel: ObservableObject {
url = url + "&date_after=\(date_after)&date_before=\(date_before)"
}

log.info("URL \(url)")
log.error("URL \(url)")
// log.error("headers \(headers)")

AF.request(url, headers: headers).responseString { response in
Expand Down
4 changes: 2 additions & 2 deletions Ravens/Models/ObservationsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ObservationsViewModel: ObservableObject {
}

func fetchData(lat: Double, long: Double, completion: @escaping () -> Void) {
log.error("fetchData ObservationsViewModel")
log.info("fetchData ObservationsViewModel")

let headers: HTTPHeaders = [
"Accept-Language": settings.selectedLanguage
Expand All @@ -92,7 +92,7 @@ class ObservationsViewModel: ObservableObject {
// url = url + "&date_after=\(date_after)&date_before=\(date_before)"
// }

log.info("\(url)")
log.error(">>> \(url)")

AF.request(url, headers: headers).responseDecodable(of: Observations.self) { response in
switch response.result {
Expand Down
2 changes: 1 addition & 1 deletion Ravens/Models/SpeciesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SpeciesViewModel: ObservableObject {
switch response.result {
case .success(_):
do {
// Decode the JSON response into an array of Bird objects
// Decode the JSON response into an array of Species objects
let decoder = JSONDecoder()
self.species = try decoder.decode([Species].self, from: response.data!)
} catch {
Expand Down
117 changes: 63 additions & 54 deletions Ravens/Views/MapObservationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct MapObservationView: View {

@ObservedObject var locationManager = LocationManager()
@State private var cameraPosition: MapCameraPosition?

@State private var isSheetObservationsViewPresented = false
@State private var MapCameraPositiondefault = MapCameraPosition
.region(
MKCoordinateRegion(
Expand All @@ -40,72 +40,81 @@ struct MapObservationView: View {
}

var body: some View {
VStack {
MapReader { proxy in
Map(position: cameraBinding) {

UserAnnotation()

if (settings.poiOn) {
ForEach(viewModel.poiList, id: \.name) { poi in
Annotation(poi.name, coordinate: poi.coordinate.cllocationCoordinate) {
Triangle()
.fill(Color.gray)
.frame(width: 5, height: 5)
ZStack {
VStack {
MapReader { proxy in
Map(position: cameraBinding) {

UserAnnotation()

if (settings.poiOn) {
ForEach(viewModel.poiList, id: \.name) { poi in
Annotation(poi.name, coordinate: poi.coordinate.cllocationCoordinate) {
Triangle()
.fill(Color.gray)
.frame(width: 5, height: 5)
.overlay(
Triangle()
.stroke(Color.white, lineWidth: 1) // Customize the border color and width
)
}
}
}

ForEach(observationsViewModel.locations) { location in
Annotation(location.name, coordinate: location.coordinate) {
Circle()
.fill(Color(myColor(value: location.rarity)))
.stroke(location.hasSound ? Color.white : Color.clear,lineWidth: 1)
.frame(width: 12, height: 12)

.overlay(
Triangle()
.stroke(Color.white, lineWidth: 1) // Customize the border color and width
Circle()
.fill(location.hasPhoto ? Color.white : Color.clear)
.frame(width: 6, height: 6)
)
}
}

MapCircle(center: circlePos ?? CLLocationCoordinate2D(), radius: CLLocationDistance(settings.radius))
.foregroundStyle(.clear.opacity(100))
.stroke(colorByMapStyle(), lineWidth: 1)
}
.mapStyle(settings.mapStyle)

ForEach(observationsViewModel.locations) { location in
Annotation(location.name, coordinate: location.coordinate) {
Circle()
.fill(Color(myColor(value: location.rarity)))
.stroke(location.hasSound ? Color.white : Color.clear,lineWidth: 1)
.frame(width: 12, height: 12)
.safeAreaInset(edge: .bottom) {
SettingsDetailsView(count: observationsViewModel.locations.count, results: observationsViewModel.observations?.count ?? 0 )
}

.onTapGesture() { position in
if let coordinate = proxy.convert(position, from: .local) {
observationsViewModel.fetchData(lat: coordinate.latitude, long: coordinate.longitude,
completion: {print("fetchData observationsViewModel xxx completed")} )

.overlay(
Circle()
.fill(location.hasPhoto ? Color.white : Color.clear)
.frame(width: 6, height: 6)
)
// Create a new CLLocation instance with the updated coordinates
let newLocation = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
circlePos = CLLocationCoordinate2D(latitude: coordinate.latitude, longitude: coordinate.longitude)

// Update currentLocation with the new CLLocation instance
settings.currentLocation = newLocation //?? why>>for other sheetview
}
}

MapCircle(center: circlePos ?? CLLocationCoordinate2D(), radius: CLLocationDistance(settings.radius))
.foregroundStyle(.clear.opacity(100))
.stroke(colorByMapStyle(), lineWidth: 1)
}
.mapStyle(settings.mapStyle)

.safeAreaInset(edge: .bottom) {
VStack {
SettingsDetailsView(count: observationsViewModel.locations.count, results: observationsViewModel.observations?.count ?? 0 )
.mapControls() {
MapCompass() //tapping this makes it north
}
}

.onTapGesture() { position in
if let coordinate = proxy.convert(position, from: .local) {
observationsViewModel.fetchData(lat: coordinate.latitude, long: coordinate.longitude,
completion: {print("fetchData observationsViewModel xxx completed")} )

// Create a new CLLocation instance with the updated coordinates
let newLocation = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
circlePos = CLLocationCoordinate2D(latitude: coordinate.latitude, longitude: coordinate.longitude)

// Update currentLocation with the new CLLocation instance
settings.currentLocation = newLocation //?? why>>for other sheetview
}
}
.mapControls() {
MapCompass() //tapping this makes it north
}
}

ObservationCircle(toggle: $isSheetObservationsViewPresented, colorHex: "f7b731")
}
.onAppear() {

//
.sheet(isPresented: $isSheetObservationsViewPresented) {
ObservationsView(isShowing: $isSheetObservationsViewPresented)
}
//

.onAppear() {
viewModel.fetchPOIs()

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
Expand Down
Loading

0 comments on commit 9fbf58c

Please sign in to comment.