Browse Source

Merge pull request #1758 from deltachat/audio_recorder_ui

show audio recorder on half screen
cyBerta 2 years ago
parent
commit
cec1d0bebf
1 changed files with 16 additions and 1 deletions
  1. 16 1
      deltachat-ios/Helper/MediaPicker.swift

+ 16 - 1
deltachat-ios/Helper/MediaPicker.swift

@@ -45,6 +45,7 @@ class MediaPicker: NSObject, UINavigationControllerDelegate {
      }
      }
 
 
     private weak var navigationController: UINavigationController?
     private weak var navigationController: UINavigationController?
+    private var accountRecorderTransitionDelegate: PartialScreenModalTransitioningDelegate?
     weak var delegate: MediaPickerDelegate?
     weak var delegate: MediaPickerDelegate?
 
 
     init(navigationController: UINavigationController?) {
     init(navigationController: UINavigationController?) {
@@ -58,7 +59,20 @@ class MediaPicker: NSObject, UINavigationControllerDelegate {
         // audioRecorderController.maximumRecordDuration = 1200
         // audioRecorderController.maximumRecordDuration = 1200
         let audioRecorderNavController = UINavigationController(rootViewController: audioRecorderController)
         let audioRecorderNavController = UINavigationController(rootViewController: audioRecorderController)
 
 
-        navigationController?.present(audioRecorderNavController, animated: true, completion: nil)
+        if #available(iOS 15.0, *) {
+            if let sheet = audioRecorderNavController.sheetPresentationController {
+                sheet.detents = [.medium()]
+                sheet.preferredCornerRadius = 20
+            }
+        } else {
+            if let shownViewController = navigationController?.visibleViewController {
+                accountRecorderTransitionDelegate = PartialScreenModalTransitioningDelegate(from: shownViewController, to: audioRecorderNavController)
+                audioRecorderNavController.modalPresentationStyle = .custom
+                audioRecorderNavController.transitioningDelegate = accountRecorderTransitionDelegate
+            }
+        }
+
+        navigationController?.present(audioRecorderNavController, animated: true)
     }
     }
 
 
     func showPhotoVideoLibrary() {
     func showPhotoVideoLibrary() {
@@ -213,6 +227,7 @@ extension MediaPicker: AudioRecorderControllerDelegate {
 
 
     func didClose() {
     func didClose() {
         self.delegate?.onVoiceMessageRecorderClosed()
         self.delegate?.onVoiceMessageRecorderClosed()
+        accountRecorderTransitionDelegate = nil
     }
     }
 }
 }