Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Commit 6c2e7c9

Browse files
Merge branch 'dblackker-master' into develop
2 parents 547f058 + dfe9799 commit 6c2e7c9

File tree

10 files changed

+33
-31
lines changed

10 files changed

+33
-31
lines changed

ALCameraViewController.xcodeproj/project.pbxproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
TargetAttributes = {
277277
C4829FFA1CAEB16C00541D08 = {
278278
CreatedOnToolsVersion = 7.3;
279-
LastSwiftMigration = 0800;
279+
LastSwiftMigration = 0900;
280280
};
281281
FAF0583E1B31618D008E5592 = {
282282
CreatedOnToolsVersion = 6.3.2;
@@ -407,7 +407,8 @@
407407
PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController;
408408
PRODUCT_NAME = "$(TARGET_NAME)";
409409
SKIP_INSTALL = YES;
410-
SWIFT_VERSION = 3.0;
410+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
411+
SWIFT_VERSION = 4.0;
411412
VERSIONING_SYSTEM = "apple-generic";
412413
VERSION_INFO_PREFIX = "";
413414
};
@@ -430,7 +431,8 @@
430431
PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController;
431432
PRODUCT_NAME = "$(TARGET_NAME)";
432433
SKIP_INSTALL = YES;
433-
SWIFT_VERSION = 3.0;
434+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
435+
SWIFT_VERSION = 4.0;
434436
VERSIONING_SYSTEM = "apple-generic";
435437
VERSION_INFO_PREFIX = "";
436438
};

ALCameraViewController/Utilities/CameraGlobals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ public class CameraGlobals {
2020
public var bundle = Bundle(for: CameraViewController.self)
2121
public var stringsTable = "CameraView"
2222
public var photoLibraryThumbnailSize = CGSize(width: thumbnailDimension, height: thumbnailDimension)
23-
public var defaultCameraPosition = AVCaptureDevicePosition.back
23+
public var defaultCameraPosition = AVCaptureDevice.Position.back
2424
}

ALCameraViewController/Utilities/CameraShot.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import AVFoundation
1111

1212
public typealias CameraShotCompletion = (UIImage?) -> Void
1313

14-
public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevicePosition, cropSize: CGSize, completion: @escaping CameraShotCompletion) {
14+
public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevice.Position, cropSize: CGSize, completion: @escaping CameraShotCompletion) {
1515

16-
guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else {
16+
guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(with: AVMediaType.video) else {
1717
completion(nil)
1818
return
1919
}

ALCameraViewController/Utilities/UIButtonExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension UIButton {
4343
}
4444
}
4545

46-
func performAction() {
46+
@objc func performAction() {
4747
guard let action = action else {
4848
return
4949
}

ALCameraViewController/Utilities/Utilities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ internal func normalizedRect(_ rect: CGRect, orientation: UIImageOrientation) ->
9191
return normalizedRect
9292
}
9393

94-
internal func flashImage(_ mode: AVCaptureFlashMode) -> String {
94+
internal func flashImage(_ mode: AVCaptureDevice.FlashMode) -> String {
9595
let image: String
9696
switch mode {
9797
case .auto:

ALCameraViewController/ViewController/CameraViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ open class CameraViewController: UIViewController {
352352
object: nil)
353353
}
354354

355-
internal func notifyCameraReady() {
355+
@objc internal func notifyCameraReady() {
356356
cameraButton.isEnabled = true
357357
}
358358

@@ -391,7 +391,7 @@ open class CameraViewController: UIViewController {
391391
libraryButton].forEach({ $0.isEnabled = enabled })
392392
}
393393

394-
func rotateCameraView() {
394+
@objc func rotateCameraView() {
395395
cameraView.rotatePreview()
396396
}
397397

@@ -459,8 +459,8 @@ open class CameraViewController: UIViewController {
459459
* the user that it not allow the permissions.
460460
*/
461461
private func checkPermissions() {
462-
if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) != .authorized {
463-
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { granted in
462+
if AVCaptureDevice.authorizationStatus(for: AVMediaType.video) != .authorized {
463+
AVCaptureDevice.requestAccess(for: AVMediaType.video) { granted in
464464
DispatchQueue.main.async() { [weak self] in
465465
if !granted {
466466
self?.showNoPermissionsView()
@@ -498,7 +498,7 @@ open class CameraViewController: UIViewController {
498498
*/
499499
internal func capturePhoto() {
500500
guard let output = cameraView.imageOutput,
501-
let connection = output.connection(withMediaType: AVMediaTypeVideo) else {
501+
let connection = output.connection(with: AVMediaType.video) else {
502502
return
503503
}
504504

@@ -577,7 +577,7 @@ open class CameraViewController: UIViewController {
577577

578578
internal func swapCamera() {
579579
cameraView.swapCameraInput()
580-
flashButton.isHidden = cameraView.currentPosition == AVCaptureDevicePosition.front
580+
flashButton.isHidden = cameraView.currentPosition == AVCaptureDevice.Position.front
581581
}
582582

583583
internal func layoutCameraResult(uiImage: UIImage) {

ALCameraViewController/ViewController/PhotoLibraryViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class PhotoLibraryViewController: UIViewController {
7272
inViewController.present(navigationController, animated: animated, completion: nil)
7373
}
7474

75-
public func dismissLibrary() {
75+
@objc public func dismissLibrary() {
7676
onSelectionComplete?(nil)
7777
}
7878

ALCameraViewController/Views/CameraView.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class CameraView: UIView {
2525

2626
public func startSession() {
2727
session = AVCaptureSession()
28-
session.sessionPreset = AVCaptureSessionPresetPhoto
28+
session.sessionPreset = AVCaptureSession.Preset.photo
2929

3030
device = cameraWithPosition(position: currentPosition)
3131
if let device = device , device.hasFlash {
@@ -107,7 +107,7 @@ public class CameraView: UIView {
107107
addGestureRecognizer(pinchGesture)
108108
}
109109

110-
internal func focus(gesture: UITapGestureRecognizer) {
110+
@objc internal func focus(gesture: UITapGestureRecognizer) {
111111
let point = gesture.location(in: self)
112112

113113
guard focusCamera(toPoint: point) else {
@@ -141,7 +141,7 @@ public class CameraView: UIView {
141141
})
142142
}
143143

144-
internal func pinch(gesture: UIPinchGestureRecognizer) {
144+
@objc internal func pinch(gesture: UIPinchGestureRecognizer) {
145145
guard let device = device else { return }
146146

147147
// Return zoom value between the minimum and maximum zoom values
@@ -175,14 +175,14 @@ public class CameraView: UIView {
175175
private func createPreview() {
176176

177177
preview = AVCaptureVideoPreviewLayer(session: session)
178-
preview.videoGravity = AVLayerVideoGravityResizeAspectFill
178+
preview.videoGravity = AVLayerVideoGravity.resizeAspectFill
179179
preview.frame = bounds
180180

181181
layer.addSublayer(preview)
182182
}
183183

184-
private func cameraWithPosition(position: AVCaptureDevicePosition) -> AVCaptureDevice? {
185-
guard let devices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) as? [AVCaptureDevice] else {
184+
private func cameraWithPosition(position: AVCaptureDevice.Position) -> AVCaptureDevice? {
185+
guard let devices = AVCaptureDevice.devices(for: AVMediaType.video) as? [AVCaptureDevice] else {
186186
return nil
187187
}
188188
return devices.filter { $0.position == position }.first
@@ -218,7 +218,7 @@ public class CameraView: UIView {
218218
return false
219219
}
220220

221-
let focusPoint = preview.captureDevicePointOfInterest(for: toPoint)
221+
let focusPoint = preview.captureDevicePointConverted(fromLayerPoint: toPoint)
222222

223223
device.focusPointOfInterest = focusPoint
224224
device.focusMode = .continuousAutoFocus
@@ -258,11 +258,11 @@ public class CameraView: UIView {
258258
session.beginConfiguration()
259259
session.removeInput(currentInput)
260260

261-
if currentInput.device.position == AVCaptureDevicePosition.back {
262-
currentPosition = AVCaptureDevicePosition.front
261+
if currentInput.device.position == AVCaptureDevice.Position.back {
262+
currentPosition = AVCaptureDevice.Position.front
263263
device = cameraWithPosition(position: currentPosition)
264264
} else {
265-
currentPosition = AVCaptureDevicePosition.back
265+
currentPosition = AVCaptureDevice.Position.back
266266
device = cameraWithPosition(position: currentPosition)
267267
}
268268

@@ -283,16 +283,16 @@ public class CameraView: UIView {
283283
}
284284
switch UIApplication.shared.statusBarOrientation {
285285
case .portrait:
286-
preview?.connection.videoOrientation = AVCaptureVideoOrientation.portrait
286+
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.portrait
287287
break
288288
case .portraitUpsideDown:
289-
preview?.connection.videoOrientation = AVCaptureVideoOrientation.portraitUpsideDown
289+
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.portraitUpsideDown
290290
break
291291
case .landscapeRight:
292-
preview?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeRight
292+
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.landscapeRight
293293
break
294294
case .landscapeLeft:
295-
preview?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeLeft
295+
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.landscapeLeft
296296
break
297297
default: break
298298
}

ALCameraViewController/Views/CropOverlay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ internal class CropOverlay: UIView {
164164
return button
165165
}
166166

167-
func moveCropOverlay(gestureRecognizer: UIPanGestureRecognizer) {
167+
@objc func moveCropOverlay(gestureRecognizer: UIPanGestureRecognizer) {
168168
if isResizable, let button = gestureRecognizer.view as? UIButton {
169169
if gestureRecognizer.state == .began || gestureRecognizer.state == .changed {
170170
let translation = gestureRecognizer.translation(in: self)

ALCameraViewController/Views/PermissionsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ internal class PermissionsView: UIView {
8383
addSubview(settingsButton)
8484
}
8585

86-
func openSettings() {
86+
@objc func openSettings() {
8787
if let appSettings = URL(string: UIApplicationOpenSettingsURLString) {
8888
UIApplication.shared.openURL(appSettings)
8989
}

0 commit comments

Comments
 (0)