forked from shadowfacts/Tusker
Use built-in sheet for asset picker on iOS 15
This commit is contained in:
parent
9417872790
commit
2499d25432
|
@ -245,6 +245,25 @@ extension ComposeHostingController: ComposeUIStateDelegate {
|
|||
}
|
||||
|
||||
func presentAssetPickerSheet() {
|
||||
#if SDK_IOS_15
|
||||
if #available(iOS 15.0, *) {
|
||||
let picker = AssetPickerViewController()
|
||||
picker.assetPickerDelegate = self
|
||||
picker.modalPresentationStyle = .popover
|
||||
picker.overrideUserInterfaceStyle = .dark
|
||||
let sheet = picker.popoverPresentationController!.adaptiveSheetPresentationController
|
||||
sheet.detents = [.medium(), .large()]
|
||||
sheet.prefersEdgeAttachedInCompactHeight = true
|
||||
self.present(picker, animated: true)
|
||||
} else {
|
||||
presentOldAssetPickerSheet()
|
||||
}
|
||||
#else
|
||||
presentOldAssetPickerSheet()
|
||||
#endif
|
||||
}
|
||||
|
||||
private func presentOldAssetPickerSheet() {
|
||||
let sheetContainer = AssetPickerSheetContainerViewController()
|
||||
sheetContainer.assetPicker.assetPickerDelegate = self
|
||||
self.present(sheetContainer, animated: true)
|
||||
|
|
Loading…
Reference in New Issue