Use built-in sheet for asset picker on iOS 15

This commit is contained in:
Shadowfacts 2021-06-09 19:12:10 -04:00
parent 9417872790
commit 2499d25432
1 changed files with 19 additions and 0 deletions

View File

@ -245,6 +245,25 @@ extension ComposeHostingController: ComposeUIStateDelegate {
} }
func presentAssetPickerSheet() { 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() let sheetContainer = AssetPickerSheetContainerViewController()
sheetContainer.assetPicker.assetPickerDelegate = self sheetContainer.assetPicker.assetPickerDelegate = self
self.present(sheetContainer, animated: true) self.present(sheetContainer, animated: true)