From 2499d25432059577a878bdded0545baaaed5506e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 9 Jun 2021 19:12:10 -0400 Subject: [PATCH] Use built-in sheet for asset picker on iOS 15 --- .../Compose/ComposeHostingController.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tusker/Screens/Compose/ComposeHostingController.swift b/Tusker/Screens/Compose/ComposeHostingController.swift index 824b491ba9..4b675ae770 100644 --- a/Tusker/Screens/Compose/ComposeHostingController.swift +++ b/Tusker/Screens/Compose/ComposeHostingController.swift @@ -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)