mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-03 14:46:56 +02:00
5858: Resolve issue with bad import
This commit is contained in:
+36
-2
@@ -27,6 +27,40 @@ struct LocationSharingCoordinatorParameters {
|
||||
let coordinateType: MXEventAssetType
|
||||
}
|
||||
|
||||
// Map between type from MatrixSDK and type from SwiftUI target, as we don't want
|
||||
// to add the SDK as a dependency to it. We need to translate from one to the other on this level.
|
||||
extension MXEventAssetType {
|
||||
func locationSharingCoordinateType() -> LocationSharingCoordinateType {
|
||||
let coordinateType: LocationSharingCoordinateType
|
||||
switch self {
|
||||
case .user:
|
||||
coordinateType = .user
|
||||
case .pin:
|
||||
coordinateType = .pin
|
||||
case .generic:
|
||||
coordinateType = .generic
|
||||
@unknown default:
|
||||
coordinateType = .generic
|
||||
}
|
||||
return coordinateType
|
||||
}
|
||||
}
|
||||
|
||||
extension LocationSharingCoordinateType {
|
||||
func eventAssetType() -> MXEventAssetType {
|
||||
let eventAssetType: MXEventAssetType
|
||||
switch self {
|
||||
case .user:
|
||||
eventAssetType = .user
|
||||
case .pin:
|
||||
eventAssetType = .pin
|
||||
case .generic:
|
||||
eventAssetType = .generic
|
||||
}
|
||||
return eventAssetType
|
||||
}
|
||||
}
|
||||
|
||||
final class LocationSharingCoordinator: Coordinator, Presentable {
|
||||
|
||||
// MARK: - Properties
|
||||
@@ -52,7 +86,7 @@ final class LocationSharingCoordinator: Coordinator, Presentable {
|
||||
let viewModel = LocationSharingViewModel(mapStyleURL: BuildSettings.tileServerMapStyleURL,
|
||||
avatarData: parameters.avatarData,
|
||||
location: parameters.location,
|
||||
coordinateType: parameters.coordinateType,
|
||||
coordinateType: parameters.coordinateType.locationSharingCoordinateType(),
|
||||
isLiveLocationSharingEnabled: BuildSettings.liveLocationSharingEnabled)
|
||||
let view = LocationSharingView(context: viewModel.context)
|
||||
.addDependency(AvatarService.instantiate(mediaManager: parameters.mediaManager))
|
||||
@@ -84,7 +118,7 @@ final class LocationSharingCoordinator: Coordinator, Presentable {
|
||||
|
||||
self.locationSharingViewModel.startLoading()
|
||||
|
||||
self.parameters.roomDataSource.sendLocation(withLatitude: latitude, longitude: longitude, description: nil, coordinateType: coordinateType) { [weak self] _ in
|
||||
self.parameters.roomDataSource.sendLocation(withLatitude: latitude, longitude: longitude, description: nil, coordinateType: coordinateType.eventAssetType()) { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.locationSharingViewModel.stopLoading()
|
||||
|
||||
@@ -18,7 +18,13 @@ import Foundation
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import CoreLocation
|
||||
import MatrixSDK
|
||||
|
||||
// This is the equivalent of MXEventAssetType in the MatrixSDK
|
||||
enum LocationSharingCoordinateType {
|
||||
case user
|
||||
case pin
|
||||
case generic
|
||||
}
|
||||
|
||||
enum LocationSharingViewAction {
|
||||
case cancel
|
||||
@@ -29,7 +35,7 @@ enum LocationSharingViewAction {
|
||||
|
||||
enum LocationSharingViewModelResult {
|
||||
case cancel
|
||||
case share(latitude: Double, longitude: Double, coordinateType: MXEventAssetType)
|
||||
case share(latitude: Double, longitude: Double, coordinateType: LocationSharingCoordinateType)
|
||||
}
|
||||
|
||||
enum LocationSharingViewError {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import CoreLocation
|
||||
import MatrixSDK
|
||||
|
||||
@available(iOS 14, *)
|
||||
typealias LocationSharingViewModelType = StateStoreViewModel<LocationSharingViewState,
|
||||
@@ -36,7 +35,7 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(mapStyleURL: URL, avatarData: AvatarInputProtocol, location: CLLocationCoordinate2D? = nil, coordinateType: MXEventAssetType, isLiveLocationSharingEnabled: Bool = false) {
|
||||
init(mapStyleURL: URL, avatarData: AvatarInputProtocol, location: CLLocationCoordinate2D? = nil, coordinateType: LocationSharingCoordinateType, isLiveLocationSharingEnabled: Bool = false) {
|
||||
|
||||
var sharedAnnotation: UserLocationAnnotation?
|
||||
var annotations: [UserLocationAnnotation] = []
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
import Foundation
|
||||
import Mapbox
|
||||
import MatrixSDK
|
||||
|
||||
class UserLocationAnnotation: NSObject, MGLAnnotation {
|
||||
|
||||
@@ -26,13 +25,13 @@ class UserLocationAnnotation: NSObject, MGLAnnotation {
|
||||
|
||||
let coordinate: CLLocationCoordinate2D
|
||||
|
||||
let coordinateType: MXEventAssetType
|
||||
let coordinateType: LocationSharingCoordinateType
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(avatarData: AvatarInputProtocol,
|
||||
coordinate: CLLocationCoordinate2D,
|
||||
coordinateType: MXEventAssetType) {
|
||||
coordinateType: LocationSharingCoordinateType) {
|
||||
|
||||
self.coordinate = coordinate
|
||||
self.avatarData = avatarData
|
||||
|
||||
Reference in New Issue
Block a user