Skip to content

Commit

Permalink
- swift 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
prscms committed Oct 3, 2019
1 parent 1235678 commit 4924e9e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Photo Editor/Photo Editor/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
setupEditingRect()

if imageView == nil {
if UIInterfaceOrientationIsPortrait(interfaceOrientation) {
if interfaceOrientation.isPortrait {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginTop)
} else {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginLeft)
Expand All @@ -198,7 +198,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
setupZoomingView()
setupImageView()
} else if usingCustomImageView {
if UIInterfaceOrientationIsPortrait(interfaceOrientation) {
if interfaceOrientation.isPortrait {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginTop)
} else {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginLeft)
Expand Down Expand Up @@ -257,7 +257,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
let cropRect = convert(scrollView.frame, to: zoomingView)
var ratio: CGFloat = 1.0
let orientation = UIApplication.shared.statusBarOrientation
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad || UIInterfaceOrientationIsPortrait(orientation)) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad || orientation.isPortrait) {
ratio = AVMakeRect(aspectRatio: imageSize, insideRect: insetRect).width / imageSize.width
} else {
ratio = AVMakeRect(aspectRatio: imageSize, insideRect: insetRect).height / imageSize.height
Expand Down Expand Up @@ -304,7 +304,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,

fileprivate func setupEditingRect() {
let interfaceOrientation = UIApplication.shared.statusBarOrientation
if UIInterfaceOrientationIsPortrait(interfaceOrientation) {
if interfaceOrientation.isPortrait {
editingRect = bounds.insetBy(dx: MarginLeft, dy: MarginTop)
} else {
editingRect = bounds.insetBy(dx: MarginLeft, dy: MarginLeft)
Expand Down
4 changes: 2 additions & 2 deletions Photo Editor/Photo Editor/PhotoEditor+Controls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ extension PhotoEditorViewController {
//MAKR: helper methods

@objc func image(_ image: UIImage, withPotentialError error: NSErrorPointer, contextInfo: UnsafeRawPointer) {
let alert = UIAlertController(title: "Image Saved", message: "Image successfully saved to Photos library", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: "Image Saved", message: "Image successfully saved to Photos library", preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}

Expand Down
4 changes: 2 additions & 2 deletions Photo Editor/Photo Editor/PhotoEditor+Gestures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
Scale Effect
*/
func scaleEffect(view: UIView) {
view.superview?.bringSubview(toFront: view)
view.superview?.bringSubviewToFront(view)

if #available(iOS 10.0, *) {
let generator = UIImpactFeedbackGenerator(style: .heavy)
Expand Down Expand Up @@ -166,7 +166,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
hideToolbar(hide: true)
deleteView.isHidden = false

view.superview?.bringSubview(toFront: view)
view.superview?.bringSubviewToFront(view)
let pointToSuperView = recognizer.location(in: self.view)

view.center = CGPoint(x: view.center.x + recognizer.translation(in: canvasImageView).x,
Expand Down
10 changes: 5 additions & 5 deletions Photo Editor/Photo Editor/PhotoEditor+Keyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ extension PhotoEditorViewController {

@objc func keyboardWillChangeFrame(_ notification: NSNotification) {
if let userInfo = notification.userInfo {
let endFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
let duration:TimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0
let animationCurveRawNSN = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIViewAnimationOptions.curveEaseInOut.rawValue
let animationCurve:UIViewAnimationOptions = UIViewAnimationOptions(rawValue: animationCurveRaw)
let endFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
let duration:TimeInterval = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0
let animationCurveRawNSN = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIView.AnimationOptions.curveEaseInOut.rawValue
let animationCurve:UIView.AnimationOptions = UIView.AnimationOptions(rawValue: animationCurveRaw)
if (endFrame?.origin.y)! >= UIScreen.main.bounds.size.height {
self.colorPickerViewBottomConstraint?.constant = 0.0
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ extension PhotoEditorViewController {
for image in self.stickers {
stickersViewController.stickers.append(image)
}
self.addChildViewController(stickersViewController)
self.addChild(stickersViewController)
self.view.addSubview(stickersViewController.view)
stickersViewController.didMove(toParentViewController: self)
stickersViewController.didMove(toParent: self)
let height = view.frame.height
let width = view.frame.width
stickersViewController.view.frame = CGRect(x: 0, y: self.view.frame.maxY , width: width, height: height)
Expand All @@ -33,15 +33,15 @@ extension PhotoEditorViewController {
self.canvasImageView.isUserInteractionEnabled = true
UIView.animate(withDuration: 0.3,
delay: 0,
options: UIViewAnimationOptions.curveEaseIn,
options: UIView.AnimationOptions.curveEaseIn,
animations: { () -> Void in
var frame = self.stickersViewController.view.frame
frame.origin.y = UIScreen.main.bounds.maxY
self.stickersViewController.view.frame = frame

}, completion: { (finished) -> Void in
self.stickersViewController.view.removeFromSuperview()
self.stickersViewController.removeFromParentViewController()
self.stickersViewController.removeFromParent()
self.hideToolbar(hide: false)
})
}
Expand Down
2 changes: 1 addition & 1 deletion Photo Editor/Photo Editor/PhotoEditor+UITextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension PhotoEditorViewController: UITextViewDelegate {
lastTextViewTransCenter = textView.center
lastTextViewFont = textView.font!
activeTextView = textView
textView.superview?.bringSubview(toFront: textView)
textView.superview?.bringSubviewToFront(textView)
textView.font = UIFont(name: "Helvetica", size: 30)
UIView.animate(withDuration: 0.3,
animations: {
Expand Down
6 changes: 3 additions & 3 deletions Photo Editor/Photo Editor/PhotoEditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public final class PhotoEditorViewController: UIViewController {
self.view.addGestureRecognizer(edgePan)

NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow),
name: .UIKeyboardDidShow, object: nil)
name: UIResponder.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide),
name: .UIKeyboardWillHide, object: nil)
name: UIResponder.keyboardWillHideNotification, object: nil)
NotificationCenter.default.addObserver(self,selector: #selector(keyboardWillChangeFrame(_:)),
name: .UIKeyboardWillChangeFrame, object: nil)
name: UIResponder.keyboardWillChangeFrameNotification, object: nil)


configureCollectionView()
Expand Down
4 changes: 2 additions & 2 deletions Photo Editor/Photo Editor/StickersViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ class StickersViewController: UIViewController, UIGestureRecognizerDelegate {
func removeBottomSheetView() {
UIView.animate(withDuration: 0.3,
delay: 0,
options: UIViewAnimationOptions.curveEaseIn,
options: UIView.AnimationOptions.curveEaseIn,
animations: { () -> Void in
var frame = self.view.frame
frame.origin.y = UIScreen.main.bounds.maxY
self.view.frame = frame

}, completion: { (finished) -> Void in
self.view.removeFromSuperview()
self.removeFromParentViewController()
self.removeFromParent()
self.stickersViewControllerDelegate?.stickersViewDidDisappear()
})
}
Expand Down

0 comments on commit 4924e9e

Please sign in to comment.