Skip to content

Commit 4b2f9c5

Browse files
authored
Merge pull request #106 from kafejo/main
Fix galery boolean for swipe down dismiss
2 parents 5b2c9b0 + 5d9c162 commit 4b2f9c5

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

@@ -92,6 +93,11 @@ extension CodeScannerView {
9293
dismiss(animated: true, completion: nil)
9394
}
9495

96+
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
97+
// Galery is no longer being presented
98+
isGalleryShowing = false
99+
}
100+
95101
#if targetEnvironment(simulator)
96102
override public func loadView() {
97103
view = UIView()

0 commit comments

Comments
 (0)