Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions SlideMenuControllerSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
PRODUCT_BUNDLE_IDENTIFIER = dekatotoro.SlideMenuControllerSwift;
PRODUCT_NAME = "$(PROJECT_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -512,7 +512,7 @@
PRODUCT_BUNDLE_IDENTIFIER = dekatotoro.SlideMenuControllerSwift;
PRODUCT_NAME = "$(PROJECT_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -628,7 +628,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "dekatotoro.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -643,7 +643,7 @@
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "dekatotoro.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
58 changes: 31 additions & 27 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 = [.flexibleHeight, .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 = .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 = .flexibleHeight
view.insertSubview(rightContainerView, at: 3)
addRightGestures()
}
Expand Down Expand Up @@ -218,6 +218,10 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
return self.mainViewController?.preferredStatusBarStyle ?? .default
}

open override var prefersStatusBarHidden: Bool {
return self.mainViewController?.prefersStatusBarHidden ?? super.prefersStatusBarHidden
}

open override func openLeft() {
guard let _ = leftViewController else { // If leftViewController is nil, then return
return
Expand Down Expand Up @@ -356,7 +360,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 All @@ -370,7 +374,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
}

switch panGesture.state {
case UIGestureRecognizerState.began:
case .began:
if LeftPanState.lastState != .ended && LeftPanState.lastState != .cancelled && LeftPanState.lastState != .failed {
return
}
Expand All @@ -389,7 +393,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
leftViewController?.beginAppearanceTransition(LeftPanState.wasHiddenAtStartOfPan, animated: true)
addShadowToView(leftContainerView)
setOpenWindowLevel()
case UIGestureRecognizerState.changed:
case .changed:
if LeftPanState.lastState != .began && LeftPanState.lastState != .changed {
return
}
Expand All @@ -398,7 +402,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
leftContainerView.frame = applyLeftTranslation(translation, toFrame: LeftPanState.frameAtStartOfPan)
applyLeftOpacity()
applyLeftContentViewScale()
case UIGestureRecognizerState.ended, UIGestureRecognizerState.cancelled:
case .ended, .cancelled:
if LeftPanState.lastState != .changed {
setCloseWindowLevel()
return
Expand All @@ -424,7 +428,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
track(.leftFlickClose)

}
case UIGestureRecognizerState.failed, UIGestureRecognizerState.possible:
case .failed, .possible:
break
}

Expand All @@ -436,7 +440,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 All @@ -450,7 +454,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
}

switch panGesture.state {
case UIGestureRecognizerState.began:
case .began:
if RightPanState.lastState != .ended && RightPanState.lastState != .cancelled && RightPanState.lastState != .failed {
return
}
Expand All @@ -470,7 +474,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {

addShadowToView(rightContainerView)
setOpenWindowLevel()
case UIGestureRecognizerState.changed:
case .changed:
if RightPanState.lastState != .began && RightPanState.lastState != .changed {
return
}
Expand All @@ -480,7 +484,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
applyRightOpacity()
applyRightContentViewScale()

case UIGestureRecognizerState.ended, UIGestureRecognizerState.cancelled:
case .ended, .cancelled:
if RightPanState.lastState != .changed {
setCloseWindowLevel()
return
Expand All @@ -505,7 +509,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {

track(.rightFlickClose)
}
case UIGestureRecognizerState.failed, UIGestureRecognizerState.possible:
case .failed, .possible:
break
}

Expand All @@ -521,7 +525,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {

var duration: TimeInterval = Double(SlideMenuOptions.animationDuration)
if velocity != 0.0 {
duration = Double(fabs(xOrigin - finalXOrigin) / velocity)
duration = Double(abs(xOrigin - finalXOrigin) / velocity)
duration = Double(fmax(0.1, fmin(1.0, duration)))
}

Expand Down Expand Up @@ -555,7 +559,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {

var duration: TimeInterval = Double(SlideMenuOptions.animationDuration)
if velocity != 0.0 {
duration = Double(fabs(xOrigin - view.bounds.width) / velocity)
duration = Double(abs(xOrigin - view.bounds.width) / velocity)
duration = Double(fmax(0.1, fmin(1.0, duration)))
}

Expand Down Expand Up @@ -587,7 +591,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {

var duration: TimeInterval = Double(SlideMenuOptions.animationDuration)
if velocity != 0.0 {
duration = Double(fabs(xOrigin - finalXOrigin) / velocity)
duration = Double(abs(xOrigin - finalXOrigin) / velocity)
duration = Double(fmax(0.1, fmin(1.0, duration)))
}

Expand Down Expand Up @@ -618,7 +622,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {

var duration: TimeInterval = Double(SlideMenuOptions.animationDuration)
if velocity != 0.0 {
duration = Double(fabs(xOrigin - view.bounds.width) / velocity)
duration = Double(abs(xOrigin - view.bounds.width) / velocity)
duration = Double(fmax(0.1, fmin(1.0, duration)))
}

Expand Down Expand Up @@ -900,7 +904,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 = .statusBar + 1
}
})
}
Expand All @@ -910,7 +914,7 @@ open class SlideMenuController: UIViewController, UIGestureRecognizerDelegate {
if SlideMenuOptions.hideStatusBar {
DispatchQueue.main.async(execute: {
if let window = UIApplication.shared.keyWindow {
window.windowLevel = UIWindowLevelNormal
window.windowLevel = .normal
}
})
}
Expand All @@ -920,10 +924,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 +936,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 +1046,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: .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: .plain, target: self, action: #selector(self.toggleRight))
navigationItem.rightBarButtonItem = rightButton
}

Expand Down