mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
+16
-21
@@ -14,15 +14,14 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import CoreLocation
|
||||
import SwiftUI
|
||||
|
||||
typealias LocationSharingViewModelType = StateStoreViewModel<LocationSharingViewState,
|
||||
Never,
|
||||
LocationSharingViewAction>
|
||||
Never,
|
||||
LocationSharingViewAction>
|
||||
class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingViewModelProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -36,8 +35,7 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
// MARK: - Setup
|
||||
|
||||
init(mapStyleURL: URL, avatarData: AvatarInputProtocol, isLiveLocationSharingEnabled: Bool = false, service: LocationSharingServiceProtocol) {
|
||||
|
||||
self.locationSharingService = service
|
||||
locationSharingService = service
|
||||
|
||||
let viewState = LocationSharingViewState(mapStyleURL: mapStyleURL,
|
||||
userAvatarData: avatarData,
|
||||
@@ -79,7 +77,7 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
state.showsUserLocation = true
|
||||
state.isPinDropSharing = false
|
||||
case .startLiveSharing:
|
||||
self.startLiveLocationSharing()
|
||||
startLiveLocationSharing()
|
||||
case .shareLiveLocation(let timeout):
|
||||
state.bindings.showingTimerSelector = false
|
||||
completion?(.shareLiveLocation(timeout: timeout.rawValue))
|
||||
@@ -101,8 +99,7 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
state.showLoadingIndicator = false
|
||||
|
||||
if let error = error {
|
||||
|
||||
let alertInfo: AlertInfo<LocationSharingAlertType>
|
||||
let alertInfo: AlertInfo<LocationSharingAlertType>
|
||||
|
||||
switch error {
|
||||
case .locationSharingPowerLevelError:
|
||||
@@ -128,7 +125,7 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
return
|
||||
}
|
||||
|
||||
let primaryButtonCompletion = { [weak self] () -> Void in
|
||||
let primaryButtonCompletion: (() -> Void)? = { [weak self] () in
|
||||
self?.completion?(.cancel)
|
||||
}
|
||||
|
||||
@@ -149,16 +146,15 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
title: VectorL10n.locationSharingInvalidAuthorizationErrorTitle(AppInfo.current.displayName),
|
||||
primaryButton: (VectorL10n.locationSharingInvalidAuthorizationNotNow, primaryButtonCompletion),
|
||||
secondaryButton: (VectorL10n.locationSharingInvalidAuthorizationSettings, {
|
||||
UIApplication.shared.vc_openSettings()
|
||||
}))
|
||||
UIApplication.shared.vc_openSettings()
|
||||
}))
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
private func checkLocationAuthorizationAndPresentTimerSelector() {
|
||||
|
||||
self.locationSharingService.requestAuthorization { [weak self] authorizationStatus in
|
||||
locationSharingService.requestAuthorization { [weak self] authorizationStatus in
|
||||
|
||||
guard let self = self else {
|
||||
return
|
||||
@@ -168,15 +164,15 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
case .unknown, .denied:
|
||||
// Show error alert
|
||||
self.state.bindings.alertInfo = AlertInfo(id: .userLocatingError,
|
||||
title: VectorL10n.locationSharingLocatingUserErrorTitle(AppInfo.current.displayName),
|
||||
title: VectorL10n.locationSharingLocatingUserErrorTitle(AppInfo.current.displayName),
|
||||
primaryButton: (VectorL10n.ok, { UIApplication.shared.vc_openSettings()
|
||||
}))
|
||||
}))
|
||||
case .authorizedInForeground:
|
||||
// When user only authorized location in foreground, advize to use background location
|
||||
self.state.bindings.alertInfo = AlertInfo(id: .userLocatingError,
|
||||
title: VectorL10n.locationSharingAllowBackgroundLocationTitle,
|
||||
message: VectorL10n.locationSharingAllowBackgroundLocationMessage,
|
||||
primaryButton: (VectorL10n.locationSharingAllowBackgroundLocationCancelAction, {}),
|
||||
message: VectorL10n.locationSharingAllowBackgroundLocationMessage,
|
||||
primaryButton: (VectorL10n.locationSharingAllowBackgroundLocationCancelAction, { }),
|
||||
secondaryButton: (VectorL10n.locationSharingAllowBackgroundLocationValidateAction, { UIApplication.shared.vc_openSettings() }))
|
||||
case .authorizedAlways:
|
||||
self.state.bindings.showingTimerSelector = true
|
||||
@@ -185,12 +181,11 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
}
|
||||
|
||||
private func startLiveLocationSharing() {
|
||||
|
||||
guard let completion = completion else {
|
||||
return
|
||||
}
|
||||
|
||||
completion(.checkLiveLocationCanBeStarted({ result in
|
||||
completion(.checkLiveLocationCanBeStarted { result in
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
@@ -200,6 +195,6 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
self.stopLoading(error: .locationSharingPowerLevelError)
|
||||
}
|
||||
}
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user