Swiftgram/TelegramUI/LegacyLocationPicker.swift
2017-10-03 15:57:32 +03:00

22 lines
1.0 KiB
Swift

import Foundation
import Display
import LegacyComponents
import TelegramCore
func legacyLocationPickerController(sendLocation: @escaping (CLLocationCoordinate2D, MapVenue?) -> Void) -> ViewController {
let legacyController = LegacyController(presentation: .modal(animateIn: true))
let controller = TGLocationPickerController(context: legacyController.context, intent: TGLocationPickerControllerDefaultIntent)!
let navigationController = TGNavigationController(controllers: [controller])!
controller.navigation_setDismiss({ [weak legacyController] in
legacyController?.dismiss()
}, rootController: nil)
legacyController.bind(controller: navigationController)
controller.locationPicked = { [weak legacyController] coordinate, venue in
sendLocation(coordinate, venue.flatMap { venue in
return MapVenue(title: venue.title, address: venue.address, provider: venue.provider, id: venue.venueId, type: venue.type)
})
legacyController?.dismiss()
}
return legacyController
}