Skip to content

Commit

Permalink
Migrated to Swift 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyGo committed Apr 1, 2019
1 parent 2be2374 commit 28d95cd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
5 changes: 3 additions & 2 deletions DrawerController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = FAEF012C1AFEE4FF00DFDF7F;
Expand Down Expand Up @@ -278,7 +279,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -298,7 +299,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.evolved.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
4 changes: 2 additions & 2 deletions DrawerController/AnimatedMenuButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ open class AnimatedMenuButton : UIButton {
layer.strokeColor = self.strokeColor.cgColor
layer.lineWidth = 1
layer.miterLimit = 2
layer.lineCap = kCALineCapSquare
layer.lineCap = CAShapeLayerLineCap.square
layer.masksToBounds = true

if let path = layer.path, let strokingPath = CGPath(__byStroking: path, transform: nil, lineWidth: 1, lineCap: .square, lineJoin: .miter, miterLimit: 4) {
Expand Down Expand Up @@ -154,7 +154,7 @@ open class AnimatedMenuButton : UIButton {
let topTransform = CABasicAnimation(keyPath: "transform")
topTransform.timingFunction = CAMediaTimingFunction(controlPoints: 0.5, -0.8, 0.5, 1.85)
topTransform.duration = animationDuration
topTransform.fillMode = kCAFillModeBackwards
topTransform.fillMode = CAMediaTimingFillMode.backwards

let bottomTransform = topTransform.copy() as! CABasicAnimation

Expand Down
2 changes: 1 addition & 1 deletion DrawerController/DrawerBarButtonItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class DrawerBarButtonItem: UIBarButtonItem {
public convenience init(target: AnyObject?, action: Selector, menuIconColor: UIColor, animatable: Bool) {
let menuButton = AnimatedMenuButton(frame: CGRect(x: 0, y: 0, width: 26, height: 26), strokeColor: menuIconColor, animatable:animatable)
menuButton.animatable = animatable
menuButton.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
menuButton.addTarget(target, action: action, for: .touchUpInside)
self.init(customView: menuButton)

self.menuButton = menuButton
Expand Down
44 changes: 22 additions & 22 deletions DrawerController/DrawerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private func bounceKeyFrameAnimation(forDistance distance: CGFloat, on view: UIV
let animation = CAKeyframeAnimation(keyPath: "position.x")
animation.repeatCount = 1
animation.duration = 0.8
animation.fillMode = kCAFillModeForwards
animation.fillMode = CAMediaTimingFillMode.forwards
animation.values = values
animation.isRemovedOnCompletion = true
animation.autoreverses = false
Expand Down Expand Up @@ -543,11 +543,11 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {

// MARK: - UIViewController Containment

override open var childViewControllerForStatusBarHidden : UIViewController? {
override open var childForStatusBarHidden : UIViewController? {
return self.childViewController(for: self.openSide)
}

override open var childViewControllerForStatusBarStyle : UIViewController? {
override open var childForStatusBarStyle : UIViewController? {
return self.childViewController(for: self.openSide)
}

Expand Down Expand Up @@ -704,7 +704,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
}

if let sideDrawerViewControllerToHide = self.sideDrawerViewController(for: drawerToHide) {
self.childControllerContainerView.sendSubview(toBack: sideDrawerViewControllerToHide.view)
self.childControllerContainerView.sendSubviewToBack(sideDrawerViewControllerToHide.view)
sideDrawerViewControllerToHide.view.isHidden = true
}

Expand Down Expand Up @@ -844,11 +844,11 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
currentSideViewController!.beginAppearanceTransition(false, animated: false)
currentSideViewController!.view.removeFromSuperview()
currentSideViewController!.endAppearanceTransition()
currentSideViewController!.willMove(toParentViewController: nil)
currentSideViewController!.removeFromParentViewController()
currentSideViewController!.willMove(toParent: nil)
currentSideViewController!.removeFromParent()
}

var autoResizingMask = UIViewAutoresizing()
var autoResizingMask = UIView.AutoresizingMask()

if drawerSide == .left {
self._leftDrawerViewController = viewController
Expand All @@ -859,19 +859,19 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
}

if viewController != nil {
self.addChildViewController(viewController!)
self.addChild(viewController!)

if (self.openSide == drawerSide) && (self.childControllerContainerView.subviews as NSArray).contains(self.centerContainerView) {
self.childControllerContainerView.insertSubview(viewController!.view, belowSubview: self.centerContainerView)
viewController!.beginAppearanceTransition(true, animated: false)
viewController!.endAppearanceTransition()
} else {
self.childControllerContainerView.addSubview(viewController!.view)
self.childControllerContainerView.sendSubview(toBack: viewController!.view)
self.childControllerContainerView.sendSubviewToBack(viewController!.view)
viewController!.view.isHidden = true
}

viewController!.didMove(toParentViewController: self)
viewController!.didMove(toParent: self)
viewController!.view.autoresizingMask = autoResizingMask
viewController!.view.frame = viewController!.evo_visibleDrawerFrame
}
Expand All @@ -885,13 +885,13 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
}

if let oldCenterViewController = self._centerViewController {
oldCenterViewController.willMove(toParentViewController: nil)
oldCenterViewController.willMove(toParent: nil)

if animated == false {
oldCenterViewController.beginAppearanceTransition(false, animated: false)
}

oldCenterViewController.removeFromParentViewController()
oldCenterViewController.removeFromParent()
oldCenterViewController.view.removeFromSuperview()

if animated == false {
Expand All @@ -902,10 +902,10 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
self._centerViewController = centerViewController

if self._centerViewController != nil {
self.addChildViewController(self._centerViewController!)
self.addChild(self._centerViewController!)
self._centerViewController!.view.frame = self.childControllerContainerView.bounds
self.centerContainerView.addSubview(self._centerViewController!.view)
self.childControllerContainerView.bringSubview(toFront: self.centerContainerView)
self.childControllerContainerView.bringSubviewToFront(self.centerContainerView)
self._centerViewController!.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.updateShadowForCenterView()

Expand All @@ -916,7 +916,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
self._centerViewController!.endAppearanceTransition()
}

self._centerViewController!.didMove(toParentViewController: self)
self._centerViewController!.didMove(toParent: self)
}
}
}
Expand Down Expand Up @@ -952,7 +952,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
self.closeDrawer(animated: animated, completion: { (finished) in
if forwardAppearanceMethodsToCenterViewController {
self.centerViewController!.endAppearanceTransition()
self.centerViewController!.didMove(toParentViewController: self)
self.centerViewController!.didMove(toParent: self)
}

completion?(finished)
Expand Down Expand Up @@ -1022,7 +1022,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
}, completion: { (finished) -> Void in
if forwardAppearanceMethodsToCenterViewController {
self.centerViewController?.endAppearanceTransition()
self.centerViewController?.didMove(toParentViewController: self)
self.centerViewController?.didMove(toParent: self)
}

sideDrawerViewController?.endAppearanceTransition()
Expand Down Expand Up @@ -1108,7 +1108,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {

// MARK: - Gesture Handlers

func tapGestureCallback(_ tapGesture: UITapGestureRecognizer) {
@objc func tapGestureCallback(_ tapGesture: UITapGestureRecognizer) {
if self.openSide != .none && self.animatingDrawer == false {
self.closeDrawer(animated: true, completion: { (finished) in
if self.gestureCompletionBlock != nil {
Expand All @@ -1118,7 +1118,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
}
}

func panGestureCallback(_ panGesture: UIPanGestureRecognizer) {
@objc func panGestureCallback(_ panGesture: UIPanGestureRecognizer) {
switch panGesture.state {
case .began:
if self.animatingDrawer {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
self.openDrawerSide(drawerSide, animated: animated, velocity: self.animationVelocity, animationOptions: [], completion: completion)
}

fileprivate func openDrawerSide(_ drawerSide: DrawerSide, animated: Bool, velocity: CGFloat, animationOptions options: UIViewAnimationOptions, completion: ((Bool) -> Void)?) {
fileprivate func openDrawerSide(_ drawerSide: DrawerSide, animated: Bool, velocity: CGFloat, animationOptions options: UIView.AnimationOptions, completion: ((Bool) -> Void)?) {
assert({ () -> Bool in
return drawerSide != .none
}(), "drawerSide cannot be .None")
Expand Down Expand Up @@ -1293,7 +1293,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
self.closeDrawer(animated: animated, velocity: self.animationVelocity, animationOptions: [], completion: completion)
}

fileprivate func closeDrawer(animated: Bool, velocity: CGFloat, animationOptions options: UIViewAnimationOptions, completion: ((Bool) -> Void)?) {
fileprivate func closeDrawer(animated: Bool, velocity: CGFloat, animationOptions options: UIView.AnimationOptions, completion: ((Bool) -> Void)?) {
if self.animatingDrawer {
completion?(false)
} else {
Expand Down Expand Up @@ -1445,7 +1445,7 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
if oldShadowPath != nil {
let transition = CABasicAnimation(keyPath: "shadowPath")
transition.fromValue = oldShadowPath
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
transition.duration = context.transitionDuration
self.centerContainerView.layer.add(transition, forKey: "transition")
}
Expand Down

0 comments on commit 28d95cd

Please sign in to comment.