Skip to content

Commit

Permalink
Fix galery boolean for swipe down dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
kafejo committed Apr 25, 2023
1 parent a147b22 commit 5d9c162
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/CodeScanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
Expand Down Expand Up @@ -46,6 +46,7 @@ extension CodeScannerView {
isGalleryShowing = true
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.presentationController?.delegate = self
present(imagePicker, animated: true, completion: nil)
}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5d9c162

Please sign in to comment.