mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 05:43:37 +00:00
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
26 lines
1008 B
Swift
26 lines
1008 B
Swift
typealias OpenInApplicationCompletionHandler = (OpenInApplication) -> Void
|
|
|
|
extension UIAlertController {
|
|
static func presentInAppActionSheet(from sourceView: UIView,
|
|
apps: [OpenInApplication] = OpenInApplication.availableApps,
|
|
didSelectApp: @escaping OpenInApplicationCompletionHandler) -> UIAlertController {
|
|
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
|
|
|
apps.forEach { app in
|
|
let action = UIAlertAction(title: app.name, style: .default) { _ in
|
|
didSelectApp(app)
|
|
}
|
|
alertController.addAction(action)
|
|
}
|
|
|
|
let cancelAction = UIAlertAction(title: L("cancel"), style: .cancel)
|
|
alertController.addAction(cancelAction)
|
|
|
|
iPadSpecific {
|
|
alertController.popoverPresentationController?.sourceView = sourceView
|
|
alertController.popoverPresentationController?.sourceRect = sourceView.bounds
|
|
}
|
|
return alertController
|
|
}
|
|
}
|