Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e8740a91e | |||
| b387ef2dd7 | |||
| 22596320a3 | |||
| 9363b747d1 | |||
| baae6186d7 | |||
| c5f80f954c | |||
| 493fa9a7a1 | |||
| 2de8d7f758 | |||
| 62a37e20d1 | |||
| 7a799b94a8 | |||
| 3a01ab6398 | |||
| 5e4ab5e254 | |||
| 70715d6fa0 | |||
| 411bd59493 | |||
| 5e295d36eb | |||
| 6aa68df4ce | |||
| 5c292125a6 | |||
| 48eb4a2e3a | |||
| 9503c814d6 | |||
| 4dd4f54a8e | |||
| 7429a42c26 | |||
| df032e6072 | |||
| 3a7c74e2e0 | |||
| 900926f268 | |||
| f5e585857c | |||
| 1d96ef80b3 | |||
| 452b354e19 | |||
| 78a3a66a69 | |||
| 8fe0a23a38 | |||
| 3a873661c3 | |||
| 89fc05a324 | |||
| 453e110246 | |||
| b39142bc1a | |||
| a6bd743e99 | |||
| 749588918c | |||
| f5b6615c72 | |||
| 8804675b80 | |||
| b0a09a5b7d | |||
| f1e4efeb46 | |||
| aea7592d85 | |||
| 87edaf1d32 | |||
| d14a8d66b3 | |||
| 36e8131965 | |||
| 58318a638d | |||
| 06ea874cc6 | |||
| fd8437b181 | |||
| 8c0d6b636f | |||
| 44d1de7d48 | |||
| 287434b008 | |||
| c0ec53608f | |||
| 54a9f3887d |
@@ -22,6 +22,7 @@ class MainViewController: UIViewController {
|
||||
super.viewDidLoad()
|
||||
setupSideMenu()
|
||||
updateUI(settings: SideMenuSettings())
|
||||
updateMenus()
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
@@ -43,7 +44,7 @@ class MainViewController: UIViewController {
|
||||
private func updateUI(settings: SideMenuSettings) {
|
||||
let styles:[UIBlurEffect.Style] = [.dark, .light, .extraLight]
|
||||
if let menuBlurEffectStyle = settings.blurEffectStyle {
|
||||
blurSegmentControl.selectedSegmentIndex = styles.firstIndex(of: menuBlurEffectStyle) ?? 0
|
||||
blurSegmentControl.selectedSegmentIndex = (styles.firstIndex(of: menuBlurEffectStyle) ?? 0) + 1
|
||||
} else {
|
||||
blurSegmentControl.selectedSegmentIndex = 0
|
||||
}
|
||||
@@ -53,7 +54,7 @@ class MainViewController: UIViewController {
|
||||
menuScaleFactorSlider.value = Float(settings.presentationStyle.menuScaleFactor)
|
||||
presentingAlphaSlider.value = Float(settings.presentationStyle.presentingEndAlpha)
|
||||
presentingScaleFactorSlider.value = Float(settings.presentationStyle.presentingScaleFactor)
|
||||
screenWidthSlider.value = Float(settings.menuWidth / view.frame.width)
|
||||
screenWidthSlider.value = Float(settings.menuWidth / min(view.frame.width, view.frame.height))
|
||||
shadowOpacitySlider.value = Float(settings.presentationStyle.onTopShadowOpacity)
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ class MainViewController: UIViewController {
|
||||
|
||||
var settings = SideMenuSettings()
|
||||
settings.presentationStyle = presentationStyle
|
||||
settings.menuWidth = view.frame.width * CGFloat(screenWidthSlider.value)
|
||||
settings.menuWidth = min(view.frame.width, view.frame.height) * CGFloat(screenWidthSlider.value)
|
||||
let styles:[UIBlurEffect.Style?] = [nil, .dark, .light, .extraLight]
|
||||
settings.blurEffectStyle = styles[blurSegmentControl.selectedSegmentIndex]
|
||||
settings.statusBarEndAlpha = blackOutStatusBar.isOn ? 1 : 0
|
||||
|
||||
@@ -27,7 +27,7 @@ extension SideMenuManager {
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
public var menuPushStyle: MenuPushStyle {
|
||||
public var menuPushStyle: SideMenuPushStyle {
|
||||
get { return .default }
|
||||
set {}
|
||||
}
|
||||
@@ -62,37 +62,37 @@ extension SideMenuManager {
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuAnimationFadeStrength: CGFloat {
|
||||
get { return 0 }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuAnimationTransformScaleFactor: CGFloat {
|
||||
get { return 1 }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuAnimationBackgroundColor: UIColor? {
|
||||
get { return nil }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuShadowOpacity: Float {
|
||||
get { return 0.5 }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuShadowColor: UIColor {
|
||||
get { return .black }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuShadowRadius: CGFloat {
|
||||
get { return 5 }
|
||||
set {}
|
||||
@@ -104,7 +104,7 @@ extension SideMenuManager {
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.")
|
||||
@available(*, deprecated, message: "This property has been moved to the SideMenuPresentationStyle class.")
|
||||
public var menuParallaxStrength: Int {
|
||||
get { return 0 }
|
||||
set {}
|
||||
@@ -182,7 +182,13 @@ extension SideMenuManager {
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "SideMenuPresentStyle")
|
||||
@available(*, deprecated, renamed: "enableSwipeToDismissGesture")
|
||||
public var enableSwipeGestures: Bool {
|
||||
get { return true }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "SideMenuPresentationStyle")
|
||||
public typealias MenuPresentMode = SideMenuPresentationStyle
|
||||
|
||||
@available(*, deprecated, renamed: "addScreenEdgePanGesturesToPresent")
|
||||
@@ -46,12 +46,25 @@ internal extension UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
// Indicates if the menu is anywhere in the view hierarchy, even if covered by another view controller.
|
||||
@objc var isHidden: Bool {
|
||||
return presentingViewController == nil
|
||||
}
|
||||
}
|
||||
|
||||
internal extension UIGestureRecognizer {
|
||||
|
||||
convenience init(addTo view: UIView, target: Any, action: Selector) {
|
||||
self.init()
|
||||
addTarget(target, action: action)
|
||||
view.addGestureRecognizer(self)
|
||||
}
|
||||
|
||||
convenience init?(addTo view: UIView?, target: Any, action: Selector) {
|
||||
guard let view = view else { return nil }
|
||||
self.init(addTo: view, target: target, action: action)
|
||||
}
|
||||
}
|
||||
|
||||
internal extension UIPanGestureRecognizer {
|
||||
|
||||
var canSwitch: Bool {
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
internal protocol InitializableClass: class {
|
||||
public protocol InitializableClass: class {
|
||||
init()
|
||||
}
|
||||
extension InitializableClass {
|
||||
|
||||
public extension InitializableClass {
|
||||
|
||||
init(_ block: (Self) -> Void) {
|
||||
self.init()
|
||||
@@ -23,10 +24,11 @@ extension InitializableClass {
|
||||
}
|
||||
}
|
||||
|
||||
internal protocol InitializableStruct {
|
||||
public protocol InitializableStruct {
|
||||
init()
|
||||
}
|
||||
internal extension InitializableStruct {
|
||||
|
||||
public extension InitializableStruct {
|
||||
init(_ block: (inout Self) -> Void) {
|
||||
self.init()
|
||||
block(&self)
|
||||
|
||||
@@ -28,8 +28,10 @@ internal protocol MenuModel: TransitionModel {
|
||||
var dismissOnRotation: Bool { get }
|
||||
/// Automatically dismisses the menu when app goes to the background.
|
||||
var dismissWhenBackgrounded: Bool { get }
|
||||
/// Enable or disable gestures that would swipe to dismiss the menu. Default is true.
|
||||
var enableSwipeGestures: Bool { get }
|
||||
/// Enable or disable a swipe gesture that dismisses the menu. Will not be triggered when `presentingViewControllerUserInteractionEnabled` is set to true. Default is true.
|
||||
var enableSwipeToDismissGesture: Bool { get }
|
||||
/// Enable or disable a tap gesture that dismisses the menu. Will not be triggered when `presentingViewControllerUserInteractionEnabled` is set to true. Default is true.
|
||||
var enableTapToDismissGesture: Bool { get }
|
||||
/**
|
||||
The push style of the menu.
|
||||
|
||||
|
||||
+13
-5
@@ -13,22 +13,30 @@ internal enum Print: String { case
|
||||
menuAlreadyAssigned = "%@ was already assigned to the %@ of %@. When using multiple SideMenuManagers you may want to use new instances of UISideMenuNavigationController instead of existing instances to avoid crashes if the menu is presented more than once.",
|
||||
menuInUse = "%@ cannot be modified while it's presented.",
|
||||
panGestureAdded = "%@ was called before %@ or %@ was set. Gestures will not work without a menu.",
|
||||
property = "a menu's %@ property can only be changed when it is hidden.",
|
||||
property = "A menu's %@ property can only be changed when it is hidden.",
|
||||
screenGestureAdded = "%@ was called before %@ was set. The gesture will not work without a menu. Use %@ to add gestures for only one menu.",
|
||||
transitioningDelegate = "SideMenu requires use of the transitioningDelegate. It cannot be modified."
|
||||
|
||||
internal static func warning(_ print: Print, arguments: CVarArg..., required: Bool = false) {
|
||||
warning(String(format: print.rawValue, arguments), required: required)
|
||||
enum PropertyName: String { case
|
||||
leftSide
|
||||
}
|
||||
|
||||
internal static func warning(_ print: Print, required: Bool = false) {
|
||||
static func warning(_ print: Print, arguments: CVarArg..., required: Bool = false) {
|
||||
warning(String(format: print.rawValue, arguments: arguments), required: required)
|
||||
}
|
||||
|
||||
static func warning(_ print: Print, arguments: PropertyName..., required: Bool = false) {
|
||||
warning(String(format: print.rawValue, arguments: arguments.map { $0.rawValue }), required: required)
|
||||
}
|
||||
|
||||
static func warning(_ print: Print, required: Bool = false) {
|
||||
warning(print.rawValue, required: required)
|
||||
}
|
||||
}
|
||||
|
||||
private extension Print {
|
||||
|
||||
private static func warning(_ message: String, required: Bool = false) {
|
||||
static func warning(_ message: String, required: Bool = false) {
|
||||
let message = "SideMenu Warning: \(message)"
|
||||
|
||||
if required {
|
||||
|
||||
@@ -9,32 +9,18 @@ import Foundation
|
||||
|
||||
internal final class Protected<T: Equatable> {
|
||||
|
||||
typealias ConditionBlock = (T) -> Bool
|
||||
typealias Block = (T) -> Void
|
||||
typealias ConditionBlock = (_ oldValue: T, T) -> T
|
||||
|
||||
private var _value: T
|
||||
private var conditionBlock: ConditionBlock
|
||||
private var thenBlock: Block?
|
||||
private var elseBlock: Block?
|
||||
private var condition: ConditionBlock
|
||||
|
||||
public var value: T {
|
||||
get {
|
||||
return _value
|
||||
}
|
||||
set {
|
||||
guard conditionBlock(_value) else {
|
||||
elseBlock?(_value)
|
||||
return
|
||||
}
|
||||
_value = newValue
|
||||
thenBlock?(_value)
|
||||
}
|
||||
get { return _value }
|
||||
set { _value = condition(_value, newValue) }
|
||||
}
|
||||
|
||||
init(_ value: T, if conditionBlock: @escaping ConditionBlock, then thenBlock: Block? = nil, else elseBlock: Block? = nil) {
|
||||
init(_ value: T, when condition: @escaping ConditionBlock) {
|
||||
self._value = value
|
||||
self.conditionBlock = conditionBlock
|
||||
self.thenBlock = thenBlock
|
||||
self.elseBlock = elseBlock
|
||||
self.condition = condition
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,21 +30,14 @@ public class SideMenuManager: NSObject {
|
||||
|
||||
var name: String {
|
||||
switch self {
|
||||
case .left: return "menuLeftNavigationController"
|
||||
case .right: return "menuRightNavigationController"
|
||||
case .left: return "leftMenuNavigationController"
|
||||
case .right: return "rightMenuNavigationController"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var _leftMenu: Protected<Menu?> =
|
||||
Protected(nil,
|
||||
if: { $0?.isHidden != false },
|
||||
else: { _ in Print.warning(.menuInUse, arguments: PresentDirection.left.name, required: true) } )
|
||||
|
||||
private var _rightMenu: Protected<Menu?> =
|
||||
Protected(nil,
|
||||
if: { $0?.isHidden != false },
|
||||
else: { _ in Print.warning(.menuInUse, arguments: PresentDirection.right.name, required: true) } )
|
||||
private var _leftMenu: Protected<Menu?> = Protected(nil) { SideMenuManager.setMenu(fromMenu: $0, toMenu: $1) }
|
||||
private var _rightMenu: Protected<Menu?> = Protected(nil) { SideMenuManager.setMenu(fromMenu: $0, toMenu: $1) }
|
||||
|
||||
private var switching: Bool = false
|
||||
|
||||
@@ -58,13 +51,23 @@ public class SideMenuManager: NSObject {
|
||||
|
||||
/// The left menu.
|
||||
open var leftMenuNavigationController: UISideMenuNavigationController? {
|
||||
get { return _leftMenu.value }
|
||||
get {
|
||||
if _leftMenu.value?.isHidden == true {
|
||||
_leftMenu.value?.leftSide = true
|
||||
}
|
||||
return _leftMenu.value
|
||||
}
|
||||
set(menu) { _leftMenu.value = menu }
|
||||
}
|
||||
|
||||
/// The right menu.
|
||||
open var rightMenuNavigationController: UISideMenuNavigationController? {
|
||||
get { return _rightMenu.value }
|
||||
get {
|
||||
if _rightMenu.value?.isHidden == true {
|
||||
_rightMenu.value?.leftSide = false
|
||||
}
|
||||
return _rightMenu.value
|
||||
}
|
||||
set(menu) { _rightMenu.value = menu }
|
||||
}
|
||||
|
||||
@@ -123,6 +126,14 @@ internal extension SideMenuManager {
|
||||
case false: rightMenuNavigationController = menu
|
||||
}
|
||||
}
|
||||
|
||||
private class func setMenu(fromMenu: Menu?, toMenu: Menu?) -> Menu? {
|
||||
if fromMenu?.isHidden == false {
|
||||
Print.warning(.menuInUse, arguments: PresentDirection.left.name, required: true)
|
||||
return fromMenu
|
||||
}
|
||||
return toMenu
|
||||
}
|
||||
}
|
||||
|
||||
private extension SideMenuManager {
|
||||
@@ -193,10 +204,8 @@ private extension SideMenuManager {
|
||||
screenEdgeGestureRecognizer.edges == edge {
|
||||
view.removeGestureRecognizer(screenEdgeGestureRecognizer)
|
||||
}
|
||||
return SideMenuScreenEdgeGestureRecognizer {
|
||||
return SideMenuScreenEdgeGestureRecognizer(addTo: view, target: self, action: #selector(handlePresentMenuScreenEdge(_:))).with {
|
||||
$0.edges = edge
|
||||
$0.addTarget(self, action: #selector(handlePresentMenuScreenEdge(_:)))
|
||||
view.addGestureRecognizer($0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,13 +213,10 @@ private extension SideMenuManager {
|
||||
if let panGestureRecognizer = view.gestureRecognizers?.first(where: { $0 is SideMenuPanGestureRecognizer }) as? SideMenuPanGestureRecognizer {
|
||||
return panGestureRecognizer
|
||||
}
|
||||
return SideMenuPanGestureRecognizer {
|
||||
$0.addTarget(self, action: #selector(handlePresentMenuPan(_:)))
|
||||
view.addGestureRecognizer($0)
|
||||
}
|
||||
return SideMenuPanGestureRecognizer(addTo: view, target: self, action: #selector(handlePresentMenuPan(_:)))
|
||||
}
|
||||
|
||||
private var activeViewController: UIViewController? {
|
||||
var activeViewController: UIViewController? {
|
||||
return UIApplication.shared.keyWindow?.rootViewController?.activeViewController
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +211,9 @@ private extension SideMenuPresentationController {
|
||||
if config.presentationStyle.menuOnTop {
|
||||
addShadow(to: presentedViewController.view)
|
||||
presentedViewController.view.layer.zPosition = 1
|
||||
presentingViewController.view.layer.zPosition = 0
|
||||
} else {
|
||||
addShadow(to: presentingViewController.view)
|
||||
presentingViewController.view.layer.zPosition = 1
|
||||
presentedViewController.view.layer.zPosition = 0
|
||||
presentedViewController.view.layer.zPosition = -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
public class SideMenuPresentationStyle {
|
||||
open class SideMenuPresentationStyle: InitializableClass {
|
||||
/// Background color behind the views and status bar color
|
||||
public var backgroundColor: UIColor = .black
|
||||
/// The starting alpha value of the menu before it appears
|
||||
@@ -36,12 +36,7 @@ public class SideMenuPresentationStyle {
|
||||
/// The strength of the parallax effect on the presenting view once the menu is displayed.
|
||||
public var presentingParallaxStrength: CGSize = .zero
|
||||
|
||||
public init() {}
|
||||
|
||||
public convenience init(_ block: (SideMenuPresentationStyle) -> Void) {
|
||||
self.init()
|
||||
block(self)
|
||||
}
|
||||
required public init() {}
|
||||
|
||||
/// This method is called just before the presentation transition begins. Use this to setup any animations. The super method does not need to be called.
|
||||
func presentationTransitionWillBegin(to presentedViewController: UIViewController, from presentingViewController: UIViewController) {}
|
||||
|
||||
@@ -27,7 +27,7 @@ internal protocol UISideMenuNavigationControllerTransitionDelegate: class {
|
||||
func sideMenuTransitionDidDismiss(menu: Menu)
|
||||
}
|
||||
|
||||
public struct SideMenuSettings: MenuModel {
|
||||
public struct SideMenuSettings: MenuModel, InitializableStruct {
|
||||
public var allowPushOfSameClassTwice: Bool = true
|
||||
public var alwaysAnimate: Bool = true
|
||||
public var animationOptions: UIView.AnimationOptions = .curveEaseInOut
|
||||
@@ -39,7 +39,8 @@ public struct SideMenuSettings: MenuModel {
|
||||
public var dismissOnPush: Bool = true
|
||||
public var dismissOnRotation: Bool = true
|
||||
public var dismissWhenBackgrounded: Bool = true
|
||||
public var enableSwipeGestures: Bool = true
|
||||
public var enableSwipeToDismissGesture: Bool = true
|
||||
public var enableTapToDismissGesture: Bool = true
|
||||
public var initialSpringVelocity: CGFloat = 1
|
||||
public var menuWidth: CGFloat = {
|
||||
let appScreenRect = UIApplication.shared.keyWindow?.bounds ?? UIWindow().bounds
|
||||
@@ -55,11 +56,6 @@ public struct SideMenuSettings: MenuModel {
|
||||
public var usingSpringWithDamping: CGFloat = 1
|
||||
|
||||
public init() {}
|
||||
|
||||
public init(_ block: (inout SideMenuSettings) -> Void) {
|
||||
self.init()
|
||||
block(&self)
|
||||
}
|
||||
}
|
||||
|
||||
internal typealias Menu = UISideMenuNavigationController
|
||||
@@ -67,16 +63,16 @@ internal typealias Menu = UISideMenuNavigationController
|
||||
@objcMembers
|
||||
open class UISideMenuNavigationController: UINavigationController {
|
||||
|
||||
private enum PropertyName: String { case
|
||||
leftSide
|
||||
private lazy var _leftSide = Protected(false) { [weak self] oldValue, newValue in
|
||||
guard self?.isHidden != false else {
|
||||
Print.warning(.property, arguments: .leftSide, required: true)
|
||||
return oldValue
|
||||
}
|
||||
return newValue
|
||||
}
|
||||
|
||||
private lazy var _leftSide = Protected(false,
|
||||
if: { [weak self] _ in self?.isHidden != false },
|
||||
else: { _ in Menu.elseCondition(.leftSide) } )
|
||||
|
||||
private weak var _sideMenuManager: SideMenuManager?
|
||||
private weak var foundDelegate: UISideMenuNavigationControllerDelegate?
|
||||
private weak var foundViewController: UIViewController?
|
||||
private weak var interactionController: SideMenuInteractionController?
|
||||
private var interactive: Bool = false
|
||||
private var originalBackgroundColor: UIColor?
|
||||
@@ -87,7 +83,9 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
internal weak var sideMenuDelegate: UISideMenuNavigationControllerDelegate?
|
||||
|
||||
/// The swipe to dismiss gesture.
|
||||
private(set) weak var swipeToDismissGesture: UIPanGestureRecognizer? = nil
|
||||
open private(set) weak var swipeToDismissGesture: UIPanGestureRecognizer? = nil
|
||||
/// The tap to dismiss gesture.
|
||||
open private(set) weak var tapToDismissGesture: UITapGestureRecognizer? = nil
|
||||
|
||||
open var sideMenuManager: SideMenuManager {
|
||||
get { return _sideMenuManager ?? SideMenuManager.default }
|
||||
@@ -106,22 +104,24 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
open var settings = SideMenuSettings() {
|
||||
didSet {
|
||||
setupBlur()
|
||||
setupSwipeGestures()
|
||||
if !enableSwipeToDismissGesture {
|
||||
removeSwipeGesture()
|
||||
}
|
||||
if !enableTapToDismissGesture {
|
||||
removeTapGesture()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
}
|
||||
|
||||
public convenience init(_ block: (UISideMenuNavigationController) -> Void) {
|
||||
self.init()
|
||||
block(self)
|
||||
setup()
|
||||
}
|
||||
|
||||
public init(rootViewController: UIViewController, settings: SideMenuSettings = SideMenuSettings()) {
|
||||
super.init(rootViewController: rootViewController)
|
||||
self.settings = settings
|
||||
setup()
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
@@ -144,7 +144,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
// Dismiss keyboard to prevent weird keyboard animations from occurring during transition
|
||||
presentingViewController?.view.endEditing(true)
|
||||
|
||||
foundDelegate = nil
|
||||
foundViewController = nil
|
||||
activeDelegate?.sideMenuWillAppear?(menu: self, animated: animated)
|
||||
}
|
||||
|
||||
@@ -165,24 +165,28 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
override open func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
|
||||
defer {
|
||||
activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}
|
||||
|
||||
guard !isBeingDismissed else { return }
|
||||
|
||||
// When presenting a view controller from the menu, the menu view gets moved into another transition view above our transition container
|
||||
// which can break the visual layout we had before. So, we move the menu view back to its original transition view to preserve it.
|
||||
if dismissOnPresent && !isBeingDismissed {
|
||||
// We're presenting a view controller from the menu, so we need to hide the menu so it isn't showing when the presented view is dismissed.
|
||||
if let presentingView = presentingViewController?.view, let containerView = presentingView.superview {
|
||||
containerView.addSubview(view)
|
||||
}
|
||||
if let presentingView = presentingViewController?.view, let containerView = presentingView.superview {
|
||||
containerView.addSubview(view)
|
||||
}
|
||||
|
||||
if dismissOnPresent {
|
||||
// We're presenting a view controller from the menu, so we need to hide the menu so it isn't showing when the presented view is dismissed.
|
||||
transitionController?.transition(presenting: false, animated: animated, alongsideTransition: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}, complete: false, completion: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
self.view.isHidden = true
|
||||
}, complete: false, completion: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
self.view.isHidden = true
|
||||
})
|
||||
} else {
|
||||
activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +197,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
// the view hierarchy leaving the screen black/empty. This is because the transition moves views within a container
|
||||
// view, but dismissing without animation removes the container view before the original hierarchy is restored.
|
||||
// This check corrects that.
|
||||
if presentedViewController == nil && view.window == nil {
|
||||
if let foundViewController = self.visibleViewController(from: presentingViewController), foundViewController.view.window == nil {
|
||||
transitionController?.transition(presenting: false, animated: false)
|
||||
}
|
||||
|
||||
@@ -207,10 +211,10 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
|
||||
activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
|
||||
if dismissOnPresent && !isBeingDismissed {
|
||||
view.isHidden = true
|
||||
} else {
|
||||
if isBeingDismissed {
|
||||
transitionController = nil
|
||||
} else if dismissOnPresent {
|
||||
view.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,15 +241,84 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
self.rotating = false
|
||||
}
|
||||
}
|
||||
|
||||
open override func viewWillLayoutSubviews() {
|
||||
super.viewWillLayoutSubviews()
|
||||
transitionController?.layout()
|
||||
}
|
||||
|
||||
override open func pushViewController(_ viewController: UIViewController, animated: Bool) {
|
||||
let push = shouldPushViewController(viewController: viewController, animated: animated) { [weak self] _ in
|
||||
self?.foundDelegate = nil
|
||||
guard viewControllers.count > 0 && pushStyle != .subMenu else {
|
||||
// NOTE: pushViewController is called by init(rootViewController: UIViewController)
|
||||
// so we must perform the normal super method in this case
|
||||
return super.pushViewController(viewController, animated: animated)
|
||||
}
|
||||
|
||||
if push {
|
||||
super.pushViewController(viewController, animated: animated)
|
||||
|
||||
let splitViewController = presentingViewController as? UISplitViewController
|
||||
let tabBarController = presentingViewController as? UITabBarController
|
||||
let potentialNavigationController = (splitViewController?.viewControllers.first ?? tabBarController?.selectedViewController) ?? presentingViewController
|
||||
guard let navigationController = potentialNavigationController as? UINavigationController else {
|
||||
return Print.warning(.cannotPush, arguments: String(describing: potentialNavigationController.self), required: true)
|
||||
}
|
||||
|
||||
// To avoid overlapping dismiss & pop/push calls, create a transaction block where the menu
|
||||
// is dismissed after showing the appropriate screen
|
||||
CATransaction.begin()
|
||||
defer { CATransaction.commit() }
|
||||
|
||||
if dismissOnPush {
|
||||
let animated = animated || alwaysAnimate
|
||||
if animated {
|
||||
let areAnimationsEnabled = UIView.areAnimationsEnabled
|
||||
UIView.setAnimationsEnabled(true)
|
||||
transitionController?.transition(presenting: false, animated: animated, alongsideTransition: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}, completion: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
self.dismiss(animated: false, completion: nil)
|
||||
self.foundViewController = nil
|
||||
})
|
||||
UIView.setAnimationsEnabled(areAnimationsEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
if let lastViewController = navigationController.viewControllers.last,
|
||||
!allowPushOfSameClassTwice && type(of: lastViewController) == type(of: viewController) {
|
||||
return
|
||||
}
|
||||
|
||||
switch pushStyle {
|
||||
case .subMenu: return // handled earlier
|
||||
case .default: break
|
||||
case .popWhenPossible:
|
||||
for subViewController in navigationController.viewControllers.reversed() {
|
||||
if type(of: subViewController) == type(of: viewController) {
|
||||
navigationController.popToViewController(subViewController, animated: animated)
|
||||
return
|
||||
}
|
||||
}
|
||||
case .preserve, .preserveAndHideBackButton:
|
||||
var viewControllers = navigationController.viewControllers
|
||||
let filtered = viewControllers.filter { preservedViewController in type(of: preservedViewController) == type(of: viewController) }
|
||||
if let preservedViewController = filtered.last {
|
||||
viewControllers = viewControllers.filter { subViewController in subViewController !== preservedViewController }
|
||||
if pushStyle == .preserveAndHideBackButton {
|
||||
preservedViewController.navigationItem.hidesBackButton = true
|
||||
}
|
||||
viewControllers.append(preservedViewController)
|
||||
return navigationController.setViewControllers(viewControllers, animated: animated)
|
||||
}
|
||||
if pushStyle == .preserveAndHideBackButton {
|
||||
viewController.navigationItem.hidesBackButton = true
|
||||
}
|
||||
case .replace:
|
||||
viewController.navigationItem.hidesBackButton = true
|
||||
return navigationController.setViewControllers([viewController], animated: animated)
|
||||
}
|
||||
|
||||
navigationController.pushViewController(viewController, animated: animated)
|
||||
}
|
||||
|
||||
override open var transitioningDelegate: UIViewControllerTransitioningDelegate? {
|
||||
@@ -312,9 +385,14 @@ extension UISideMenuNavigationController: MenuModel {
|
||||
set { settings.dismissWhenBackgrounded = newValue }
|
||||
}
|
||||
|
||||
@IBInspectable open var enableSwipeGestures: Bool {
|
||||
get { return settings.enableSwipeGestures }
|
||||
set { settings.enableSwipeGestures = newValue }
|
||||
@IBInspectable open var enableSwipeToDismissGesture: Bool {
|
||||
get { return settings.enableSwipeToDismissGesture }
|
||||
set { settings.enableSwipeToDismissGesture = newValue }
|
||||
}
|
||||
|
||||
@IBInspectable open var enableTapToDismissGesture: Bool {
|
||||
get { return settings.enableTapToDismissGesture }
|
||||
set { settings.enableTapToDismissGesture = newValue }
|
||||
}
|
||||
|
||||
@IBInspectable open var initialSpringVelocity: CGFloat {
|
||||
@@ -327,6 +405,11 @@ extension UISideMenuNavigationController: MenuModel {
|
||||
get { return _leftSide.value }
|
||||
set { _leftSide.value = newValue }
|
||||
}
|
||||
|
||||
/// Indicates if the menu is anywhere in the view hierarchy, even if covered by another view controller.
|
||||
open override var isHidden: Bool {
|
||||
return super.isHidden
|
||||
}
|
||||
|
||||
@IBInspectable open var menuWidth: CGFloat {
|
||||
get { return settings.menuWidth }
|
||||
@@ -392,7 +475,7 @@ extension UISideMenuNavigationController: UIViewControllerTransitioningDelegate
|
||||
return interactionController(using: animator)
|
||||
}
|
||||
|
||||
open func interactionController(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
|
||||
private func interactionController(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
|
||||
guard interactive else { return nil }
|
||||
let interactionController = SideMenuInteractionController(cancelWhenBackgrounded: dismissWhenBackgrounded, completionCurve: completionCurve)
|
||||
self.interactionController = interactionController
|
||||
@@ -403,21 +486,15 @@ extension UISideMenuNavigationController: UIViewControllerTransitioningDelegate
|
||||
extension UISideMenuNavigationController: SideMenuTransitionControllerDelegate {
|
||||
|
||||
internal func sideMenuTransitionController(_ transitionController: SideMenuTransitionController, didDismiss viewController: UIViewController) {
|
||||
interactive = false
|
||||
sideMenuManager.sideMenuTransitionDidDismiss(menu: self)
|
||||
}
|
||||
|
||||
internal func sideMenuTransitionController(_ transitionController: SideMenuTransitionController, didPresent viewController: UIViewController) {
|
||||
guard !presentingViewControllerUserInteractionEnabled else { return }
|
||||
|
||||
let panGesture = UIPanGestureRecognizer()
|
||||
panGesture.cancelsTouchesInView = false
|
||||
panGesture.addTarget(self, action: #selector(handleDismissMenuPan(_:)))
|
||||
view.superview?.addGestureRecognizer(panGesture)
|
||||
|
||||
let tapGestureRecognizer = UITapGestureRecognizer()
|
||||
tapGestureRecognizer.addTarget(self, action: #selector(handleDismissMenuTap(_:)))
|
||||
tapGestureRecognizer.cancelsTouchesInView = false
|
||||
view.superview?.addGestureRecognizer(tapGestureRecognizer)
|
||||
interactive = false
|
||||
removeSwipeGesture()
|
||||
swipeToDismissGesture = addSwipeToDismissGesture(to: view.superview)
|
||||
tapToDismissGesture = addTapToDismissGesture(to: view.superview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,118 +541,36 @@ internal extension UISideMenuNavigationController {
|
||||
|
||||
private extension UISideMenuNavigationController {
|
||||
|
||||
func shouldPushViewController(viewController: UIViewController, animated: Bool, completion: ((Bool) -> Void)?) -> Bool {
|
||||
guard viewControllers.count > 0 && pushStyle != .subMenu else {
|
||||
// NOTE: pushViewController is called by init(rootViewController: UIViewController)
|
||||
// so we must perform the normal super method in this case
|
||||
return true
|
||||
}
|
||||
|
||||
let splitViewController = presentingViewController as? UISplitViewController
|
||||
let tabBarController = presentingViewController as? UITabBarController
|
||||
let potentialNavigationController = (splitViewController?.viewControllers.first ?? tabBarController?.selectedViewController) ?? presentingViewController
|
||||
guard let navigationController = potentialNavigationController as? UINavigationController else {
|
||||
Print.warning(.cannotPush, arguments: String(describing: potentialNavigationController.self), required: true)
|
||||
return false
|
||||
}
|
||||
|
||||
// To avoid overlapping dismiss & pop/push calls, create a transaction block where the menu
|
||||
// is dismissed after showing the appropriate screen
|
||||
CATransaction.begin()
|
||||
defer { CATransaction.commit() }
|
||||
var push = false
|
||||
|
||||
if dismissOnPush {
|
||||
let animated = animated || alwaysAnimate
|
||||
if animated {
|
||||
let areAnimationsEnabled = UIView.areAnimationsEnabled
|
||||
UIView.setAnimationsEnabled(true)
|
||||
transitionController?.transition(presenting: false, animated: animated, alongsideTransition: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}, completion: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
self.dismiss(animated: false, completion: nil)
|
||||
completion?(push)
|
||||
})
|
||||
UIView.setAnimationsEnabled(areAnimationsEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
if let lastViewController = navigationController.viewControllers.last,
|
||||
!allowPushOfSameClassTwice && type(of: lastViewController) == type(of: viewController) {
|
||||
return false
|
||||
}
|
||||
|
||||
switch pushStyle {
|
||||
case .subMenu: return false // handled earlier
|
||||
case .default:
|
||||
navigationController.pushViewController(viewController, animated: animated)
|
||||
return false
|
||||
case .popWhenPossible:
|
||||
for subViewController in navigationController.viewControllers.reversed() {
|
||||
if type(of: subViewController) == type(of: viewController) {
|
||||
navigationController.popToViewController(subViewController, animated: animated)
|
||||
return false
|
||||
}
|
||||
}
|
||||
push = true
|
||||
return true
|
||||
case .preserve, .preserveAndHideBackButton:
|
||||
var viewControllers = navigationController.viewControllers
|
||||
let filtered = viewControllers.filter { preservedViewController in type(of: preservedViewController) == type(of: viewController) }
|
||||
if let preservedViewController = filtered.last {
|
||||
viewControllers = viewControllers.filter { subViewController in subViewController !== preservedViewController }
|
||||
if pushStyle == .preserveAndHideBackButton {
|
||||
preservedViewController.navigationItem.hidesBackButton = true
|
||||
}
|
||||
viewControllers.append(preservedViewController)
|
||||
navigationController.setViewControllers(viewControllers, animated: animated)
|
||||
return false
|
||||
}
|
||||
if pushStyle == .preserveAndHideBackButton {
|
||||
viewController.navigationItem.hidesBackButton = true
|
||||
}
|
||||
|
||||
push = true
|
||||
return true
|
||||
case .replace:
|
||||
viewController.navigationItem.hidesBackButton = true
|
||||
navigationController.setViewControllers([viewController], animated: animated)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private class func elseCondition(_ propertyName: PropertyName) {
|
||||
Print.warning(.property, arguments: propertyName.rawValue, required: true)
|
||||
}
|
||||
|
||||
weak var activeDelegate: UISideMenuNavigationControllerDelegate? {
|
||||
guard !view.isHidden else { return nil }
|
||||
return sideMenuDelegate ?? foundDelegate ?? findDelegate(forViewController: presentingViewController)
|
||||
if let sideMenuDelegate = sideMenuDelegate {
|
||||
return sideMenuDelegate
|
||||
}
|
||||
return visibleViewController(from: presentingViewController) as? UISideMenuNavigationControllerDelegate
|
||||
}
|
||||
|
||||
func findDelegate(forViewController: UIViewController?) -> UISideMenuNavigationControllerDelegate? {
|
||||
if let navigationController = forViewController as? UINavigationController {
|
||||
return findDelegate(forViewController: navigationController.topViewController)
|
||||
func visibleViewController(from: UIViewController?) -> UIViewController? {
|
||||
if let foundDelegate = foundViewController {
|
||||
return foundDelegate
|
||||
}
|
||||
if let tabBarController = forViewController as? UITabBarController {
|
||||
return findDelegate(forViewController: tabBarController.selectedViewController)
|
||||
if let navigationController = from as? UINavigationController {
|
||||
return visibleViewController(from: navigationController.topViewController)
|
||||
}
|
||||
if let splitViewController = forViewController as? UISplitViewController {
|
||||
return findDelegate(forViewController: splitViewController.viewControllers.last)
|
||||
if let tabBarController = from as? UITabBarController {
|
||||
return visibleViewController(from: tabBarController.selectedViewController)
|
||||
}
|
||||
if let splitViewController = from as? UISplitViewController {
|
||||
return visibleViewController(from: splitViewController.viewControllers.last)
|
||||
}
|
||||
|
||||
foundDelegate = forViewController as? UISideMenuNavigationControllerDelegate
|
||||
return foundDelegate
|
||||
foundViewController = from
|
||||
return from
|
||||
}
|
||||
|
||||
func setup() {
|
||||
modalPresentationStyle = .overFullScreen
|
||||
|
||||
setupBlur()
|
||||
setupSwipeGestures()
|
||||
registerForNotifications()
|
||||
}
|
||||
|
||||
@@ -622,12 +617,15 @@ private extension UISideMenuNavigationController {
|
||||
}
|
||||
}
|
||||
|
||||
func setupSwipeGestures() {
|
||||
func removeSwipeGesture() {
|
||||
if let swipeToDismissGesture = swipeToDismissGesture {
|
||||
swipeToDismissGesture.view?.removeGestureRecognizer(swipeToDismissGesture)
|
||||
}
|
||||
if enableSwipeGestures {
|
||||
swipeToDismissGesture = addDismissPanGesture(to: view)
|
||||
}
|
||||
|
||||
func removeTapGesture() {
|
||||
if let tapToDismissGesture = tapToDismissGesture {
|
||||
tapToDismissGesture.view?.removeGestureRecognizer(tapToDismissGesture)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,16 +655,23 @@ private extension UISideMenuNavigationController {
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult func addDismissPanGesture(to view: UIView) -> UIPanGestureRecognizer {
|
||||
return UIPanGestureRecognizer {
|
||||
@discardableResult func addSwipeToDismissGesture(to view: UIView?) -> UIPanGestureRecognizer? {
|
||||
guard enableSwipeToDismissGesture else { return nil }
|
||||
return UIPanGestureRecognizer(addTo: view, target: self, action: #selector(handleDismissMenuPan(_:)))?.with {
|
||||
$0.cancelsTouchesInView = false
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult func addTapToDismissGesture(to view: UIView?) -> UITapGestureRecognizer? {
|
||||
guard enableTapToDismissGesture else { return nil }
|
||||
return UITapGestureRecognizer(addTo: view, target: self, action: #selector(handleDismissMenuTap(_:)))?.with {
|
||||
$0.cancelsTouchesInView = false
|
||||
$0.addTarget(self, action: #selector(handleDismissMenuPan(_:)))
|
||||
view.addGestureRecognizer($0)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func handleDismissMenuTap(_ tap: UITapGestureRecognizer) {
|
||||
guard view.window?.hitTest(tap.location(in: nil), with: nil) == view.superview else { return }
|
||||
let hitTest = view.window?.hitTest(tap.location(in: view.superview), with: nil)
|
||||
guard hitTest == view.superview else { return }
|
||||
dismissMenu()
|
||||
}
|
||||
|
||||
|
||||
Generated
+14
@@ -17,6 +17,7 @@
|
||||
5B0A5C9933D0FCD08E12CFFB56145333 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; };
|
||||
614FC39555CB129D97FC24B2D953A427 /* SideMenuPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61AFB3209BCB97295281AC6437FB346B /* SideMenuPresentationController.swift */; };
|
||||
6E6E17C0E8351D23CB4B20332C70BE61 /* Print.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB39D726F07EA27650309A1A3213412 /* Print.swift */; };
|
||||
8428210422E0540800C6F2D8 /* Deprecations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8428210022E0448700C6F2D8 /* Deprecations.swift */; };
|
||||
89B2CFA98A07964FBD2D7775FF5FB98D /* Pods-Example-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = D6D7C498FA339E02BD53ECB8916CEA8E /* Pods-Example-dummy.m */; };
|
||||
A2ACFE2D997BC8F1DA4EE3064A4270DD /* SideMenuInteractionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB64592703EA9A196B5C0F07BA1A918A /* SideMenuInteractionController.swift */; };
|
||||
BD5C0C12B6BB0BF6DA294E095B35E38D /* Initializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00F847D27577EF5335081BFA43A0BFA3 /* Initializable.swift */; };
|
||||
@@ -57,6 +58,7 @@
|
||||
441854E35F81731E63E53DC7E4EEAD9D /* Pods-Example-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Example-acknowledgements.markdown"; sourceTree = "<group>"; };
|
||||
61AFB3209BCB97295281AC6437FB346B /* SideMenuPresentationController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SideMenuPresentationController.swift; path = Pod/Classes/SideMenuPresentationController.swift; sourceTree = "<group>"; };
|
||||
7825A90E082A1582EB16256B0E722B3F /* Pods-Example-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Example-umbrella.h"; sourceTree = "<group>"; };
|
||||
8428210022E0448700C6F2D8 /* Deprecations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Deprecations.swift; path = Pod/Classes/Deprecations.swift; sourceTree = "<group>"; };
|
||||
8F8B09C72B577EFDB20A3EFF4F0C668A /* UISideMenuNavigationController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = UISideMenuNavigationController.swift; path = Pod/Classes/UISideMenuNavigationController.swift; sourceTree = "<group>"; };
|
||||
9CF977D7FB42D367F2810037EBA59B7D /* SideMenu-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SideMenu-dummy.m"; sourceTree = "<group>"; };
|
||||
9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
|
||||
@@ -135,6 +137,7 @@
|
||||
children = (
|
||||
71A499AE33E397EBD7FA1A9D5B8440BA /* Pod */,
|
||||
B5D061624D54AFB703E72CCF860BDB15 /* Support Files */,
|
||||
8428210022E0448700C6F2D8 /* Deprecations.swift */,
|
||||
F1B25193EDCA447F119795F68F75BF05 /* Extensions.swift */,
|
||||
00F847D27577EF5335081BFA43A0BFA3 /* Initializable.swift */,
|
||||
B5F10B146FA49E99D07F0FA0E38ABE8F /* Models.swift */,
|
||||
@@ -276,6 +279,11 @@
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1100;
|
||||
LastUpgradeCheck = 1100;
|
||||
TargetAttributes = {
|
||||
0AEE99A309977BD12A049FF48AF9BA4B = {
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
@@ -317,6 +325,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8428210422E0540800C6F2D8 /* Deprecations.swift in Sources */,
|
||||
31E79D7BA42208D00E73C18CBAF1598E /* Extensions.swift in Sources */,
|
||||
BD5C0C12B6BB0BF6DA294E095B35E38D /* Initializable.swift in Sources */,
|
||||
0D2D410A6087D4E0A54642165913EF30 /* Models.swift in Sources */,
|
||||
@@ -454,6 +463,7 @@
|
||||
baseConfigurationReference = 243410B9535472556EA4BB6DBC133A0D /* Pods-Example.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = NO;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
|
||||
@@ -477,6 +487,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -548,6 +559,7 @@
|
||||
baseConfigurationReference = B45138496B85A072654D1D0F8EBBEDE5 /* Pods-Example.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = NO;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
|
||||
@@ -571,6 +583,8 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
|
||||
@@ -72,10 +72,10 @@ use_frameworks!
|
||||
pod 'SideMenu'
|
||||
|
||||
# For Swift 5 use:
|
||||
# pod 'SideMenu', '~> 6.0.0'
|
||||
# pod 'SideMenu', '~> 6.0'
|
||||
|
||||
# For Swift 4.2 (no longer maintained) use:
|
||||
# pod 'SideMenu', '~> 5.0.0'
|
||||
# pod 'SideMenu', '~> 5.0'
|
||||
```
|
||||
|
||||
Then, run the following command:
|
||||
@@ -137,11 +137,11 @@ dismiss(animated: true, completion: nil)
|
||||
To use gestures you have to use the `SideMenuManager`. In your `AppDelegate` do something like this:
|
||||
``` swift
|
||||
// Define the menus
|
||||
let menuLeftNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
|
||||
SideMenuManager.default.menuLeftNavigationController = menuLeftNavigationController
|
||||
let leftMenuNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
|
||||
SideMenuManager.default.leftMenuNavigationController = leftMenuNavigationController
|
||||
|
||||
let menuRightNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
|
||||
SideMenuManager.default.menuRightNavigationController = menuRightNavigationController
|
||||
let rightMenuNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
|
||||
SideMenuManager.default.rightMenuNavigationController = rightMenuNavigationController
|
||||
|
||||
// Setup gestures: the left and/or right menus must be set up (above) for these to work.
|
||||
// Note that these continue to work on the Navigation Controller independent of the view controller it displays!
|
||||
@@ -149,9 +149,9 @@ SideMenuManager.default.addPanGestureToPresent(toView: self.navigationController
|
||||
SideMenuManager.default.addScreenEdgePanGesturesToPresent(toView: self.navigationController!.view)
|
||||
|
||||
// (Optional) Prevent status bar area from turning black when menu appears:
|
||||
menuLeftNavigationController.statusBarEndAlpha = 0
|
||||
leftMenuNavigationController.statusBarEndAlpha = 0
|
||||
// Copy all settings to the other menu
|
||||
menuRightNavigationController.settings = menuLeftNavigationController.settings
|
||||
rightMenuNavigationController.settings = leftMenuNavigationController.settings
|
||||
```
|
||||
That's it.
|
||||
### Customization
|
||||
@@ -159,9 +159,9 @@ That's it.
|
||||
`SideMenuManager` supports the following:
|
||||
``` swift
|
||||
/// The left menu.
|
||||
open var menuLeftNavigationController: UISideMenuNavigationController?
|
||||
open var leftMenuNavigationController: UISideMenuNavigationController?
|
||||
/// The right menu.
|
||||
public var menuRightNavigationController: UISideMenuNavigationController?
|
||||
public var rightMenuNavigationController: UISideMenuNavigationController?
|
||||
/**
|
||||
Adds screen edge gestures for both left and right sides to a view to present a menu.
|
||||
|
||||
@@ -217,8 +217,10 @@ var dismissOnPush: Bool = true
|
||||
var dismissOnRotation: Bool = true
|
||||
/// Automatically dismisses the menu when app goes to the background.
|
||||
var dismissWhenBackgrounded: Bool = true
|
||||
/// Enable or disable gestures that would swipe to dismiss the menu. Default is true.
|
||||
var enableSwipeGestures: Bool = true
|
||||
/// Enable or disable a swipe gesture that dismisses the menu. Will not be triggered when `presentingViewControllerUserInteractionEnabled` is set to true. Default is true.
|
||||
var enableSwipeToDismissGesture: Bool = true
|
||||
/// Enable or disable a tap gesture that dismisses the menu. Will not be triggered when `presentingViewControllerUserInteractionEnabled` is set to true. Default is true.
|
||||
var enableTapToDismissGesture: Bool = true
|
||||
/// The animation initial spring velocity when a menu is displayed. Ignored when displayed with a gesture.
|
||||
var initialSpringVelocity: CGFloat = 1
|
||||
/// Whether the menu appears on the right or left side of the screen. Right is the default. This property cannot be changed after the menu has loaded.
|
||||
@@ -256,21 +258,21 @@ var isHidden: Bool
|
||||
There are 8 pre-defined `SideMenuPresentStyle` options:
|
||||
``` swift
|
||||
/// Menu slides in over the existing view.
|
||||
static let menuSlideIn = SideMenuPresentStyle
|
||||
static let menuSlideIn: SideMenuPresentStyle
|
||||
/// The existing view slides out to reveal the menu underneath.
|
||||
static let viewSlideOut = SideMenuPresentStyle
|
||||
static let viewSlideOut: SideMenuPresentStyle
|
||||
/// The existing view slides out while the menu slides in.
|
||||
static let viewSlideOutMenuIn = SideMenuPresentStyle
|
||||
static let viewSlideOutMenuIn: SideMenuPresentStyle
|
||||
/// The menu dissolves in over the existing view.
|
||||
static let menuDissolveIn = SideMenuPresentStyle
|
||||
static let menuDissolveIn: SideMenuPresentStyle
|
||||
/// The existing view slides out while the menu partially slides in.
|
||||
static let viewSlideOutMenuPartialIn = SideMenuPresentStyle
|
||||
static let viewSlideOutMenuPartialIn: SideMenuPresentStyle
|
||||
/// The existing view slides out while the menu slides out from under it.
|
||||
static let viewSlideOutMenuOut = SideMenuPresentStyle
|
||||
static let viewSlideOutMenuOut: SideMenuPresentStyle
|
||||
/// The existing view slides out while the menu partially slides out from under it.
|
||||
static let viewSlideOutMenuPartialOut = SideMenuPresentStyle
|
||||
static let viewSlideOutMenuPartialOut: SideMenuPresentStyle
|
||||
/// The existing view slides out and shrinks to reveal the menu underneath.
|
||||
static let viewSlideOutMenuZoom = SideMenuPresentStyle
|
||||
static let viewSlideOutMenuZoom: SideMenuPresentStyle
|
||||
```
|
||||
#### UISideMenuNavigationControllerDelegate
|
||||
To receive notifications when a menu is displayed from a view controller, have it adhere to the `UISideMenuNavigationControllerDelegate` protocol:
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SideMenu"
|
||||
s.version = "6.0.2"
|
||||
s.version = "6.1.4"
|
||||
s.summary = "Simple side menu control for iOS in Swift inspired by Facebook. Right and Left sides. No coding required."
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
@@ -29,7 +29,7 @@ Pod::Spec.new do |s|
|
||||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.swift_version = '5'
|
||||
s.swift_version = '5.0'
|
||||
|
||||
s.source_files = 'Pod/Classes/**/*'
|
||||
# s.resource_bundles = {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
842820FB22DDD1E800C6F2D8 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842820F522DDD1E800C6F2D8 /* Extensions.swift */; };
|
||||
842820FD22DDD21100C6F2D8 /* SideMenuPresentationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842820FC22DDD21100C6F2D8 /* SideMenuPresentationStyle.swift */; };
|
||||
842820FF22DDD24200C6F2D8 /* SideMenuInteractionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842820FE22DDD24200C6F2D8 /* SideMenuInteractionController.swift */; };
|
||||
8428210322E0449300C6F2D8 /* Deprecations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8428210222E0449300C6F2D8 /* Deprecations.swift */; };
|
||||
8461A2D51E145A08001DA4F8 /* UISideMenuNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8461A2D11E145A08001DA4F8 /* UISideMenuNavigationController.swift */; };
|
||||
8461A2D61E145A08001DA4F8 /* UITableViewVibrantCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8461A2D21E145A08001DA4F8 /* UITableViewVibrantCell.swift */; };
|
||||
84B489B51DD469B000D6CB43 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 84B489B21DD469B000D6CB43 /* LICENSE */; };
|
||||
@@ -61,6 +62,7 @@
|
||||
842820F522DDD1E800C6F2D8 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Extensions.swift; path = Pod/Classes/Extensions.swift; sourceTree = "<group>"; };
|
||||
842820FC22DDD21100C6F2D8 /* SideMenuPresentationStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SideMenuPresentationStyle.swift; path = Pod/Classes/SideMenuPresentationStyle.swift; sourceTree = "<group>"; };
|
||||
842820FE22DDD24200C6F2D8 /* SideMenuInteractionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SideMenuInteractionController.swift; path = Pod/Classes/SideMenuInteractionController.swift; sourceTree = "<group>"; };
|
||||
8428210222E0449300C6F2D8 /* Deprecations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Deprecations.swift; path = Pod/Classes/Deprecations.swift; sourceTree = "<group>"; };
|
||||
8461A2D11E145A08001DA4F8 /* UISideMenuNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UISideMenuNavigationController.swift; path = Pod/Classes/UISideMenuNavigationController.swift; sourceTree = "<group>"; };
|
||||
8461A2D21E145A08001DA4F8 /* UITableViewVibrantCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UITableViewVibrantCell.swift; path = Pod/Classes/UITableViewVibrantCell.swift; sourceTree = "<group>"; };
|
||||
84B489B21DD469B000D6CB43 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
@@ -104,6 +106,7 @@
|
||||
65FF1B3F1DE33097007B0845 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8428210222E0449300C6F2D8 /* Deprecations.swift */,
|
||||
842820F522DDD1E800C6F2D8 /* Extensions.swift */,
|
||||
842820F422DDD1E800C6F2D8 /* Initializable.swift */,
|
||||
842820F122DDD1E800C6F2D8 /* Models.swift */,
|
||||
@@ -382,6 +385,7 @@
|
||||
842820F722DDD1E800C6F2D8 /* Models.swift in Sources */,
|
||||
842820F622DDD1E800C6F2D8 /* SideMenuPresentationController.swift in Sources */,
|
||||
842820FA22DDD1E800C6F2D8 /* Initializable.swift in Sources */,
|
||||
8428210322E0449300C6F2D8 /* Deprecations.swift in Sources */,
|
||||
8461A2D61E145A08001DA4F8 /* UITableViewVibrantCell.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
Reference in New Issue
Block a user