Skip to content

Commit

Permalink
Merge pull request #72 from edequartel/developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
edequartel authored Nov 8, 2024
2 parents 80268ab + 43b0b0e commit f6e4f47
Show file tree
Hide file tree
Showing 40 changed files with 852 additions and 781 deletions.
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disabled_rules:
- trailing_whitespace
34 changes: 17 additions & 17 deletions ButtonViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct InformationSpeciesButtonView: View {

var body: some View {
Button(action: {
selectedSpeciesID = obs.species_detail.id
selectedSpeciesID = obs.speciesDetail.id
}) {
Image(systemSymbol: SFInformation)
}
Expand All @@ -57,21 +57,21 @@ struct AreaButtonView: View {

var body: some View {
Button(action: {
if areasViewModel.isIDInRecords(areaID: obs.location_detail?.id ?? 0) {
print("remove areas \(obs.location_detail?.id ?? 0)")
if areasViewModel.isIDInRecords(areaID: obs.locationDetail?.id ?? 0) {
print("remove areas \(obs.locationDetail?.id ?? 0)")
areasViewModel.removeRecord(
areaID: obs.location_detail?.id ?? 0)
areaID: obs.locationDetail?.id ?? 0)
} else {
print("adding area \(obs.location_detail?.id ?? 0)")
print("adding area \(obs.locationDetail?.id ?? 0)")
areasViewModel.appendRecord(
areaName: obs.location_detail?.name ?? "unknown",
areaID: obs.location_detail?.id ?? 0,
areaName: obs.locationDetail?.name ?? "unknown",
areaID: obs.locationDetail?.id ?? 0,
latitude: obs.point.coordinates[1], //!!?
longitude: obs.point.coordinates[0]
)
}
}) {
if areasViewModel.isIDInRecords(areaID: obs.location_detail?.id ?? 0) {
if areasViewModel.isIDInRecords(areaID: obs.locationDetail?.id ?? 0) {
Image(systemSymbol: SFAreaFill)
.uniformSize()
} else {
Expand All @@ -92,15 +92,15 @@ struct ObserversButtonView: View {

var body: some View {
Button(action: {
if observersViewModel.isObserverInRecords(userID: obs.user_detail?.id ?? 0) {
observersViewModel.removeRecord(userID: obs.user_detail?.id ?? 0)
if observersViewModel.isObserverInRecords(userID: obs.userDetail?.id ?? 0) {
observersViewModel.removeRecord(userID: obs.userDetail?.id ?? 0)
} else {
observersViewModel.appendRecord(
name: obs.user_detail?.name ?? "unknown",
userID: obs.user_detail?.id ?? 0)
name: obs.userDetail?.name ?? "unknown",
userID: obs.userDetail?.id ?? 0)
}
}) {
if observersViewModel.isObserverInRecords(userID: obs.user_detail?.id ?? 0) {
if observersViewModel.isObserverInRecords(userID: obs.userDetail?.id ?? 0) {
Image(systemSymbol: SFObserverFill)
.uniformSize()
} else {
Expand All @@ -123,13 +123,13 @@ struct BookmarkButtonView: View {

var body: some View {
Button(action: {
if bookMarksViewModel.isSpeciesIDInRecords(speciesID: obs.species_detail.id) {
bookMarksViewModel.removeRecord(speciesID: obs.species_detail.id)
if bookMarksViewModel.isSpeciesIDInRecords(speciesID: obs.speciesDetail.id) {
bookMarksViewModel.removeRecord(speciesID: obs.speciesDetail.id)
} else {
bookMarksViewModel.appendRecord(speciesID: obs.species_detail.id)
bookMarksViewModel.appendRecord(speciesID: obs.speciesDetail.id)
}
}) {
Image(systemSymbol: bookMarksViewModel.isSpeciesIDInRecords(speciesID: obs.species_detail.id) ? SFSpeciesFill : SFSpecies)
Image(systemSymbol: bookMarksViewModel.isSpeciesIDInRecords(speciesID: obs.speciesDetail.id) ? SFSpeciesFill : SFSpecies)
.uniformSize()
}
.tint(colorOn ? .obsBookmark : nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "110"
endingLineNumber = "110"
landmarkName = "FilteringMenu"
landmarkType = "14">
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down
31 changes: 17 additions & 14 deletions Ravens/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct ContentView: View {
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}

//@@@
var body: some View {
if (keyChainviewModel.token.isEmpty) {
VStack {
Expand Down Expand Up @@ -124,6 +125,7 @@ struct SplashScreen: View {

@EnvironmentObject var keychainViewModel: KeychainViewModel

// @State private var isLocationDataLoaded = false
@State private var isLanguageDataLoaded = false
@State private var isFirstLanguageDataLoaded = false
@State private var isSecondLanguageDataLoaded = false
Expand All @@ -149,12 +151,20 @@ struct SplashScreen: View {
.frame(width: 100, height: 100)
}
.onAppear {



log.info("*** NEW LAUNCHING SPLASHSCREEN ***")

// keychainViewModel.fetchToken(
// settings: settings,
// completion: {
// log.info("keychainViewModel token data loaded")
// })


CLLocationManager().requestWhenInUseAuthorization()

//?? deze standaard slechts 1 keer laden,
//?? betekend ergens opslaan, todo
languagesViewModel.fetchLanguageData(
settings: settings,
completion: {
Expand Down Expand Up @@ -187,13 +197,6 @@ struct SplashScreen: View {
checkDataLoaded()
})


// keychainViewModel.fetchToken(
// settings: settings,
// completion: {
// log.info("keychainViewModel token data loaded")
// })

speciesViewModel.fetchDataFirst( //contatenate fetching
settings: settings,
completion: {
Expand All @@ -203,9 +206,6 @@ struct SplashScreen: View {
isFirstLanguageDataLoaded = true
checkDataLoaded()
})
//just to test the initial view
// isFirstLanguageDataLoaded = true
// checkDataLoaded()
})

speciesViewModel.fetchDataSecondLanguage(
Expand All @@ -216,7 +216,6 @@ struct SplashScreen: View {
checkDataLoaded()
})

//iedere keer
userViewModel.fetchUserData(
settings: settings,
completion: {
Expand All @@ -237,11 +236,15 @@ struct SplashScreen: View {
// Use fetchedLocations here //actually it is one location
settings.locationName = fetchedLocations[0].name
for location in fetchedLocations {
log.info(location)
log.error("location \(location)")
}
print("locationIdViewModel data loaded")
isLocationIdDataLoaded = true
})
}



}
}

Expand Down
11 changes: 1 addition & 10 deletions Ravens/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@
}
}
}
},
"Filter Options" : {

},
"Filter rarity by" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -770,9 +767,6 @@
},
"Menu filter" : {

},
"Menu Sort" : {

},
"Month" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -915,7 +909,7 @@
"ObservationsSpeciesView" : {

},
"observationsSpeciesViewModel" : {
"ObservationsSpeciesViewIn2" : {

},
"ObservationsUserView" : {
Expand Down Expand Up @@ -1229,9 +1223,6 @@
}
}
}
},
"Sort Options" : {

},
"Sort/filter" : {
"extractionState" : "stale",
Expand Down
14 changes: 12 additions & 2 deletions Ravens/Model/Language.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ import Foundation

struct Language: Codable, Hashable {
let count: Int
let next, previous: URL? //?? naar kijken
let next, previous: URL?
let results: [Result]
}

struct Result: Codable, Hashable {
let code, name_en, name_native: String
let code: String
let nameEn: String
let nameNative: String

enum CodingKeys: String, CodingKey {
case code
case nameEn = "name_en"
case nameNative = "name_native"
}
}


9 changes: 8 additions & 1 deletion Ravens/Model/LocationJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ struct ApiResponse: Decodable {
struct LocationJSON: Decodable {
let id: Int
let name: String
let country_code: String
let countryCode: String
let permalink: String

enum CodingKeys: String, CodingKey {
case id
case name
case countryCode = "country_code"
case permalink
}
}
Loading

0 comments on commit f6e4f47

Please sign in to comment.