Integrate Amap SDK to replace CoreLocation and MapKit for all location features.

Unify GPS, reverse geocoding, and map display behind LocationProvider with privacy-gated bootstrap after login, aligned with Android.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-07 11:49:22 +08:00
parent d2879ad7e2
commit cfcd3eee6f
29 changed files with 748 additions and 240 deletions

View File

@ -30,7 +30,7 @@ final class HomeViewModel {
let locationReportService: LocationReportService
private let appStore: AppStore
private let commonMenuStore: HomeCommonMenuStore
private let locationProvider: HomeLocationProvider
private let locationProvider: any LocationProviding
private var timeoutDialogTriggered = false
private var dismissedLocationTimeoutDialog = false
@ -39,7 +39,7 @@ final class HomeViewModel {
appStore: AppStore = .shared,
locationStateStore: HomeLocationStateStore = HomeLocationStateStore(),
commonMenuStore: HomeCommonMenuStore = HomeCommonMenuStore(),
locationProvider: HomeLocationProvider = HomeLocationProvider()
locationProvider: any LocationProviding = LocationProvider.shared
) {
self.appStore = appStore
self.locationStateStore = locationStateStore

View File

@ -27,11 +27,11 @@ final class ScenicSelectionViewModel {
var onNavigateApplyStatus: ((String) -> Void)?
private let appStore: AppStore
private let locationProvider: HomeLocationProvider
private let locationProvider: any LocationProviding
private var currentLat: Double?
private var currentLng: Double?
init(appStore: AppStore = .shared, locationProvider: HomeLocationProvider = HomeLocationProvider()) {
init(appStore: AppStore = .shared, locationProvider: any LocationProviding = LocationProvider.shared) {
self.appStore = appStore
self.locationProvider = locationProvider
}
@ -63,7 +63,7 @@ final class ScenicSelectionViewModel {
let address = snapshot.address.trimmingCharacters(in: .whitespacesAndNewlines)
currentLocationText = address.isEmpty ? "最近的景区" : address
loadFromLocal()
} catch HomeLocationProviderError.permissionDenied {
} catch LocationProviderError.permissionDenied {
onShowMessage?("未授予定位权限,无法获取附近景区")
} catch {
onShowMessage?("定位失败: \(error.localizedDescription)")