Skip to content

Commit 5d9c162

Browse files
committed
Fix galery boolean for swipe down dismiss
1 parent a147b22 commit 5d9c162

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/CodeScanner/ScannerViewController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212
@available(macCatalyst 14.0, *)
1313
extension CodeScannerView {
1414

15-
public class ScannerViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate {
15+
public class ScannerViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, AVCaptureMetadataOutputObjectsDelegate, UIAdaptivePresentationControllerDelegate {
1616
private let photoOutput = AVCapturePhotoOutput()
1717
private var isCapturing = false
1818
private var handler: ((UIImage) -> Void)?
@@ -46,6 +46,7 @@ extension CodeScannerView {
4646
isGalleryShowing = true
4747
let imagePicker = UIImagePickerController()
4848
imagePicker.delegate = self
49+
imagePicker.presentationController?.delegate = self
4950
present(imagePicker, animated: true, completion: nil)
5051
}
5152

@@ -86,6 +87,11 @@ extension CodeScannerView {
8687
dismiss(animated: true, completion: nil)
8788
}
8889

90+
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
91+
// Galery is no longer being presented
92+
isGalleryShowing = false
93+
}
94+
8995
#if targetEnvironment(simulator)
9096
override public func loadView() {
9197
view = UIView()

0 commit comments

Comments
 (0)