Skip to content

Commit

Permalink
Merge pull request #106 from kafejo/main
Browse files Browse the repository at this point in the history
Fix galery boolean for swipe down dismiss
  • Loading branch information
nathanfallet committed May 8, 2023
2 parents 5b2c9b0 + 5d9c162 commit 4b2f9c5
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 @@ -92,6 +93,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 4b2f9c5

Please sign in to comment.