Sharing event
This commit is contained in:
parent
5cc4ca02be
commit
2481045a9c
@ -129,6 +129,10 @@ struct EventsScreen: View {
|
|||||||
} label: {
|
} label: {
|
||||||
Label("Open in Maps", systemImage: "map")
|
Label("Open in Maps", systemImage: "map")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let link = viewModel.getMapLink(for: event) {
|
||||||
|
ShareLink(item: link)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,9 +132,9 @@ class EventsViewModel: ACHudContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMapLink(for event: VehicleEventDto) -> URL? {
|
func getMapLink(for event: EventModel) -> URL? {
|
||||||
var urlString = "http://maps.apple.com/?sll=\(event.latitude),\(event.longitude)"
|
var urlString = "http://maps.apple.com/?sll=\(event.coordinate.latitude),\(event.coordinate.longitude)"
|
||||||
if let address = event.address?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
|
if let address = event.address.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
|
||||||
urlString = urlString + "&address=" + address
|
urlString = urlString + "&address=" + address
|
||||||
}
|
}
|
||||||
return URL(string: urlString)
|
return URL(string: urlString)
|
||||||
@ -146,7 +146,7 @@ class EventsViewModel: ACHudContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let sharedData: [String: Any?] = [
|
let sharedData: [String: Any?] = [
|
||||||
UTType.url.identifier: getMapLink(for: eventDto),
|
UTType.url.identifier: getMapLink(for: event),
|
||||||
UTType.vehicleEvent.identifier: try? JSONEncoder().encode(eventDto)
|
UTType.vehicleEvent.identifier: try? JSONEncoder().encode(eventDto)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user