forked from shadowfacts/Tusker
Prompt for Photos access before showing asset picker
This commit is contained in:
parent
c7b4d00da7
commit
5d0c59e863
|
@ -10,6 +10,7 @@ import UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import MobileCoreServices
|
import MobileCoreServices
|
||||||
import PencilKit
|
import PencilKit
|
||||||
|
import Photos
|
||||||
|
|
||||||
protocol ComposeAttachmentsViewControllerDelegate: class {
|
protocol ComposeAttachmentsViewControllerDelegate: class {
|
||||||
func composeSelectedAttachmentsDidChange()
|
func composeSelectedAttachmentsDidChange()
|
||||||
|
@ -353,18 +354,23 @@ class ComposeAttachmentsViewController: UITableViewController {
|
||||||
// MARK: Interaction
|
// MARK: Interaction
|
||||||
|
|
||||||
func addAttachmentPressed() {
|
func addAttachmentPressed() {
|
||||||
if traitCollection.horizontalSizeClass == .compact {
|
PHPhotoLibrary.requestAuthorization { (status) in
|
||||||
let sheetContainer = AssetPickerSheetContainerViewController()
|
guard status == .authorized else { return }
|
||||||
sheetContainer.assetPicker.assetPickerDelegate = self
|
DispatchQueue.main.async {
|
||||||
present(sheetContainer, animated: true)
|
if self.traitCollection.horizontalSizeClass == .compact {
|
||||||
} else {
|
let sheetContainer = AssetPickerSheetContainerViewController()
|
||||||
let picker = AssetPickerViewController()
|
sheetContainer.assetPicker.assetPickerDelegate = self
|
||||||
picker.assetPickerDelegate = self
|
self.present(sheetContainer, animated: true)
|
||||||
picker.overrideUserInterfaceStyle = .dark
|
} else {
|
||||||
picker.modalPresentationStyle = .popover
|
let picker = AssetPickerViewController()
|
||||||
present(picker, animated: true)
|
picker.assetPickerDelegate = self
|
||||||
if let presentationController = picker.presentationController as? UIPopoverPresentationController {
|
picker.overrideUserInterfaceStyle = .dark
|
||||||
presentationController.sourceView = tableView.cellForRow(at: IndexPath(row: 0, section: 1))
|
picker.modalPresentationStyle = .popover
|
||||||
|
self.present(picker, animated: true)
|
||||||
|
if let presentationController = picker.presentationController as? UIPopoverPresentationController {
|
||||||
|
presentationController.sourceView = self.tableView.cellForRow(at: IndexPath(row: 0, section: 1))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue