diff --git a/Ravens.xcodeproj/project.pbxproj b/Ravens.xcodeproj/project.pbxproj index c09cacfb..42e73fa7 100644 --- a/Ravens.xcodeproj/project.pbxproj +++ b/Ravens.xcodeproj/project.pbxproj @@ -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 */, diff --git a/Ravens/ContentView.swift b/Ravens/ContentView.swift index f45484bf..063a12b6 100644 --- a/Ravens/ContentView.swift +++ b/Ravens/ContentView.swift @@ -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(get: { self.locationId ?? 0 }, set: { self.locationId = $0 }), - sharedLocationStr: Binding(get: { self.locationStr ?? "---" }, set: { self.locationStr = $0 }) - ) - ObservationCircle(toggle: $isSheetObservationsLocationsViewPresented, colorHex: "a7b731") - } + MapObservationsLocationView() .tabItem { Text("Area") Image(systemName: "pentagon") @@ -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() @@ -109,16 +58,6 @@ struct ContentView: View { Image(systemName: "gearshape") } } - - .sheet(isPresented: $isSheetObservationsViewPresented) { - ObservationsView(isShowing: $isSheetObservationsViewPresented) - } - .sheet(isPresented: $isSheetObservationsLocationsViewPresented) { - ObservationsLocationView( - locationId: Binding(get: { self.locationId ?? 0 }, set: { self.locationId = $0 }), - locationStr: Binding(get: { self.locationStr ?? "test" }, set: { self.locationStr = $0 }), - isShowing: $isSheetObservationsLocationsViewPresented) - } .onAppear() { log.warning("*** NEW LAUNCH ***") CLLocationManager().requestWhenInUseAuthorization() @@ -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") +// } diff --git a/Ravens/Data/poi.json b/Ravens/Data/poi.json index 714767cf..3c2afc51 100644 --- a/Ravens/Data/poi.json +++ b/Ravens/Data/poi.json @@ -62,7 +62,7 @@ "latitude": 51.965423, "longitude": 5.215302 } - } + }, ] } diff --git a/Ravens/Localizable.xcstrings b/Ravens/Localizable.xcstrings index b390ac7f..2500bc29 100644 --- a/Ravens/Localizable.xcstrings +++ b/Ravens/Localizable.xcstrings @@ -186,6 +186,7 @@ } }, "Default Name" : { + "extractionState" : "stale", "localizations" : { "nl" : { "stringUnit" : { diff --git a/Ravens/Models/ObservationsLocationViewModel.swift b/Ravens/Models/ObservationsLocationViewModel.swift index 48c0ac1f..444f35a8 100644 --- a/Ravens/Models/ObservationsLocationViewModel.swift +++ b/Ravens/Models/ObservationsLocationViewModel.swift @@ -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 diff --git a/Ravens/Models/ObservationsViewModel.swift b/Ravens/Models/ObservationsViewModel.swift index 9d935b6b..63469aa6 100644 --- a/Ravens/Models/ObservationsViewModel.swift +++ b/Ravens/Models/ObservationsViewModel.swift @@ -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 @@ -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 { diff --git a/Ravens/Models/SpeciesViewModel.swift b/Ravens/Models/SpeciesViewModel.swift index 8cb08657..c342aad0 100644 --- a/Ravens/Models/SpeciesViewModel.swift +++ b/Ravens/Models/SpeciesViewModel.swift @@ -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 { diff --git a/Ravens/Views/MapObservationView.swift b/Ravens/Views/MapObservationView.swift index b128cf03..46857720 100644 --- a/Ravens/Views/MapObservationView.swift +++ b/Ravens/Views/MapObservationView.swift @@ -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( @@ -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) { diff --git a/Ravens/Views/MapObservationsLocationView.swift b/Ravens/Views/MapObservationsLocationView.swift index f452b04f..ef43f6a6 100644 --- a/Ravens/Views/MapObservationsLocationView.swift +++ b/Ravens/Views/MapObservationsLocationView.swift @@ -26,14 +26,13 @@ struct MapObservationsLocationView: View { @ObservedObject var locationManager = LocationManager() + @State private var cameraPosition: MapCameraPosition? + @State private var isSheetObservationsLocationsViewPresented = false @State private var locationId: Int = 0 - @Binding var sharedLocationId: Int @State private var locationStr: String = "no location" - @Binding var sharedLocationStr: String - @State private var circlePos: CLLocationCoordinate2D? @State private var MapCameraPositiondefault = MapCameraPosition @@ -53,80 +52,75 @@ struct MapObservationsLocationView: 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 + ) + } + } + } + + // location observation + ForEach(observationsLocationViewModel.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) ) } } - } - - // location observation - ForEach(observationsLocationViewModel.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( - Circle() - .fill(location.hasPhoto ? Color.white : Color.clear) - .frame(width: 6, height: 6) - ) + + //JSONData + ForEach(polyOverlays, id: \.self) { polyOverlay in + MapPolygon(polyOverlay) + .stroke(.pink, lineWidth: 1) + .foregroundStyle(.blue.opacity(0.1)) } + + } + .mapStyle(settings.mapStyle) - //JSONData - ForEach(polyOverlays, id: \.self) { polyOverlay in - MapPolygon(polyOverlay) - .stroke(.pink, lineWidth: 1) - .foregroundStyle(.blue.opacity(0.1)) - } - - - } - .mapStyle(settings.mapStyle) - - .safeAreaInset(edge: .bottom) { - VStack { - SettingsDetailsView(count: observationsLocationViewModel.locations.count, results: observationsLocationViewModel.observations?.count ?? 0 ) - .padding(5) - .frame(maxHeight: 30) - - if locationIdViewModel.locations.count > 0 { + .safeAreaInset(edge: .bottom) { + VStack { + SettingsDetailsView(count: observationsLocationViewModel.locations.count, results: observationsLocationViewModel.observations?.count ?? 0) + + HStack { Spacer() - Text("\(locationIdViewModel.locations[0].name)") + let text = locationIdViewModel.locations.count > 0 ? "\(locationIdViewModel.locations[0].name)" : "Default Name" + Text(text) } .padding(5) - .frame(maxHeight: 30) - } else { - Text("Default Name") - .padding(5) - .frame(maxHeight: 30) + .font(.headline) + .foregroundColor(.obsGreenFlower) + .background(Color.obsGreenEagle.opacity(0.5)) + .frame(height: 20) } } - .background(Color.obsGreenEagle.opacity(0.5)) - .font(.headline) - .foregroundColor(.obsGreenFlower) - .background(Color.obsGreenEagle.opacity(0.5)) - } - - .onTapGesture() { position in + + .onTapGesture() { position in + if let coordinate = proxy.convert(position, from: .local) { // Create a new CLLocation instance with the updated coordinates @@ -142,11 +136,9 @@ struct MapObservationsLocationView: View { log.info(location.id) //dit is de locatieId en hiermee halen we de geoJSON data op geoJSONViewModel.fetchGeoJsonData(for: String(location.id)) { polyOverlaysIn in polyOverlays = polyOverlaysIn - locationId = location.id - sharedLocationId = location.id - locationStr = location.name - sharedLocationStr = location.name + +// log.error("\(locationIdViewModel.count)") //and now er get the observations from the locationId observationsLocationViewModel.fetchData(locationId: locationId, limit: 100, offset: 0, completion: { @@ -160,14 +152,27 @@ struct MapObservationsLocationView: View { // Update currentLocation with the new CLLocation instance settings.currentLocation = newLocation + } + } + .mapControls() { + MapCompass() //tapping this makes it north + } - } - .mapControls() { - MapCompass() //tapping this makes it north - } } + ObservationCircle(toggle: $isSheetObservationsLocationsViewPresented, colorHex: "a7b731") + } + + .sheet(isPresented: $isSheetObservationsLocationsViewPresented) { + ObservationsLocationView( + locationId: locationId, + locationStr: locationStr, + isShowing: $isSheetObservationsLocationsViewPresented) + } + + + .onAppear() { //onappear viewModel.fetchPOIs() @@ -195,11 +200,12 @@ struct MapObservationsLocationView: View { geoJSONViewModel.fetchGeoJsonData(for: String(location.id)) { polyOverlaysIn in polyOverlays = polyOverlaysIn locationId = location.id - sharedLocationId = location.id + locationStr = location.name // the first is the same observationsLocationViewModel.fetchData(locationId: locationId, limit: 100, offset: 0, completion: { log.info("MapObservationsLocationView: fetchObservationsLocationData completed use delta") log.info(observationsLocationViewModel.span) +// log.error(observationsLocationViewModel.observations?.results.count ?? 0) //?? if settings.isFirstAppear { cameraPosition = MapCameraPosition @@ -257,7 +263,7 @@ struct MapObservationsLocationView: View { struct MapObservationLocationView_Previews: PreviewProvider { static var previews: some View { // Setting up the environment objects for the preview - MapObservationsLocationView(sharedLocationId: .constant(0), sharedLocationStr: .constant("locationStr")) + MapObservationsLocationView() .environmentObject(Settings()) .environmentObject(ObservationsViewModel(settings: Settings())) .environmentObject(SpeciesGroupViewModel(settings: Settings())) diff --git a/Ravens/Views/MapObservationsUserView.swift b/Ravens/Views/MapObservationsUserView.swift index a4154f8c..c312f53c 100644 --- a/Ravens/Views/MapObservationsUserView.swift +++ b/Ravens/Views/MapObservationsUserView.swift @@ -119,11 +119,13 @@ struct MapObservationsUserView: View { MapCompass() //tapping this makes it north } - ObservationCircle(toggle: $isSheetObservationsViewPresented, colorHex: "f7b731") + ObservationCircle(toggle: $isSheetObservationsViewPresented, colorHex: "77b731") } + .sheet(isPresented: $isSheetObservationsViewPresented) { ObservationsUserViewExtra(viewModel: observationsUserViewModel) } + .onAppear { observationsUserViewModel.fetchData(limit: limit, offset: offset) } diff --git a/Ravens/Views/ObsView.swift b/Ravens/Views/ObsView.swift index e83dbc05..a17154a3 100644 --- a/Ravens/Views/ObsView.swift +++ b/Ravens/Views/ObsView.swift @@ -53,7 +53,7 @@ struct ObsView: View { if showUsername { HStack { - Text("\(obs.user_detail?.name ?? "user_detail")") + Text("\(obs.user_detail?.name ?? String(obs.user))") Spacer() Text("\(obs.user_detail?.id ?? 0)") } diff --git a/Ravens/Views/ObservationUserView.swift b/Ravens/Views/ObservationUserView.swift index acc5ff77..4dda9791 100644 --- a/Ravens/Views/ObservationUserView.swift +++ b/Ravens/Views/ObservationUserView.swift @@ -54,10 +54,6 @@ struct ObservationsUserView: View { List { if let results = viewModel.observations?.results { ForEach(results.sorted(by: { (/*$0.species_group, */$1.rarity, $0.species_detail.name, $1.date, $0.time ?? "00:00") < (/*$1.species_group, */$0.rarity, $1.species_detail.name, $0.date, $1.time ?? "00:00") }), id: \.id) { -// ForEach(results.sorted(by: { ($0.species_group, $1.rarity, $1.date, $0.species_detail.name) < ($1.species_group, $0.rarity, $0.date, $1.species_detail.name) } ), id: \.id) { -// ForEach(results.sorted(by: { ($1.rarity ) < ($0.rarity) } ), id: \.id) { -// ForEach(results.sorted(by: { ($1.rarity, $1.date, $1.time ?? "" ) < ($0.rarity, $0.date, $0.time ?? "") } ), id: \.id) { -// ForEach(results.sorted(by: { ($0.species_group, $1.rarity, $1.date, $0.species_detail.name) < ($1.species_group, $0.rarity, $0.date, $1.species_detail.name) } ), id: \.id) { result in ObsView(obs: result) } @@ -84,17 +80,15 @@ struct ObservationsUserViewExtra: View { Text("Waarneming"+" ") UserSimpleView() } - .padding() - .font(.headline) + .padding(16) + .bold() List { -// ScrollView { if let results = viewModel.observations?.results { ForEach(results.sorted(by: { ($1.date, $1.time ?? "" ) < ($0.date, $0.time ?? "") } ), id: \.id) { result in ObsView(obs: result, showUsername: false) } - .font(.footnote) } } } diff --git a/Ravens/Views/ObservationsLocationsView.swift b/Ravens/Views/ObservationsLocationsView.swift index 5df447ba..52e56c15 100644 --- a/Ravens/Views/ObservationsLocationsView.swift +++ b/Ravens/Views/ObservationsLocationsView.swift @@ -19,34 +19,26 @@ struct ObservationsLocationView: View { @State private var limit = 100 @State private var offset = 0 - @Binding var locationId: Int - @Binding var locationStr: String + var locationId: Int + var locationStr: String + @Binding var isShowing: Bool var body: some View { VStack { - HStack() { HStack { Text("Obs") - Spacer() - Text("Area") -// Text("\(viewModel.locations.)") + Text(locationStr) } - Spacer() - Text(String(locationId)) - Text(locationStr) - } - .padding() + .padding(16) + .bold() List { if let results = viewModel.observations?.results { ForEach(results.sorted(by: { ($1.rarity, $0.species_detail.name, $1.date, $0.time ?? "00:00") < ($0.rarity, $1.species_detail.name, $0.date, $1.time ?? "00:00") }), id: \.id) { result in - - ObsView(obs: result, showLocation: false) } - .font(.footnote) } } } diff --git a/Ravens/Views/ObservationsSpeciesView.swift b/Ravens/Views/ObservationsSpeciesView.swift index 64b67685..4a35444f 100644 --- a/Ravens/Views/ObservationsSpeciesView.swift +++ b/Ravens/Views/ObservationsSpeciesView.swift @@ -33,7 +33,8 @@ struct ObservationsSpeciesView: View { .font(.headline) } } - .padding() + .padding(16) + .bold() .buttonStyle(.bordered) .foregroundColor(.obsGreenEagle) @@ -47,7 +48,6 @@ struct ObservationsSpeciesView: View { ObsView(obs: result) - .font(.footnote) .onAppear { if index == sortedResults.count - 1 { print("End of list reached") diff --git a/Ravens/Views/ObservationsView.swift b/Ravens/Views/ObservationsView.swift index f35c1c74..959c8f46 100644 --- a/Ravens/Views/ObservationsView.swift +++ b/Ravens/Views/ObservationsView.swift @@ -31,7 +31,7 @@ struct ObservationsView: View { if let results = observationsViewModel.observations?.results { ForEach(results.sorted(by: { ($1.rarity, $0.species_detail.name, $1.date, $0.time ?? "00:00") < ($0.rarity, $1.species_detail.name, $0.date, $1.time ?? "00:00") }), id: \.id) { result in - ObsView(obs: result, showUsername: false) + ObsView(obs: result, showUsername: true) } } else { diff --git a/Ravens/Views/SpeciesView.swift b/Ravens/Views/SpeciesView.swift index 14dcde1f..5c053307 100644 --- a/Ravens/Views/SpeciesView.swift +++ b/Ravens/Views/SpeciesView.swift @@ -148,12 +148,10 @@ struct SpeciesView: View { .searchable(text: $searchText) .onAppear() { - log.info("birdview: selectedGroup \(settings.selectedGroup)") + log.info("speciesView: selectedGroup \(settings.selectedGroup)") speciesViewModel.fetchData(language: settings.selectedLanguage, for: settings.selectedGroup) -// birdViewModelsecLanguage.fetchData(language: "eng", for: settings.selectedGroup) //< [Species] { + func sortedSpecies(by sortOption: SortOption) -> [Species] { switch sortOption { case .name: return species.sorted { ($0.name < $1.name) } @@ -200,14 +198,14 @@ extension SpeciesViewModel { extension SpeciesViewModel { func filteredSpecies(by sortOption: SortOption, searchText: String, filterOption: FilterOption, rarityFilterOption: Int, isBookmarked: Bool, additionalIntArray: [Int]) -> [Species] { - let sortedBirdsList = sortedBirds(by: sortOption) + let sortedSpeciesList = sortedSpecies(by: sortOption) if searchText.isEmpty { - var filteredList = applyFilter(to: sortedBirdsList, with: filterOption) + var filteredList = applyFilter(to: sortedSpeciesList, with: filterOption) filteredList = applyRarityFilter(to: filteredList, with: rarityFilterOption) return applyBookmarkFilter(to: filteredList, isBookmarked: isBookmarked, additionalIntArray: additionalIntArray) } else { - let filteredList = sortedBirdsList.filter { species in + let filteredList = sortedSpeciesList.filter { species in species.name.lowercased().contains(searchText.lowercased()) || species.scientific_name.lowercased().contains(searchText.lowercased()) } diff --git a/ravens.log b/ravens.log index c6be9fcd..8e7ebfff 100644 --- a/ravens.log +++ b/ravens.log @@ -57596,3 +57596,162 @@ accept-Language: nl 2024-04-05 13:19:22.712 Ravens: fetchData ObservationsViewModel 2024-04-05 13:24:30.816 WARNING: *** NEW LAUNCH *** 2024-04-05 13:24:31.436 Ravens: fetchData ObservationsViewModel +2024-04-05 13:32:11.585 WARNING: *** NEW LAUNCH *** +2024-04-05 13:32:12.556 Ravens: fetchData ObservationsViewModel +2024-04-05 13:39:55.396 WARNING: *** NEW LAUNCH *** +2024-04-05 13:39:56.022 Ravens: fetchData ObservationsViewModel +2024-04-05 13:40:22.386 WARNING: *** NEW LAUNCH *** +2024-04-05 13:40:22.748 Ravens: fetchData ObservationsViewModel +2024-04-05 13:40:25.988 Ravens: fetchData ObservationsViewModel +2024-04-05 14:02:44.410 WARNING: *** NEW LAUNCH *** +2024-04-05 14:02:44.974 Ravens: fetchData ObservationsViewModel +2024-04-05 14:03:28.531 WARNING: *** NEW LAUNCH *** +2024-04-05 14:03:29.068 Ravens: fetchData ObservationsViewModel +2024-04-05 14:03:39.907 WARNING: *** NEW LAUNCH *** +2024-04-05 14:03:40.284 Ravens: fetchData ObservationsViewModel +2024-04-05 14:03:51.196 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:03:51.200 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:03:52.623 Ravens: https://waarneming.nl/api/v1/user/info/ +2024-04-05 14:03:58.371 Ravens: fetchData ObservationsViewModel +2024-04-05 14:03:59.674 Ravens: fetchData ObservationsViewModel +2024-04-05 14:06:28.186 Ravens: Error ObservationsSpeciesViewModel decoding JSON: keyNotFound(CodingKeys(stringValue: "results", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"results\", intValue: nil) (\"results\").", underlyingError: nil)) +2024-04-05 14:06:28.231 Ravens: https://waarneming.nl/api/v1/species/2/observations/?date_after=2024-03-31&date_before=2024-04-05&limit=100 +2024-04-05 14:06:41.305 Ravens: Error ObservationsSpeciesViewModel decoding JSON: keyNotFound(CodingKeys(stringValue: "results", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"results\", intValue: nil) (\"results\").", underlyingError: nil)) +2024-04-05 14:06:41.323 Ravens: https://waarneming.nl/api/v1/species/2/observations/?date_after=2024-03-31&date_before=2024-04-05&limit=100 +2024-04-05 14:06:43.056 Ravens: Error ObservationsSpeciesViewModel decoding JSON: keyNotFound(CodingKeys(stringValue: "results", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"results\", intValue: nil) (\"results\").", underlyingError: nil)) +2024-04-05 14:06:43.062 Ravens: https://waarneming.nl/api/v1/species/2/observations/?date_after=2024-03-31&date_before=2024-04-05&limit=100 +2024-04-05 14:06:45.681 Ravens: Error ObservationsSpeciesViewModel decoding JSON: keyNotFound(CodingKeys(stringValue: "results", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"results\", intValue: nil) (\"results\").", underlyingError: nil)) +2024-04-05 14:06:45.687 Ravens: https://waarneming.nl/api/v1/species/2/observations/?date_after=2024-03-31&date_before=2024-04-05&limit=100 +2024-04-05 14:07:01.244 Ravens: Error ObservationsSpeciesViewModel decoding JSON: keyNotFound(CodingKeys(stringValue: "results", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"results\", intValue: nil) (\"results\").", underlyingError: nil)) +2024-04-05 14:07:01.250 Ravens: https://waarneming.nl/api/v1/species/2/observations/?date_after=2024-03-31&date_before=2024-04-05&limit=100 +2024-04-05 14:07:09.116 WARNING: *** NEW LAUNCH *** +2024-04-05 14:07:09.727 Ravens: fetchData ObservationsViewModel +2024-04-05 14:13:40.637 WARNING: *** NEW LAUNCH *** +2024-04-05 14:13:41.189 Ravens: fetchData ObservationsViewModel +2024-04-05 14:14:29.975 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:14:29.980 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:14:32.464 Ravens: https://waarneming.nl/api/v1/user/info/ +2024-04-05 14:14:40.571 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:14:40.575 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:14:48.233 Ravens: fetchData ObservationsViewModel +2024-04-05 14:14:53.394 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:14:53.398 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:15:36.965 WARNING: *** NEW LAUNCH *** +2024-04-05 14:15:37.343 Ravens: fetchData ObservationsViewModel +2024-04-05 14:15:42.147 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:15:42.151 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:15:44.264 Ravens: fetchData ObservationsViewModel +2024-04-05 14:15:58.560 WARNING: *** NEW LAUNCH *** +2024-04-05 14:15:58.920 Ravens: fetchData ObservationsViewModel +2024-04-05 14:16:00.958 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:16:00.962 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:16:13.387 WARNING: *** NEW LAUNCH *** +2024-04-05 14:16:13.762 Ravens: fetchData ObservationsViewModel +2024-04-05 14:16:16.094 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:16:16.098 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:16:18.435 Ravens: fetchData ObservationsViewModel +2024-04-05 14:19:58.295 WARNING: *** NEW LAUNCH *** +2024-04-05 14:19:58.688 Ravens: fetchData ObservationsViewModel +2024-04-05 14:21:02.138 WARNING: *** NEW LAUNCH *** +2024-04-05 14:21:02.520 Ravens: fetchData ObservationsViewModel +2024-04-05 14:21:06.008 Ravens: fetchData ObservationsViewModel +2024-04-05 14:24:52.822 WARNING: *** NEW LAUNCH *** +2024-04-05 14:24:53.201 Ravens: fetchData ObservationsViewModel +2024-04-05 14:24:54.833 Ravens: fetchData ObservationsViewModel +2024-04-05 14:27:18.526 WARNING: *** NEW LAUNCH *** +2024-04-05 14:27:18.913 Ravens: fetchData ObservationsViewModel +2024-04-05 14:27:26.349 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:27:26.354 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:27:27.575 Ravens: https://waarneming.nl/api/v1/user/info/ +2024-04-05 14:33:23.909 WARNING: *** NEW LAUNCH *** +2024-04-05 14:33:24.362 Ravens: fetchData ObservationsViewModel +2024-04-05 14:33:27.132 Ravens: fetchData ObservationsViewModel +2024-04-05 14:34:14.478 WARNING: *** NEW LAUNCH *** +2024-04-05 14:34:14.834 Ravens: fetchData ObservationsViewModel +2024-04-05 14:36:14.431 WARNING: *** NEW LAUNCH *** +2024-04-05 14:36:14.917 Ravens: fetchData ObservationsViewModel +2024-04-05 14:36:55.685 WARNING: *** NEW LAUNCH *** +2024-04-05 14:36:56.046 Ravens: fetchData ObservationsViewModel +2024-04-05 14:37:38.387 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:37:38.392 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:41:55.567 WARNING: *** NEW LAUNCH *** +2024-04-05 14:41:55.968 Ravens: fetchData ObservationsViewModel +2024-04-05 14:45:29.973 WARNING: *** NEW LAUNCH *** +2024-04-05 14:45:30.371 Ravens: fetchData ObservationsViewModel +2024-04-05 14:47:24.335 WARNING: *** NEW LAUNCH *** +2024-04-05 14:47:24.725 Ravens: fetchData ObservationsViewModel +2024-04-05 14:48:16.642 WARNING: *** NEW LAUNCH *** +2024-04-05 14:48:17.037 Ravens: fetchData ObservationsViewModel +2024-04-05 14:49:41.644 WARNING: *** NEW LAUNCH *** +2024-04-05 14:49:42.033 Ravens: fetchData ObservationsViewModel +2024-04-05 14:49:46.070 Ravens: Error ObservationsLocationViewModel decoding JSON: keyNotFound(CodingKeys(stringValue: "results", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"results\", intValue: nil) (\"results\").", underlyingError: nil)) +2024-04-05 14:49:46.074 Ravens: https://waarneming.nl/api/v1/locations/0/observations/?species_group=1 +2024-04-05 14:49:52.555 Ravens: fetchData ObservationsViewModel +2024-04-05 14:49:54.089 Ravens: fetchData ObservationsViewModel +2024-04-05 14:50:28.585 WARNING: *** NEW LAUNCH *** +2024-04-05 14:50:28.954 Ravens: fetchData ObservationsViewModel +2024-04-05 14:50:40.905 Ravens: fetchData ObservationsUserViewModel limit: 100 offset: 0 +2024-04-05 14:50:40.910 Ravens: https://waarneming.nl/api/v1/user/observations/?limit=100&offset=0 +2024-04-05 14:50:42.792 Ravens: https://waarneming.nl/api/v1/user/info/ +2024-04-05 14:52:52.186 WARNING: *** NEW LAUNCH *** +2024-04-05 14:52:52.574 Ravens: fetchData ObservationsViewModel +2024-04-05 14:53:38.892 WARNING: *** NEW LAUNCH *** +2024-04-05 14:53:39.258 Ravens: fetchData ObservationsViewModel +2024-04-05 14:55:56.997 WARNING: *** NEW LAUNCH *** +2024-04-05 14:55:57.362 Ravens: fetchData ObservationsViewModel +2024-04-05 14:56:03.690 Ravens: 0 +2024-04-05 14:57:15.908 WARNING: *** NEW LAUNCH *** +2024-04-05 14:57:16.255 Ravens: fetchData ObservationsViewModel +2024-04-05 14:57:19.771 Ravens: 100 +2024-04-05 15:00:34.153 WARNING: *** NEW LAUNCH *** +2024-04-05 15:00:34.535 Ravens: fetchData ObservationsViewModel +2024-04-05 15:00:39.400 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:04:49.657 WARNING: *** NEW LAUNCH *** +2024-04-05 15:04:50.052 Ravens: fetchData ObservationsViewModel +2024-04-05 15:04:57.775 Ravens: fetchData ObservationsViewModel +2024-04-05 15:05:09.231 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:05:14.184 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:36:01.293 WARNING: *** NEW LAUNCH *** +2024-04-05 15:36:02.014 Ravens: fetchData ObservationsViewModel +2024-04-05 15:36:58.465 WARNING: *** NEW LAUNCH *** +2024-04-05 15:36:59.066 Ravens: fetchData ObservationsViewModel +2024-04-05 15:37:01.521 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:37:21.156 WARNING: *** NEW LAUNCH *** +2024-04-05 15:37:21.523 Ravens: fetchData ObservationsViewModel +2024-04-05 15:37:32.148 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:37:45.623 WARNING: *** NEW LAUNCH *** +2024-04-05 15:37:46.002 Ravens: fetchData ObservationsViewModel +2024-04-05 15:37:48.878 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:38:13.171 WARNING: *** NEW LAUNCH *** +2024-04-05 15:38:13.528 Ravens: fetchData ObservationsViewModel +2024-04-05 15:38:15.246 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:40:02.413 WARNING: *** NEW LAUNCH *** +2024-04-05 15:40:03.022 Ravens: fetchData ObservationsViewModel +2024-04-05 15:40:17.890 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:40:48.099 WARNING: *** NEW LAUNCH *** +2024-04-05 15:40:48.502 Ravens: fetchData ObservationsViewModel +2024-04-05 15:40:50.210 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:41:58.662 WARNING: *** NEW LAUNCH *** +2024-04-05 15:41:59.058 Ravens: fetchData ObservationsViewModel +2024-04-05 15:42:00.831 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:42:12.576 WARNING: *** NEW LAUNCH *** +2024-04-05 15:42:12.999 Ravens: fetchData ObservationsViewModel +2024-04-05 15:42:14.582 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:44:23.909 WARNING: *** NEW LAUNCH *** +2024-04-05 15:44:24.327 Ravens: fetchData ObservationsViewModel +2024-04-05 15:44:26.198 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:45:25.214 WARNING: *** NEW LAUNCH *** +2024-04-05 15:45:25.566 Ravens: fetchData ObservationsViewModel +2024-04-05 15:45:26.961 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:45:45.912 WARNING: *** NEW LAUNCH *** +2024-04-05 15:45:46.249 Ravens: fetchData ObservationsViewModel +2024-04-05 15:46:05.303 WARNING: *** NEW LAUNCH *** +2024-04-05 15:46:05.645 Ravens: fetchData ObservationsViewModel +2024-04-05 15:46:30.677 WARNING: *** NEW LAUNCH *** +2024-04-05 15:46:31.003 Ravens: fetchData ObservationsViewModel +2024-04-05 15:46:50.355 WARNING: *** NEW LAUNCH *** +2024-04-05 15:46:50.715 Ravens: fetchData ObservationsViewModel +2024-04-05 15:46:56.001 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1 +2024-04-05 15:47:49.030 WARNING: *** NEW LAUNCH *** +2024-04-05 15:47:49.446 Ravens: fetchData ObservationsViewModel +2024-04-05 15:47:51.400 Ravens: URL https://waarneming.nl/api/v1/locations/133746/observations/?species_group=1