完善景区排队设置页与全局按钮配置迁移。
重构排队设置与变更日志交互,补充 Overlay 与资源,并将多页面主操作按钮统一到 UIButton Configuration,同步更新相关单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -7,19 +7,19 @@ import CoreLocation
|
||||
import Foundation
|
||||
|
||||
/// 统一定位服务,封装高德 `AMapLocationManager`,对齐 Android `LocationProvider`。
|
||||
@MainActor
|
||||
final class LocationProvider: NSObject, LocationProviding {
|
||||
|
||||
static let shared = LocationProvider()
|
||||
nonisolated static let shared = LocationProvider()
|
||||
|
||||
private let permissionManager = CLLocationManager()
|
||||
private let geocoder: LocationGeocoder
|
||||
private let geocoder = LocationGeocoder.shared
|
||||
|
||||
init(geocoder: LocationGeocoder = .shared) {
|
||||
self.geocoder = geocoder
|
||||
nonisolated override init() {
|
||||
super.init()
|
||||
permissionManager.desiredAccuracy = kCLLocationAccuracyBest
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func requestSnapshot(desiredAccuracy: CLLocationAccuracy = kCLLocationAccuracyBest) async throws -> HomeLocationSnapshot {
|
||||
try AMapBootstrap.requireConfigured()
|
||||
try await ensureLocationPermission()
|
||||
@ -51,6 +51,7 @@ final class LocationProvider: NSObject, LocationProviding {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func requestCoordinate(desiredAccuracy: CLLocationAccuracy) async throws -> CLLocationCoordinate2D {
|
||||
try AMapBootstrap.requireConfigured()
|
||||
try await ensureLocationPermission()
|
||||
@ -77,12 +78,14 @@ final class LocationProvider: NSObject, LocationProviding {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func reverseGeocode(latitude: Double, longitude: Double) async -> String {
|
||||
await geocoder.reverseGeocode(latitude: latitude, longitude: longitude)
|
||||
}
|
||||
|
||||
/// 请求系统定位权限,首次弹窗后等待用户响应。
|
||||
func ensureLocationPermission() async throws {
|
||||
permissionManager.desiredAccuracy = kCLLocationAccuracyBest
|
||||
let initialStatus = permissionManager.authorizationStatus
|
||||
if initialStatus == .notDetermined {
|
||||
permissionManager.requestWhenInUseAuthorization()
|
||||
|
||||
Reference in New Issue
Block a user