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

Commit

Permalink
Upgraded to Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Tulleb committed Oct 12, 2019
1 parent a9393ed commit 05d896f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions ALCameraViewController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
FAF0583E1B31618D008E5592 = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = 9E43V6CC9L;
LastSwiftMigration = 0900;
LastSwiftMigration = 1110;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -556,7 +556,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -572,7 +572,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Utilities/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal func errorWithKey(_ key: String, domain: String) -> NSError {
return error
}

internal func normalizedRect(_ rect: CGRect, orientation: UIImageOrientation) -> CGRect {
internal func normalizedRect(_ rect: CGRect, orientation: UIImage.Orientation) -> CGRect {
let normalizedX = rect.origin.x
let normalizedY = rect.origin.y

Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Utilities/VolumeControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class VolumeControl {
init(view: UIView, onVolumeChange: VolumeChangeAction?) {
self.onVolumeChange = onVolumeChange
view.addSubview(volumeView)
view.sendSubview(toBack: volumeView)
view.sendSubviewToBack(volumeView)

try? AVAudioSession.sharedInstance().setActive(true)
NotificationCenter.default.addObserver(self, selector: #selector(volumeChanged), name: NSNotification.Name(rawValue: changeKey), object: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ open class CameraViewController: UIViewController {

var animationDuration: TimeInterval = 0.5
var animationSpring: CGFloat = 0.5
var rotateAnimation: UIViewAnimationOptions = .curveLinear
var rotateAnimation: UIView.AnimationOptions = .curveLinear

var cameraButtonEdgeConstraint: NSLayoutConstraint?
var cameraButtonGravityConstraint: NSLayoutConstraint?
Expand Down Expand Up @@ -349,7 +349,7 @@ open class CameraViewController: UIViewController {
NotificationCenter.default.addObserver(
self,
selector: #selector(rotateCameraView),
name: NSNotification.Name.UIDeviceOrientationDidChange,
name: UIDevice.orientationDidChangeNotification,
object: nil)
}

Expand Down Expand Up @@ -631,12 +631,12 @@ open class CameraViewController: UIViewController {

private func showSpinner() -> UIActivityIndicatorView {
let spinner = UIActivityIndicatorView()
spinner.activityIndicatorViewStyle = .white
spinner.style = .white
spinner.center = view.center
spinner.startAnimating()

view.addSubview(spinner)
view.bringSubview(toFront: spinner)
view.bringSubviewToFront(spinner)

return spinner
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension CameraViewController {
func configCameraButtonEdgeConstraint(_ statusBarOrientation: UIInterfaceOrientation) {
view.autoRemoveConstraint(cameraButtonEdgeConstraint)

let attribute : NSLayoutAttribute = {
let attribute : NSLayoutConstraint.Attribute = {
switch statusBarOrientation {
case .portrait: return .bottomMargin
case .landscapeRight: return .rightMargin
Expand Down Expand Up @@ -72,7 +72,7 @@ extension CameraViewController {
*/
func configCameraButtonGravityConstraint(_ portrait: Bool) {
view.autoRemoveConstraint(cameraButtonGravityConstraint)
let attribute : NSLayoutAttribute = portrait ? .centerX : .centerY
let attribute : NSLayoutConstraint.Attribute = portrait ? .centerX : .centerY
cameraButtonGravityConstraint = NSLayoutConstraint(
item: cameraButton,
attribute: attribute,
Expand Down Expand Up @@ -100,8 +100,8 @@ extension CameraViewController {
*/
func configContainerEdgeConstraint(_ statusBarOrientation : UIInterfaceOrientation) {

let attributeOne : NSLayoutAttribute
let attributeTwo : NSLayoutAttribute
let attributeOne : NSLayoutConstraint.Attribute
let attributeTwo : NSLayoutConstraint.Attribute

switch statusBarOrientation {
case .portrait:
Expand Down Expand Up @@ -149,7 +149,7 @@ extension CameraViewController {
* orientation of the device.
*/
func configContainerGravityConstraint(_ statusBarOrientation : UIInterfaceOrientation) {
let attributeCenter : NSLayoutAttribute = statusBarOrientation.isPortrait ? .centerY : .centerX
let attributeCenter : NSLayoutConstraint.Attribute = statusBarOrientation.isPortrait ? .centerY : .centerX
containerButtonsGravityConstraint = NSLayoutConstraint(
item: containerSwapLibraryButton,
attribute: attributeCenter,
Expand Down Expand Up @@ -179,8 +179,8 @@ extension CameraViewController {
*/
func configSwapButtonEdgeConstraint(_ statusBarOrientation : UIInterfaceOrientation) {

let attributeOne : NSLayoutAttribute
let attributeTwo : NSLayoutAttribute
let attributeOne : NSLayoutConstraint.Attribute
let attributeTwo : NSLayoutConstraint.Attribute

switch statusBarOrientation {
case .portrait:
Expand Down Expand Up @@ -249,7 +249,7 @@ extension CameraViewController {
*/
func configCloseButtonEdgeConstraint(_ statusBarOrientation : UIInterfaceOrientation) {

let attribute : NSLayoutAttribute = {
let attribute : NSLayoutConstraint.Attribute = {
switch statusBarOrientation {
case .portrait: return .left
case .landscapeRight, .landscapeLeft: return .centerX
Expand Down Expand Up @@ -278,7 +278,7 @@ extension CameraViewController {
*/
func configCloseButtonGravityConstraint(_ statusBarOrientation : UIInterfaceOrientation) {

let attribute : NSLayoutAttribute
let attribute : NSLayoutConstraint.Attribute
let constant : CGFloat

switch statusBarOrientation {
Expand Down Expand Up @@ -331,8 +331,8 @@ extension CameraViewController {
*/
func configLibraryEdgeButtonConstraint(_ statusBarOrientation : UIInterfaceOrientation) {

let attributeOne : NSLayoutAttribute
let attributeTwo : NSLayoutAttribute
let attributeOne : NSLayoutConstraint.Attribute
let attributeTwo : NSLayoutConstraint.Attribute

switch statusBarOrientation {
case .portrait:
Expand Down Expand Up @@ -401,7 +401,7 @@ extension CameraViewController {
view.autoRemoveConstraint(flashButtonEdgeConstraint)

let constraintRight = statusBarOrientation == .portrait || statusBarOrientation == .landscapeRight
let attribute : NSLayoutAttribute = constraintRight ? .topMargin : .bottomMargin
let attribute : NSLayoutConstraint.Attribute = constraintRight ? .topMargin : .bottomMargin

flashButtonEdgeConstraint = NSLayoutConstraint(
item: flashButton,
Expand All @@ -425,7 +425,7 @@ extension CameraViewController {
view.autoRemoveConstraint(flashButtonGravityConstraint)

let constraintRight = statusBarOrientation == .portrait || statusBarOrientation == .landscapeLeft
let attribute : NSLayoutAttribute = constraintRight ? .right : .left
let attribute : NSLayoutConstraint.Attribute = constraintRight ? .right : .left

flashButtonGravityConstraint = NSLayoutConstraint(
item: flashButton,
Expand Down Expand Up @@ -466,7 +466,7 @@ extension CameraViewController {
*/
func configCameraOverlayCenterConstraint(_ portrait: Bool) {
view.autoRemoveConstraint(cameraOverlayCenterConstraint)
let attribute : NSLayoutAttribute = portrait ? .centerY : .centerX
let attribute : NSLayoutConstraint.Attribute = portrait ? .centerY : .centerX
cameraOverlayCenterConstraint = NSLayoutConstraint(
item: cameraOverlay,
attribute: attribute,
Expand Down Expand Up @@ -494,7 +494,7 @@ extension CameraViewController {
the view will be pinned.
*/
func configCameraOverlayEdgeOneContraint(_ portrait: Bool, padding: CGFloat) {
let attribute : NSLayoutAttribute = portrait ? .left : .bottom
let attribute : NSLayoutConstraint.Attribute = portrait ? .left : .bottom
cameraOverlayEdgeOneConstraint = NSLayoutConstraint(
item: cameraOverlay,
attribute: attribute,
Expand All @@ -513,7 +513,7 @@ extension CameraViewController {
the view will be pinned.
*/
func configCameraOverlayEdgeTwoConstraint(_ portrait: Bool, padding: CGFloat) {
let attributeTwo : NSLayoutAttribute = portrait ? .right : .top
let attributeTwo : NSLayoutConstraint.Attribute = portrait ? .right : .top
cameraOverlayEdgeTwoConstraint = NSLayoutConstraint(
item: cameraOverlay,
attribute: attributeTwo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate {

func showSpinner() -> UIActivityIndicatorView {
let spinner = UIActivityIndicatorView()
spinner.activityIndicatorViewStyle = .white
spinner.style = .white
spinner.center = view.center
spinner.startAnimating()

view.addSubview(spinner)
view.bringSubview(toFront: spinner)
view.bringSubviewToFront(spinner)

return spinner
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public class PhotoLibraryViewController: UIViewController {

setNeedsStatusBarAppearanceUpdate()

let buttonImage = UIImage(named: "libraryCancel", in: CameraGlobals.shared.bundle, compatibleWith: nil)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
let buttonImage = UIImage(named: "libraryCancel", in: CameraGlobals.shared.bundle, compatibleWith: nil)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)

navigationItem.leftBarButtonItem = UIBarButtonItem(image: buttonImage,
style: UIBarButtonItemStyle.plain,
style: UIBarButtonItem.Style.plain,
target: self,
action: #selector(dismissLibrary))

Expand Down
4 changes: 2 additions & 2 deletions ALCameraViewController/Views/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public class CameraView: UIView {
focusView.alpha = 0
focusView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)

bringSubview(toFront: focusView)
bringSubviewToFront(focusView)

UIView.animateKeyframes(withDuration: 1.5, delay: 0, options: UIViewKeyframeAnimationOptions(), animations: {
UIView.animateKeyframes(withDuration: 1.5, delay: 0, options: UIView.KeyframeAnimationOptions(), animations: {

UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.15, animations: { [weak self] in
self?.focusView.alpha = 1
Expand Down
12 changes: 6 additions & 6 deletions ALCameraViewController/Views/PermissionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class PermissionsView: UIView {
descriptionLabel.text = description

closeButton.action = completion
closeButton.setImage(UIImage(named: "retakeButton", in: CameraGlobals.shared.bundle, compatibleWith: nil), for: UIControlState())
closeButton.setImage(UIImage(named: "retakeButton", in: CameraGlobals.shared.bundle, compatibleWith: nil), for: UIControl.State())
closeButton.sizeToFit()

let size = view.frame.size
Expand Down Expand Up @@ -69,13 +69,13 @@ internal class PermissionsView: UIView {
let icon = UIImage(named: "permissionsIcon", in: CameraGlobals.shared.bundle, compatibleWith: nil)!
iconView.image = icon

settingsButton.contentEdgeInsets = UIEdgeInsetsMake(6, 12, 6, 12)
settingsButton.setTitle(localizedString("permissions.settings"), for: UIControlState())
settingsButton.setTitleColor(UIColor.white, for: UIControlState())
settingsButton.contentEdgeInsets = UIEdgeInsets.init(top: 6, left: 12, bottom: 6, right: 12)
settingsButton.setTitle(localizedString("permissions.settings"), for: UIControl.State())
settingsButton.setTitleColor(UIColor.white, for: UIControl.State())
settingsButton.layer.cornerRadius = 4
settingsButton.titleLabel?.font = UIFont(name: "AppleSDGothicNeo-Regular", size: 14)
settingsButton.backgroundColor = UIColor(red: 52.0/255.0, green: 183.0/255.0, blue: 250.0/255.0, alpha: 1)
settingsButton.addTarget(self, action: #selector(PermissionsView.openSettings), for: UIControlEvents.touchUpInside)
settingsButton.addTarget(self, action: #selector(PermissionsView.openSettings), for: UIControl.Event.touchUpInside)

addSubview(iconView)
addSubview(titleLabel)
Expand All @@ -84,7 +84,7 @@ internal class PermissionsView: UIView {
}

@objc func openSettings() {
if let appSettings = URL(string: UIApplicationOpenSettingsURLString) {
if let appSettings = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.openURL(appSettings)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let viewController = ViewController(nibName: "ViewController", bundle: Bundle.main)

window = UIWindow(frame: UIScreen.main.bounds)
Expand Down

0 comments on commit 05d896f

Please sign in to comment.