feature/async_single_value_storage_map_ui_settings #7

Merged
ivan.smolin merged 5 commits from feature/async_single_value_storage_map_ui_settings into master 2023-06-07 20:00:43 +03:00
Member

Добавлены UI настройки для всех поддерживаемых карт

Пример для Apple Maps:

    func didFinishLoading(fuelingStations: [FuelingStation]) {
        mapManager = AppleMapManager(map: customView) { [weak self] in
            self?.focus(to: $0)

            return true
        }

        mapManager?.apply(settings: AppleMapUISettings(showUserLocation: true,
                                                       isRotationEnabled: false,
                                                       showCompassButton: true))

        mapManager?.set(items: fuelingStations)
    }

Отрисовка маркера текущего местоположения для Yandex Maps:

Добавлен UserLocationFetcher для получения текущей геопозиции пользователя

init() {
        let locationManager = CLLocationManager()
        locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters

        locationFetcher = UserLocationFetcher(locationManager: locationManager,
                                              accuracyRequest: .fullAccuracy(purposeKey: "NearFuelingStationRequest"))

        super.init()

        locationFetcher.authFailureCallback = { [weak self] in
            self?.onUserLocation(failure: $0)
        }

        locationFetcher.locationCallback = { [weak self] in
            self?.didReceive(userLocation: $0)
        }

        locationFetcher.requestLocationUpdates(onlyIfHasAccess: true)
    }

    func viewDidLoad() {
        startLogin()
        fetchFuelingStations()

        locationFetcher.requestLocationUpdates()
    }
    
    private func onUserLocation(failure: UserLocationFetcher.Failure) {
        guard let view else {
            return
        }

        let descriptor: AlertDescriptor

        switch failure {
        case .restricted:
            descriptor = alertFactory
                .okAlert(title: "Нет доступа к геолокации",
                               message: "Доступ к геосервисам ограничен")

        case .denied:
            descriptor = alertFactory
                .dialogueAlert(title: "Нет доступа к геолокации",
                               message: "Для определения местоположения и ближайших АЗС разрешите доступ к геолокации в настройках",
                               yesAction: {
                    try? UIApplication.shared.open(UIApplication.openSettingsURLString.asURL())
                })

        case .fullAccuracyDenied:
            descriptor = alertFactory
                .dialogueAlert(title: "Нет доступа к точной геолокации",
                               message: "Для определения местоположения и ближайших АЗС разрешите доступ к высокоточной геолокации в настройках",
                               yesAction: {
                    try? UIApplication.shared.open(UIApplication.openSettingsURLString.asURL())
                })
        }

        descriptor.present(on: view)
    }
### Добавлены UI настройки для всех поддерживаемых карт Пример для Apple Maps: ```swift func didFinishLoading(fuelingStations: [FuelingStation]) { mapManager = AppleMapManager(map: customView) { [weak self] in self?.focus(to: $0) return true } mapManager?.apply(settings: AppleMapUISettings(showUserLocation: true, isRotationEnabled: false, showCompassButton: true)) mapManager?.set(items: fuelingStations) } ``` ### Отрисовка маркера текущего местоположения для Yandex Maps: <img width="350px" src="https://github.com/TouchInstinct/LeadKit/assets/6436245/fba95008-bd31-4aa6-a9e9-140f1625ae50"> ### Добавлен UserLocationFetcher для получения текущей геопозиции пользователя ```swift init() { let locationManager = CLLocationManager() locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters locationFetcher = UserLocationFetcher(locationManager: locationManager, accuracyRequest: .fullAccuracy(purposeKey: "NearFuelingStationRequest")) super.init() locationFetcher.authFailureCallback = { [weak self] in self?.onUserLocation(failure: $0) } locationFetcher.locationCallback = { [weak self] in self?.didReceive(userLocation: $0) } locationFetcher.requestLocationUpdates(onlyIfHasAccess: true) } func viewDidLoad() { startLogin() fetchFuelingStations() locationFetcher.requestLocationUpdates() } private func onUserLocation(failure: UserLocationFetcher.Failure) { guard let view else { return } let descriptor: AlertDescriptor switch failure { case .restricted: descriptor = alertFactory .okAlert(title: "Нет доступа к геолокации", message: "Доступ к геосервисам ограничен") case .denied: descriptor = alertFactory .dialogueAlert(title: "Нет доступа к геолокации", message: "Для определения местоположения и ближайших АЗС разрешите доступ к геолокации в настройках", yesAction: { try? UIApplication.shared.open(UIApplication.openSettingsURLString.asURL()) }) case .fullAccuracyDenied: descriptor = alertFactory .dialogueAlert(title: "Нет доступа к точной геолокации", message: "Для определения местоположения и ближайших АЗС разрешите доступ к высокоточной геолокации в настройках", yesAction: { try? UIApplication.shared.open(UIApplication.openSettingsURLString.asURL()) }) } descriptor.present(on: view) } ```
ivan.smolin added 5 commits 2023-06-05 16:40:44 +03:00
vladimir.makarov reviewed 2023-06-06 10:27:07 +03:00
@ -0,0 +79,4 @@
public var tintColor: UIColor = .red {
didSet {
userLocationObjectListener?.tintColor = tintColor

А не надо дополнительно менять view.accuracyCircle.fillColor при изменении tintColor?

А не надо дополнительно менять `view.accuracyCircle.fillColor` при изменении `tintColor`?
Author
Member

это делает userLocationObjectListener внутри didSet tintColor или я не понял вопрос

это делает userLocationObjectListener внутри didSet tintColor или я не понял вопрос

А, всё, увидел, спасибо за ответ

А, всё, увидел, спасибо за ответ
vladimir.makarov marked this conversation as resolved
vladimir.makarov approved these changes 2023-06-06 11:26:27 +03:00
ivan.smolin merged commit f50bb09ad8 into master 2023-06-07 20:00:43 +03:00
ivan.smolin deleted branch feature/async_single_value_storage_map_ui_settings 2023-06-07 20:00:43 +03:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: TouchInstinct/LeadKit#7
No description provided.