From 5d9c162e57faa96b0b915f2fd31888a9383f6d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Kocur?= Date: Tue, 25 Apr 2023 14:44:14 +0200 Subject: [PATCH] Fix galery boolean for swipe down dismiss --- Sources/CodeScanner/ScannerViewController.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/CodeScanner/ScannerViewController.swift b/Sources/CodeScanner/ScannerViewController.swift index d56798e..95520c8 100644 --- a/Sources/CodeScanner/ScannerViewController.swift +++ b/Sources/CodeScanner/ScannerViewController.swift @@ -12,7 +12,7 @@ import UIKit @available(macCatalyst 14.0, *) extension CodeScannerView { - public class ScannerViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate { + public class ScannerViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate, UIAdaptivePresentationControllerDelegate { private let photoOutput = AVCapturePhotoOutput() private var isCapturing = false private var handler: ((UIImage) -> Void)? @@ -46,6 +46,7 @@ extension CodeScannerView { isGalleryShowing = true let imagePicker = UIImagePickerController() imagePicker.delegate = self + imagePicker.presentationController?.delegate = self present(imagePicker, animated: true, completion: nil) } @@ -86,6 +87,11 @@ extension CodeScannerView { dismiss(animated: true, completion: nil) } + public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { + // Galery is no longer being presented + isGalleryShowing = false + } + #if targetEnvironment(simulator) override public func loadView() { view = UIView()