forked from kbs-fabfel/WeScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewCameraViewController.swift
54 lines (44 loc) · 1.55 KB
/
NewCameraViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// NewCameraViewController.swift
// WeScanSampleProject
//
// Created by Chawatvish Worrapoj on 7/1/2020
// Copyright © 2020 WeTransfer. All rights reserved.
//
import UIKit
import WeScan
final class NewCameraViewController: UIViewController {
@IBOutlet private weak var cameraView: UIView!
var controller: CameraScannerViewController!
override func viewDidLoad() {
super.viewDidLoad()
setupView()
}
private func setupView() {
controller = CameraScannerViewController()
controller.view.frame = cameraView.bounds
controller.willMove(toParent: self)
cameraView.addSubview(controller.view)
self.addChild(controller)
controller.didMove(toParent: self)
controller.delegate = self
}
@IBAction func flashTapped(_ sender: UIButton) {
controller.toggleFlash()
}
@IBAction func captureTapped(_ sender: UIButton) {
controller.capture()
}
}
extension NewCameraViewController: CameraScannerViewOutputDelegate {
func captureImageFailWithError(error: Error) {
print(error)
}
func captureImageSuccess(image: UIImage, withQuad quad: Quadrilateral?) {
guard let controller = self.storyboard?.instantiateViewController(withIdentifier: "NewEditImageView") as? EditImageViewController else { return }
controller.modalPresentationStyle = .fullScreen
controller.captureImage = image
controller.quad = quad
navigationController?.pushViewController(controller, animated: false)
}
}