Configured and applied SwiftFormat

This commit is contained in:
Stefan Ceriu
2022-09-27 10:17:22 +03:00
committed by Stefan Ceriu
parent ff2e6ddfa7
commit 43c28d23b7
663 changed files with 2329 additions and 2840 deletions
@@ -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)
}
}
}))
})
}
}