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