From dc3f20e108d70f5ba23e0d36e200ef3ae80f4429 Mon Sep 17 00:00:00 2001 From: Marta Panuszewska Date: Tue, 30 Sep 2025 14:33:59 +0200 Subject: [PATCH 1/3] fix: Keep location from search from changing --- .../xcshareddata/swiftpm/Package.resolved | 177 +++++++++++++++++- .../ChooseCustomLocationView.swift | 12 +- .../ConfirmCreatingSessionView.swift | 53 +++++- AirCasting/Map/LocationTracker.swift | 6 +- AirCasting/Models/SessionContext.swift | 1 + 5 files changed, 237 insertions(+), 12 deletions(-) diff --git a/AirCasting.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AirCasting.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6af2cd056..9c1fb1977 100644 --- a/AirCasting.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AirCasting.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,13 +1,175 @@ { "object": { "pins": [ + { + "package": "abseil", + "repositoryURL": "https://github.com/google/abseil-cpp-binary.git", + "state": { + "branch": null, + "revision": "194a6706acbd25e4ef639bcaddea16e8758a3e27", + "version": "1.2024011602.0" + } + }, + { + "package": "AppCheck", + "repositoryURL": "https://github.com/google/app-check.git", + "state": { + "branch": null, + "revision": "3b62f154d00019ae29a71e9738800bb6f18b236d", + "version": "10.19.2" + } + }, { "package": "Charts", - "repositoryURL": "https://github.com/danielgindi/Charts", + "repositoryURL": "https://github.com/jterhorst/Charts", + "state": { + "branch": "bugfix/3.6.1_xcode14_compilation", + "revision": "0cc20181d2e709032495091d8879ca4a95587e3d", + "version": null + } + }, + { + "package": "DeviceKit", + "repositoryURL": "https://github.com/devicekit/DeviceKit", + "state": { + "branch": null, + "revision": "d37e70cb2646666dcf276d7d3d4a9760a41ff8a6", + "version": "4.9.0" + } + }, + { + "package": "Firebase", + "repositoryURL": "https://github.com/firebase/firebase-ios-sdk", + "state": { + "branch": null, + "revision": "e57841b296d04370ea23580f908881b0ccab17b9", + "version": "10.28.1" + } + }, + { + "package": "GoogleAppMeasurement", + "repositoryURL": "https://github.com/google/GoogleAppMeasurement.git", + "state": { + "branch": null, + "revision": "fe727587518729046fc1465625b9afd80b5ab361", + "version": "10.28.0" + } + }, + { + "package": "GoogleDataTransport", + "repositoryURL": "https://github.com/google/GoogleDataTransport.git", + "state": { + "branch": null, + "revision": "a637d318ae7ae246b02d7305121275bc75ed5565", + "version": "9.4.0" + } + }, + { + "package": "GoogleUtilities", + "repositoryURL": "https://github.com/google/GoogleUtilities.git", + "state": { + "branch": null, + "revision": "57a1d307f42df690fdef2637f3e5b776da02aad6", + "version": "7.13.3" + } + }, + { + "package": "gRPC", + "repositoryURL": "https://github.com/google/grpc-binary.git", + "state": { + "branch": null, + "revision": "e9fad491d0673bdda7063a0341fb6b47a30c5359", + "version": "1.62.2" + } + }, + { + "package": "GTMSessionFetcher", + "repositoryURL": "https://github.com/google/gtm-session-fetcher.git", + "state": { + "branch": null, + "revision": "a2ab612cb980066ee56d90d60d8462992c07f24b", + "version": "3.5.0" + } + }, + { + "package": "Gzip", + "repositoryURL": "https://github.com/1024jp/GzipSwift", + "state": { + "branch": null, + "revision": "731037f6cc2be2ec01562f6597c1d0aa3fe6fd05", + "version": "6.0.1" + } + }, + { + "package": "InteropForGoogle", + "repositoryURL": "https://github.com/google/interop-ios-for-google-sdks.git", + "state": { + "branch": null, + "revision": "2d12673670417654f08f5f90fdd62926dc3a2648", + "version": "100.0.0" + } + }, + { + "package": "leveldb", + "repositoryURL": "https://github.com/firebase/leveldb.git", "state": { "branch": null, - "revision": "66546404a6739173b8e436ab6bc1f2897cd08594", - "version": "3.6.0" + "revision": "a0bc79961d7be727d258d33d5a6b2f1023270ba1", + "version": "1.22.5" + } + }, + { + "package": "nanopb", + "repositoryURL": "https://github.com/firebase/nanopb.git", + "state": { + "branch": null, + "revision": "b7e1104502eca3a213b46303391ca4d3bc8ddec1", + "version": "2.30910.0" + } + }, + { + "package": "Promises", + "repositoryURL": "https://github.com/google/promises.git", + "state": { + "branch": null, + "revision": "540318ecedd63d883069ae7f1ed811a2df00b6ac", + "version": "2.4.0" + } + }, + { + "package": "Resolver", + "repositoryURL": "https://github.com/hmlongco/Resolver", + "state": { + "branch": null, + "revision": "97de0b0320036607564af4a60025b48f8d041221", + "version": "1.5.0" + } + }, + { + "package": "swift-algorithms", + "repositoryURL": "https://github.com/apple/swift-algorithms.git", + "state": { + "branch": null, + "revision": "87e50f483c54e6efd60e885f7f5aa946cee68023", + "version": "1.2.1" + } + }, + { + "package": "swift-numerics", + "repositoryURL": "https://github.com/apple/swift-numerics.git", + "state": { + "branch": null, + "revision": "bbadd4b853a33fd78c4ae977d17bb2af15eb3f2a", + "version": "1.1.0" + } + }, + { + "package": "SwiftProtobuf", + "repositoryURL": "https://github.com/apple/swift-protobuf.git", + "state": { + "branch": null, + "revision": "2547102afd04fe49f1b286090f13ebce07284980", + "version": "1.31.1" } }, { @@ -18,6 +180,15 @@ "revision": "d4cbe1889c7b650b4753d1ec681e9967588995f7", "version": "1.1.1" } + }, + { + "package": "ZipArchive", + "repositoryURL": "https://github.com/ZipArchive/ZipArchive", + "state": { + "branch": null, + "revision": "825ff12a74a94c54e737e279604c27e6740e8a2c", + "version": "2.4.2" + } } ] }, diff --git a/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift b/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift index bad3ad105..7ac5575ce 100644 --- a/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift +++ b/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift @@ -14,6 +14,7 @@ struct ChooseCustomLocationView: View { @Binding var creatingSessionFlowContinues: Bool @StateObject private var locationTracker = BindableLocationTracker() var sessionName: String + @State private var locationChangedProgramatically: Bool = false @Injected private var AppLocationTracker: LocationTracker @EnvironmentObject private var sessionContext: CreateSessionContext @@ -37,7 +38,10 @@ struct ChooseCustomLocationView: View { } .background(confirmCreatingSessionLink) .sheet(isPresented: $isLocationPopupPresented, onDismiss: { + guard let newLocation = location else { return } + Log.warning("2: \(newLocation)") + locationChangedProgramatically = true locationTracker.ovverridenLocation = newLocation }, content: { PlacePicker(service: ChooseLocationPickerService(address: $locationName, @@ -58,8 +62,12 @@ struct ChooseCustomLocationView: View { locationTracker: locationTracker, stickHardToTheUser: true) .indicateMapLocationChange { newLocation in - location = .init(latitude: newLocation.coordinate.latitude, - longitude: newLocation.coordinate.longitude) + Log.warning("1: \(newLocation)") + if !locationChangedProgramatically { + locationChangedProgramatically = false + location = .init(latitude: newLocation.coordinate.latitude, + longitude: newLocation.coordinate.longitude) + } } .onMyLocationButtonTapped { locationTracker.ovverridenLocation = nil diff --git a/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift b/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift index 1d47c215e..0cd23f187 100644 --- a/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift +++ b/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift @@ -21,6 +21,7 @@ struct ConfirmCreatingSessionView: View { @EnvironmentObject var selectedSection: SelectedSection @EnvironmentObject private var sessionContext: CreateSessionContext @Injected private var locationTracker: LocationTracker + private var constantTracker: ConstantTracker? @Injected private var downloadMeasurementsService: DownloadMeasurementsService @EnvironmentObject private var tabSelection: TabBarSelector @Binding var creatingSessionFlowContinues: Bool @@ -31,9 +32,14 @@ struct ConfirmCreatingSessionView: View { private var shouldTrackLocation: Bool { sessionContext.sessionType == .mobile && !sessionContext.locationless } init(creatingSessionFlowContinues: Binding, sessionName: String, initialLocation: CLLocation? = nil) { + Log.warning("Confirm creating session view initial location: \(initialLocation)") _creatingSessionFlowContinues = .init(projectedValue: creatingSessionFlowContinues) self.sessionName = sessionName self.initialLocation = initialLocation + + if let initialLocation = initialLocation { + self.constantTracker = ConstantTracker(location: initialLocation) + } } var body: some View { @@ -123,7 +129,7 @@ struct ConfirmCreatingSessionView: View { type: .normal, trackingStyle: .none, userIndicatorStyle: .none, - locationTracker: ConstantTracker(location: initialLocation!), + locationTracker: constantTracker!, markers: []) .disabled(true) // It needs to be disabled to prevent user interaction (swiping map) because it is only conformation screen @@ -178,13 +184,48 @@ extension ConfirmCreatingSessionView { sessionContext.saveCurrentLocation(lat: krakowLat, log: krakowLong) return #endif - if sessionContext.sessionType == .fixed || sessionContext.locationless { - if sessionContext.isIndoor! || sessionContext.locationless { - sessionContext.saveCurrentLocation(lat: 200, log: 200) + Log.warning("getAndSaveStartingLocation location entered") + + if (sessionContext.sessionType == .fixed && sessionContext.isIndoor!) || sessionContext.locationless { + Log.warning("getAndSaveStartingLocation location entered \(sessionContext.sessionType == .fixed ), locationless: \(sessionContext.locationless)") + Log.warning("getAndSaveStartingLocation location entered 2 \(sessionContext.isIndoor!)") + sessionContext.saveCurrentLocation(lat: 200, log: 200) + } else if (sessionContext.sessionType == .fixed && !sessionContext.isIndoor!) { + + guard let lat = (constantTracker?.location.coordinate.latitude), + let lon = (constantTracker?.location.coordinate.longitude) + else { + Log.error("No location found!") + return } + + Log.warning("HERE lat: \(lat), lon: \(lon)") + // MARTA: Above is working but the session is in the ocean + // Chek: Was michael's example the same? Maybe just 0,0 is in the ocean but now this is fixed? + // This can be due to area instead of specific place differences + // Check: Did my changes actually fix anything? Or was is still in a good place just not zoomed out? + // Map is still not fixed (or is it just showing the sea?) + // W pewnym momencie lokalizacja sie zmienia w ConfirmCreatingSessionView + + /*[09-29-2025 15:32:16.664] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.507, -0.128)) + [09-29-2025 15:32:17.184] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.507, -0.128)) + [09-29-2025 15:32:17.453] ChooseCustomLocationView.swift: ⚠️ 1: <+51.35636507,+1.96028609> +/- 0.00m (speed -1.00 mps / course -1.00) @ 29/09/2025, 17:32:17 Central European Summer Time + [09-29-2025 15:32:17.454] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.356, 1.960)) + [09-29-2025 15:32:17.941] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.356, 1.960))*/ + + sessionContext.saveCurrentLocation(lat: lat, log: lon) + } else { + //Log.warning("getAndSaveStartingLocation check for lat and long: \(locationTracker.location.value as Any)") + guard let lat = (locationTracker.location.value?.coordinate.latitude), - let lon = (locationTracker.location.value?.coordinate.longitude) else { return } + let lon = (locationTracker.location.value?.coordinate.longitude) + else { + Log.error("No location found!") + return + } + + //Log.warning("getAndSaveStartingLocation lat: \(lat), lon: \(lon)") sessionContext.saveCurrentLocation(lat: lat, log: lon) } } @@ -199,8 +240,8 @@ extension ConfirmCreatingSessionView { } else if sessionContext.sessionType == .mobile { return MobilePeripheralSessionCreator() } else { - return nil Log.info("Can't set the session creator storage") + return nil } } diff --git a/AirCasting/Map/LocationTracker.swift b/AirCasting/Map/LocationTracker.swift index d1f29349f..ecff7e907 100644 --- a/AirCasting/Map/LocationTracker.swift +++ b/AirCasting/Map/LocationTracker.swift @@ -172,13 +172,17 @@ class MapLocationTrackerAdapter: MapLocationTracker { } struct ConstantTracker: MapLocationTracker { + let location: CLLocation func getLastKnownLocation() -> CLLocation? { - location + Log.warning("Constant tracker get last known location location: \(location)") + return location } func startTrackingUserPosition(_ newPos: @escaping (CLLocation) -> Void) -> MapLocationTrackerStoper { + Log.warning("Constant tracker start tracking user position location: \(location)") + newPos(location) return Stoper() } diff --git a/AirCasting/Models/SessionContext.swift b/AirCasting/Models/SessionContext.swift index 7aa3f20b4..464ac5eda 100644 --- a/AirCasting/Models/SessionContext.swift +++ b/AirCasting/Models/SessionContext.swift @@ -41,6 +41,7 @@ final class CreateSessionContext: ObservableObject { func saveCurrentLocation(lat: Double, log: Double) { startingLocation = CLLocationCoordinate2D(latitude: lat, longitude: log) + Log.warning("saved in context \(String(describing: self.startingLocation))") } var isMobileSession: Bool { sessionType == .mobile From dda36cb264ee8aba28aafd00a5b186055792ba76 Mon Sep 17 00:00:00 2001 From: Marta Panuszewska Date: Tue, 30 Sep 2025 14:38:37 +0200 Subject: [PATCH 2/3] REmove all comments and logs --- .../ChooseCustomLocationView.swift | 4 +--- .../ConfirmCreatingSessionView.swift | 22 ------------------- AirCasting/Map/LocationTracker.swift | 6 +---- AirCasting/Models/SessionContext.swift | 1 - 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift b/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift index 7ac5575ce..b28f75586 100644 --- a/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift +++ b/AirCasting/CreateSessionViews/ChooseCustomLocationView.swift @@ -38,9 +38,8 @@ struct ChooseCustomLocationView: View { } .background(confirmCreatingSessionLink) .sheet(isPresented: $isLocationPopupPresented, onDismiss: { - guard let newLocation = location else { return } - Log.warning("2: \(newLocation)") + locationChangedProgramatically = true locationTracker.ovverridenLocation = newLocation }, content: { @@ -62,7 +61,6 @@ struct ChooseCustomLocationView: View { locationTracker: locationTracker, stickHardToTheUser: true) .indicateMapLocationChange { newLocation in - Log.warning("1: \(newLocation)") if !locationChangedProgramatically { locationChangedProgramatically = false location = .init(latitude: newLocation.coordinate.latitude, diff --git a/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift b/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift index 0cd23f187..0c59e907f 100644 --- a/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift +++ b/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift @@ -32,7 +32,6 @@ struct ConfirmCreatingSessionView: View { private var shouldTrackLocation: Bool { sessionContext.sessionType == .mobile && !sessionContext.locationless } init(creatingSessionFlowContinues: Binding, sessionName: String, initialLocation: CLLocation? = nil) { - Log.warning("Confirm creating session view initial location: \(initialLocation)") _creatingSessionFlowContinues = .init(projectedValue: creatingSessionFlowContinues) self.sessionName = sessionName self.initialLocation = initialLocation @@ -184,11 +183,8 @@ extension ConfirmCreatingSessionView { sessionContext.saveCurrentLocation(lat: krakowLat, log: krakowLong) return #endif - Log.warning("getAndSaveStartingLocation location entered") if (sessionContext.sessionType == .fixed && sessionContext.isIndoor!) || sessionContext.locationless { - Log.warning("getAndSaveStartingLocation location entered \(sessionContext.sessionType == .fixed ), locationless: \(sessionContext.locationless)") - Log.warning("getAndSaveStartingLocation location entered 2 \(sessionContext.isIndoor!)") sessionContext.saveCurrentLocation(lat: 200, log: 200) } else if (sessionContext.sessionType == .fixed && !sessionContext.isIndoor!) { @@ -199,33 +195,15 @@ extension ConfirmCreatingSessionView { return } - Log.warning("HERE lat: \(lat), lon: \(lon)") - // MARTA: Above is working but the session is in the ocean - // Chek: Was michael's example the same? Maybe just 0,0 is in the ocean but now this is fixed? - // This can be due to area instead of specific place differences - // Check: Did my changes actually fix anything? Or was is still in a good place just not zoomed out? - // Map is still not fixed (or is it just showing the sea?) - // W pewnym momencie lokalizacja sie zmienia w ConfirmCreatingSessionView - - /*[09-29-2025 15:32:16.664] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.507, -0.128)) - [09-29-2025 15:32:17.184] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.507, -0.128)) - [09-29-2025 15:32:17.453] ChooseCustomLocationView.swift: ⚠️ 1: <+51.35636507,+1.96028609> +/- 0.00m (speed -1.00 mps / course -1.00) @ 29/09/2025, 17:32:17 Central European Summer Time - [09-29-2025 15:32:17.454] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.356, 1.960)) - [09-29-2025 15:32:17.941] ConfirmCreatingSessionView.swift: ⚠️ Confirm creating session view initial location: Optional((51.356, 1.960))*/ - sessionContext.saveCurrentLocation(lat: lat, log: lon) } else { - //Log.warning("getAndSaveStartingLocation check for lat and long: \(locationTracker.location.value as Any)") - guard let lat = (locationTracker.location.value?.coordinate.latitude), let lon = (locationTracker.location.value?.coordinate.longitude) else { Log.error("No location found!") return } - - //Log.warning("getAndSaveStartingLocation lat: \(lat), lon: \(lon)") sessionContext.saveCurrentLocation(lat: lat, log: lon) } } diff --git a/AirCasting/Map/LocationTracker.swift b/AirCasting/Map/LocationTracker.swift index ecff7e907..d1f29349f 100644 --- a/AirCasting/Map/LocationTracker.swift +++ b/AirCasting/Map/LocationTracker.swift @@ -172,17 +172,13 @@ class MapLocationTrackerAdapter: MapLocationTracker { } struct ConstantTracker: MapLocationTracker { - let location: CLLocation func getLastKnownLocation() -> CLLocation? { - Log.warning("Constant tracker get last known location location: \(location)") - return location + location } func startTrackingUserPosition(_ newPos: @escaping (CLLocation) -> Void) -> MapLocationTrackerStoper { - Log.warning("Constant tracker start tracking user position location: \(location)") - newPos(location) return Stoper() } diff --git a/AirCasting/Models/SessionContext.swift b/AirCasting/Models/SessionContext.swift index 464ac5eda..7aa3f20b4 100644 --- a/AirCasting/Models/SessionContext.swift +++ b/AirCasting/Models/SessionContext.swift @@ -41,7 +41,6 @@ final class CreateSessionContext: ObservableObject { func saveCurrentLocation(lat: Double, log: Double) { startingLocation = CLLocationCoordinate2D(latitude: lat, longitude: log) - Log.warning("saved in context \(String(describing: self.startingLocation))") } var isMobileSession: Bool { sessionType == .mobile From 894623dc45fbf0f57845a0405530bdf03bdcdca0 Mon Sep 17 00:00:00 2001 From: Marta Panuszewska Date: Tue, 30 Sep 2025 14:49:14 +0200 Subject: [PATCH 3/3] This was actually unnecessary I think --- .../ConfirmCreatingSessionView.swift | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift b/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift index 0c59e907f..1d47c215e 100644 --- a/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift +++ b/AirCasting/CreateSessionViews/ConfirmCreatingSessionView.swift @@ -21,7 +21,6 @@ struct ConfirmCreatingSessionView: View { @EnvironmentObject var selectedSection: SelectedSection @EnvironmentObject private var sessionContext: CreateSessionContext @Injected private var locationTracker: LocationTracker - private var constantTracker: ConstantTracker? @Injected private var downloadMeasurementsService: DownloadMeasurementsService @EnvironmentObject private var tabSelection: TabBarSelector @Binding var creatingSessionFlowContinues: Bool @@ -35,10 +34,6 @@ struct ConfirmCreatingSessionView: View { _creatingSessionFlowContinues = .init(projectedValue: creatingSessionFlowContinues) self.sessionName = sessionName self.initialLocation = initialLocation - - if let initialLocation = initialLocation { - self.constantTracker = ConstantTracker(location: initialLocation) - } } var body: some View { @@ -128,7 +123,7 @@ struct ConfirmCreatingSessionView: View { type: .normal, trackingStyle: .none, userIndicatorStyle: .none, - locationTracker: constantTracker!, + locationTracker: ConstantTracker(location: initialLocation!), markers: []) .disabled(true) // It needs to be disabled to prevent user interaction (swiping map) because it is only conformation screen @@ -183,27 +178,13 @@ extension ConfirmCreatingSessionView { sessionContext.saveCurrentLocation(lat: krakowLat, log: krakowLong) return #endif - - if (sessionContext.sessionType == .fixed && sessionContext.isIndoor!) || sessionContext.locationless { - sessionContext.saveCurrentLocation(lat: 200, log: 200) - } else if (sessionContext.sessionType == .fixed && !sessionContext.isIndoor!) { - - guard let lat = (constantTracker?.location.coordinate.latitude), - let lon = (constantTracker?.location.coordinate.longitude) - else { - Log.error("No location found!") - return + if sessionContext.sessionType == .fixed || sessionContext.locationless { + if sessionContext.isIndoor! || sessionContext.locationless { + sessionContext.saveCurrentLocation(lat: 200, log: 200) } - - sessionContext.saveCurrentLocation(lat: lat, log: lon) - } else { guard let lat = (locationTracker.location.value?.coordinate.latitude), - let lon = (locationTracker.location.value?.coordinate.longitude) - else { - Log.error("No location found!") - return - } + let lon = (locationTracker.location.value?.coordinate.longitude) else { return } sessionContext.saveCurrentLocation(lat: lat, log: lon) } } @@ -218,8 +199,8 @@ extension ConfirmCreatingSessionView { } else if sessionContext.sessionType == .mobile { return MobilePeripheralSessionCreator() } else { - Log.info("Can't set the session creator storage") return nil + Log.info("Can't set the session creator storage") } }