Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: migration to swift 5 #445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Source/SlideMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct SlideMenuOptions {
public static var shadowOffset: CGSize = CGSize(width: 0,height: 0)
public static var panFromBezel: Bool = true
public static var animationDuration: CGFloat = 0.4
public static var animationOptions: UIViewAnimationOptions = []
public static var animationOptions: UIView.AnimationOptions = []
public static var rightViewWidth: CGFloat = 270.0
public static var rightBezelWidth: CGFloat? = 16.0
public static var rightPanFromBezel: Bool = true
Expand Down Expand Up @@ -128,7 +128,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
opacityframe.size.height = opacityframe.size.height - opacityOffset
opacityView = UIView(frame: opacityframe)
opacityView.backgroundColor = SlideMenuOptions.opacityViewBackgroundColor
opacityView.autoresizingMask = [UIViewAutoresizing.flexibleHeight, UIViewAutoresizing.flexibleWidth]
opacityView.autoresizingMask = [UIView.AutoresizingMask.flexibleHeight, UIView.AutoresizingMask.flexibleWidth]
opacityView.layer.opacity = 0.0
view.insertSubview(opacityView, at: 1)

Expand All @@ -141,7 +141,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
leftFrame.size.height = leftFrame.size.height - leftOffset
leftContainerView = UIView(frame: leftFrame)
leftContainerView.backgroundColor = UIColor.clear
leftContainerView.autoresizingMask = UIViewAutoresizing.flexibleHeight
leftContainerView.autoresizingMask = UIView.AutoresizingMask.flexibleHeight
view.insertSubview(leftContainerView, at: 2)
addLeftGestures()
}
Expand All @@ -155,7 +155,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
rightFrame.size.height = rightFrame.size.height - rightOffset
rightContainerView = UIView(frame: rightFrame)
rightContainerView.backgroundColor = UIColor.clear
rightContainerView.autoresizingMask = UIViewAutoresizing.flexibleHeight
rightContainerView.autoresizingMask = UIView.AutoresizingMask.flexibleHeight
view.insertSubview(rightContainerView, at: 3)
addRightGestures()
}
Expand Down Expand Up @@ -356,7 +356,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
static var startPointOfPan: CGPoint = CGPoint.zero
static var wasOpenAtStartOfPan: Bool = false
static var wasHiddenAtStartOfPan: Bool = false
static var lastState : UIGestureRecognizerState = .ended
static var lastState : UIGestureRecognizer.State = .ended
}

@objc func handleLeftPanGesture(_ panGesture: UIPanGestureRecognizer) {
Expand Down Expand Up @@ -436,7 +436,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
static var startPointOfPan: CGPoint = CGPoint.zero
static var wasOpenAtStartOfPan: Bool = false
static var wasHiddenAtStartOfPan: Bool = false
static var lastState : UIGestureRecognizerState = .ended
static var lastState : UIGestureRecognizer.State = .ended
}

@objc func handleRightPanGesture(_ panGesture: UIPanGestureRecognizer) {
Expand Down Expand Up @@ -900,7 +900,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
if SlideMenuOptions.hideStatusBar {
DispatchQueue.main.async(execute: {
if let window = UIApplication.shared.keyWindow {
window.windowLevel = UIWindowLevelStatusBar + 1
window.windowLevel = UIWindow.Level.statusBar + 1
}
})
}
Expand All @@ -910,7 +910,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
if SlideMenuOptions.hideStatusBar {
DispatchQueue.main.async(execute: {
if let window = UIApplication.shared.keyWindow {
window.windowLevel = UIWindowLevelNormal
window.windowLevel = UIWindow.Level.normal
}
})
}
Expand All @@ -920,10 +920,10 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
if let viewController = targetViewController {
viewController.view.frame = targetView.bounds

if (!childViewControllers.contains(viewController)) {
addChildViewController(viewController)
if (!children.contains(viewController)) {
addChild(viewController)
targetView.addSubview(viewController.view)
viewController.didMove(toParentViewController: self)
viewController.didMove(toParent: self)
}
}
}
Expand All @@ -932,9 +932,9 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
fileprivate func removeViewController(_ viewController: UIViewController?) {
if let _viewController = viewController {
_viewController.view.layer.removeAllAnimations()
_viewController.willMove(toParentViewController: nil)
_viewController.willMove(toParent: nil)
_viewController.view.removeFromSuperview()
_viewController.removeFromParentViewController()
_viewController.removeFromParent()
}
}

Expand Down Expand Up @@ -1042,12 +1042,12 @@ extension UIViewController {
}

public func addLeftBarButtonWithImage(_ buttonImage: UIImage) {
let leftButton: UIBarButtonItem = UIBarButtonItem(image: buttonImage, style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.toggleLeft))
let leftButton: UIBarButtonItem = UIBarButtonItem(image: buttonImage, style: UIBarButtonItem.Style.plain, target: self, action: #selector(self.toggleLeft))
navigationItem.leftBarButtonItem = leftButton
}

public func addRightBarButtonWithImage(_ buttonImage: UIImage) {
let rightButton: UIBarButtonItem = UIBarButtonItem(image: buttonImage, style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.toggleRight))
let rightButton: UIBarButtonItem = UIBarButtonItem(image: buttonImage, style: UIBarButtonItem.Style.plain, target: self, action: #selector(self.toggleRight))
navigationItem.rightBarButtonItem = rightButton
}

Expand Down