فهرست منبع

camera authorization

nayooti 5 سال پیش
والد
کامیت
c8789aedc6
1فایلهای تغییر یافته به همراه19 افزوده شده و 2 حذف شده
  1. 19 2
      deltachat-ios/Controller/QrCodeReaderController.swift

+ 19 - 2
deltachat-ios/Controller/QrCodeReaderController.swift

@@ -13,6 +13,13 @@ class QrCodeReaderController: UIViewController {
         return videoPreviewLayer
     }()
 
+    private lazy var cameraAccessButton: UIButton = {
+        let button = UIButton()
+        button.setTitle("Settings", for: .normal)
+        button.addTarget(self, action: #selector(cameraAccessButtonPressed(_:)), for: .touchUpInside)
+        return button
+    }()
+
     private var infoLabel: UILabel = {
         let label = UILabel()
            label.translatesAutoresizingMaskIntoConstraints = false
@@ -61,10 +68,10 @@ class QrCodeReaderController: UIViewController {
     }
 
     override func viewWillAppear(_ animated: Bool) {
-        captureSession.startRunning()
+        
     }
 
-  override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         super.viewWillTransition(to: size, with: coordinator)
 
         coordinator.animate(alongsideTransition: nil, completion: { [weak self] _ in
@@ -90,6 +97,12 @@ class QrCodeReaderController: UIViewController {
         view.bringSubviewToFront(infoLabel)
     }
 
+    private func handleCameraAutorizationState() {
+        if AVCaptureDevice.authorizationStatus(for: AVMediaType.video) == .authorized {
+            captureSession.startRunning()
+        }
+    }
+
     private func updateVideoOrientation() {
 
         guard let connection = videoPreviewLayer.connection else {
@@ -121,6 +134,10 @@ class QrCodeReaderController: UIViewController {
     func stopSession() {
         captureSession.stopRunning()
     }
+
+    @objc private func cameraAccessButtonPressed(_ sender: UIButton) {
+        print("Camera button pressed")
+    }
 }
 
 extension QrCodeReaderController: AVCaptureMetadataOutputObjectsDelegate {