Fix activity view controllers on iPad

This commit is contained in:
Justin Mazzocchi 2021-01-19 11:00:26 -08:00
parent f3107094c9
commit c104f47ea9
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
3 changed files with 18 additions and 0 deletions

View file

@ -152,6 +152,11 @@ extension ImageViewController {
if let image = imageView.image {
let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: [])
if UIDevice.current.userInterfaceIdiom == .pad {
activityViewController.popoverPresentationController?
.barButtonItem = parent?.navigationItem.rightBarButtonItem
}
present(activityViewController, animated: true)
} else if let asset = playerView.player?.currentItem?.asset as? AVURLAsset {
asset.exportWithoutAudioTrack { result in
@ -162,6 +167,11 @@ extension ImageViewController {
activityItems: [url],
applicationActivities: [])
if UIDevice.current.userInterfaceIdiom == .pad {
activityViewController.popoverPresentationController?
.barButtonItem = self.parent?.navigationItem.rightBarButtonItem
}
activityViewController.completionWithItemsHandler = { _, _, _, _ in
try? FileManager.default.removeItem(at: url.deletingLastPathComponent())
}

View file

@ -444,6 +444,12 @@ private extension TableViewController {
func share(url: URL) {
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
if UIDevice.current.userInterfaceIdiom == .pad {
guard let sourceView = tableView.viewWithTag(url.hashValue) else { return }
activityViewController.popoverPresentationController?.sourceView = sourceView
}
present(activityViewController, animated: true, completion: nil)
}
}

View file

@ -430,6 +430,8 @@ private extension StatusView {
favoriteButton.tintColor = favoriteColor
favoriteButton.setTitleColor(favoriteColor, for: .normal)
shareButton.tag = viewModel.sharingURL?.hashValue ?? 0
}
// swiftlint:enable function_body_length