From 2cea3499ee5f429bf2b617b93cf8d3119eefde8e Mon Sep 17 00:00:00 2001 From: jonkykong Date: Fri, 5 Jul 2019 15:18:30 -0700 Subject: [PATCH] Added deprecations --- Deprecations.swift | 180 ++++++++++++++++ Pod/Classes/Models.swift | 2 + Pod/Classes/SideMenuManager.swift | 194 ------------------ Pod/Classes/SideMenuPresentStyle.swift | 2 - .../UISideMenuNavigationController.swift | 12 +- Pods/Pods.xcodeproj/project.pbxproj | 4 + 6 files changed, 195 insertions(+), 199 deletions(-) create mode 100644 Deprecations.swift diff --git a/Deprecations.swift b/Deprecations.swift new file mode 100644 index 0000000..0c82d86 --- /dev/null +++ b/Deprecations.swift @@ -0,0 +1,180 @@ +// +// Deprecations.swift +// SideMenu +// +// Created by Jon Kent on 7/3/19. +// + +// Deprecations; to be removed at a future date. +extension SideMenuManager { + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuPresentMode: SideMenuPresentStyle { + get { return .viewSlideOut } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuPushStyle: MenuPushStyle { + get { return .default } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAllowPushOfSameClassTwice: Bool { + get { return true } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuWidth: CGFloat { + get { return 0 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationPresentDuration: Double { + get { return 0.35 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationDismissDuration: Double { + get { return 0.35 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationCompleteGestureDuration: Double { + get { return 0.35 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationFadeStrength: CGFloat { + get { return 0 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationTransformScaleFactor: CGFloat { + get { return 1 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationBackgroundColor: UIColor? { + get { return nil } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuShadowOpacity: Float { + get { return 0.5 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuShadowColor: UIColor { + get { return .black } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuShadowRadius: CGFloat { + get { return 5 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuPresentingViewControllerUserInteractionEnabled: Bool { + get { return false } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuParallaxStrength: Int { + get { return 0 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuFadeStatusBar: Bool { + get { return true } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationOptions: UIView.AnimationOptions { + get { return .curveEaseInOut } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationCompletionCurve: UIView.AnimationCurve { + get { return .easeIn } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationUsingSpringWithDamping: CGFloat { + get { return 1 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAnimationInitialSpringVelocity: CGFloat { + get { return 1 } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuDismissOnPush: Bool { + get { return true } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuAlwaysAnimate: Bool { + get { return false } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuDismissWhenBackgrounded: Bool { + get { return true } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuBlurEffectStyle: UIBlurEffect.Style? { + get { return nil } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public weak var menuLeftSwipeToDismissGesture: UIPanGestureRecognizer? { + get { return nil } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public weak var menuRightSwipeToDismissGesture: UIPanGestureRecognizer? { + get { return nil } + set {} + } + + @available(*, deprecated, message: "This property has been moved to the UISideMenuNavigationController class.") + public var menuEnableSwipeGestures: Bool { + get { return true } + set {} + } + + @available(*, deprecated, renamed: "SideMenuPresentStyle") + public typealias MenuPresentMode = SideMenuPresentStyle +} + +extension SideMenuPresentStyle { + @available(*, deprecated, renamed: "viewSlideOutMenuIn") + public static let viewSlideInOut = viewSlideOutMenuIn +} diff --git a/Pod/Classes/Models.swift b/Pod/Classes/Models.swift index 383e17d..e33cd10 100644 --- a/Pod/Classes/Models.swift +++ b/Pod/Classes/Models.swift @@ -24,6 +24,8 @@ internal protocol MenuModel: TransitionModel { var dismissOnPresent: Bool { get } /// Automatically dismisses the menu when another view controller is pushed from it. var dismissOnPush: Bool { get } + /// Automatically dismisses the menu when the screen is rotated. + 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. diff --git a/Pod/Classes/SideMenuManager.swift b/Pod/Classes/SideMenuManager.swift index 5d4a6d1..a1ca91a 100644 --- a/Pod/Classes/SideMenuManager.swift +++ b/Pod/Classes/SideMenuManager.swift @@ -211,197 +211,3 @@ extension SideMenuManager: UISideMenuNavigationControllerTransitionDelegate { switchToMenu.presentFrom(activeViewController, interactively: true) } } - -// Deprecations, to be removed at a future date. -extension SideMenuManager { -// @available(*, deprecated, renamed: "menuPresentStyle") -// open var menuPresentMode: MenuPresentStyle { -// get { return menuPresentStyle } -// set { menuPresentStyle = newValue } -// } - - /** - The push style of the menu. - - There are six modes in MenuPushStyle: - - defaultBehavior: The view controller is pushed onto the stack. - - popWhenPossible: If a view controller already in the stack is of the same class as the pushed view controller, the stack is instead popped back to the existing view controller. This behavior can help users from getting lost in a deep navigation stack. - - preserve: If a view controller already in the stack is of the same class as the pushed view controller, the existing view controller is pushed to the end of the stack. This behavior is similar to a UITabBarController. - - preserveAndHideBackButton: Same as .preserve and back buttons are automatically hidden. - - replace: Any existing view controllers are released from the stack and replaced with the pushed view controller. Back buttons are automatically hidden. This behavior is ideal if view controllers require a lot of memory or their state doesn't need to be preserved.. - - subMenu: Unlike all other behaviors that push using the menu's presentingViewController, this behavior pushes view controllers within the menu. Use this behavior if you want to display a sub menu. - */ - // open var menuPushStyle: MenuPushStyle = .defaultBehavior - - /** - The presentation stayle of the menu. - - There are four modes in MenuPresentStyle: - - menuSlideIn: Menu slides in over of the existing view. - - viewSlideOut: The existing view slides out to reveal the menu. - - viewSlideInOut: The existing view slides out while the menu slides in. - - menuDissolveIn: The menu dissolves in over the existing view controller. - */ - // open var menuPresentStyle: MenuPresentStyle = .viewSlideOut - - /// Prevents the same view controller (or a view controller of the same class) from being pushed more than once. Defaults to true. - // open var menuAllowPushOfSameClassTwice = true - - /** - Width of the menu when presented on screen, showing the existing view controller in the remaining space. Default is 75% of the screen width or 240 points, whichever is smaller. - - Note that each menu's width can be overridden using the `menuWidth` property on any `UISideMenuNavigationController` instance. - */ - // open var menuWidth: CGFloat = { - // let appScreenRect = UIApplication.shared.keyWindow?.bounds ?? UIWindow().bounds - // let minimumSize = min(appScreenRect.width, appScreenRect.height) - // return min(round(minimumSize * 0.75), 240) - // }() - - /// Duration of the animation when the menu is presented without gestures. Default is 0.35 seconds. - // open var menuAnimationPresentDuration: Double = 0.35 - - /// Duration of the animation when the menu is dismissed without gestures. Default is 0.35 seconds. - // open var menuAnimationDismissDuration: Double = 0.35 - - /// Duration of the remaining animation when the menu is partially dismissed with gestures. Default is 0.35 seconds. - // open var menuAnimationCompleteGestureDuration: Double = 0.35 - - /// Amount to fade the existing view controller when the menu is presented. Default is 0 for no fade. Set to 1 to fade completely. - // open var menuAnimationFadeStrength: CGFloat = 0 - - /// The amount to scale the existing view controller or the menu view controller depending on the `menuPresentMode`. Default is 1 for no scaling. Less than 1 will shrink, greater than 1 will grow. - // open var menuAnimationTransformScaleFactor: CGFloat = 1 - - /// The background color behind menu animations. Depending on the animation settings this may not be visible. If `menuFadeStatusBar` is true, this color is used to fade it. Default is black. - // open var menuAnimationBackgroundColor: UIColor? - - /// The shadow opacity around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is 0.5 for 50% opacity. - // open var menuShadowOpacity: Float = 0.5 - - /// The shadow color around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is black. - // open var menuShadowColor = UIColor.black - - /// The radius of the shadow around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is 5. - // open var menuShadowRadius: CGFloat = 5 - - /// Enable or disable interaction with the presenting view controller while the menu is displayed. Enabling may make it difficult to dismiss the menu or cause exceptions if the user tries to present and already presented menu. Default is false. - // open var menuPresentingViewControllerUserInteractionEnabled: Bool = false - - /// The strength of the parallax effect on the existing view controller. Does not apply to `menuPresentMode` when set to `ViewSlideOut`. Default is 0. - // open var menuParallaxStrength: Int = 0 - - /// Draws the `menuAnimationBackgroundColor` behind the status bar. Default is true. - // open var menuFadeStatusBar = true - - /// The animation options when a menu is displayed. Ignored when displayed with a gesture. - // open var menuAnimationOptions: UIView.AnimationOptions = .curveEaseInOut - - /// Animation curve of the remaining animation when the menu is partially dismissed with gestures. Default is .easeIn. - // open var menuAnimationCompletionCurve: UIView.AnimationCurve = .easeIn - - /// The animation spring damping when a menu is displayed. Ignored when displayed with a gesture. - // open var menuAnimationUsingSpringWithDamping: CGFloat = 1 - - /// The animation initial spring velocity when a menu is displayed. Ignored when displayed with a gesture. - // open var menuAnimationInitialSpringVelocity: CGFloat = 1 - - /** - Automatically dismisses the menu when another view is pushed from it. - - Note: to prevent the menu from dismissing when presenting, set modalPresentationStyle = .overFullScreen - of the view controller being presented in storyboard or during its initalization. - */ - // open var menuDismissOnPush = true - - /// Forces menus to always animate when appearing or disappearing, regardless of a pushed view controller's animation. - // open var menuAlwaysAnimate = false - - /// Automatically dismisses the menu when app goes to the background. - // open var menuDismissWhenBackgrounded = true - - /** - The blur effect style of the menu if the menu's root view controller is a UITableViewController or UICollectionViewController. - - - Note: If you want cells in a UITableViewController menu to show vibrancy, make them a subclass of UITableViewVibrantCell. - */ -// open var menuBlurEffectStyle: UIBlurEffect.Style? { -// didSet { -// if oldValue != menuBlurEffectStyle { -// updateBlurIfNecessary() -// } -// } -// } -// -// /// The left menu. -// open var menuLeftNavigationController: UISideMenuNavigationController? { -// didSet { -// if !setMenu(from: oldValue, to: menuLeftNavigationController, side: .left) { -// menuLeftNavigationController = oldValue -// } -// } -// } -// -// /// The right menu. -// open var menuRightNavigationController: UISideMenuNavigationController? { -// didSet { -// if !setMenu(from: oldValue, to: menuRightNavigationController, side: .right) { -// menuRightNavigationController = oldValue -// } -// } -// } -// -// /// The left menu swipe to dismiss gesture. -// open private(set) weak var menuLeftSwipeToDismissGesture: UIPanGestureRecognizer? { -// didSet { -// oldValue?.view?.removeGestureRecognizer(oldValue!) -// } -// } -// -// open private(set) weak var menuRightSwipeToDismissGesture: UIPanGestureRecognizer? { -// didSet { -// oldValue?.view?.removeGestureRecognizer(oldValue!) -// } -// } -// -// open var menuEnableSwipeGestures: Bool = true { -// didSet { -// setupSwipeGestures() -// } -// } -// /** -// Adds screen edge gestures to a view to present a menu. -// -// - Parameter toView: The view to add gestures to. -// - Parameter forMenu: The menu (left or right) you want to add a gesture for. If unspecified, gestures will be added for both sides. -// -// - Returns: The array of screen edge gestures added to `toView`. -// */ -// @discardableResult open func menuAddScreenEdgePanGesturesToPresent(toView view: UIView, forMenu sides: [PresentDirection] = [.left, .right]) -> [UIScreenEdgePanGestureRecognizer] { -// sides.forEach { side in -// if menu(forSide: side) == nil { -// let methodName = #function // "menuAddScreenEdgePanGesturesToPresent" -// let suggestedMethodName = "menuAddScreenEdgePanGesturesToPresent(toView:forMenu:)" -// Print.warning(.screenGestureAdded, arguments: methodName, side.name, suggestedMethodName) -// } -// } -// -// let edges: [UIRectEdge] = sides.map { $0.edge } -// return addPresentScreenEdgePanGestures(to: view, for: edges) -// } -// -// /** -// Adds a pan edge gesture to a view to present menus. -// -// - Parameter toView: The view to add a pan gesture to. -// -// - Returns: The pan gesture added to `toView`. -// */ -// @discardableResult open func menuAddPanGestureToPresent(toView view: UIView) -> UIPanGestureRecognizer { -// if menuLeftNavigationController ?? menuRightNavigationController == nil { -// Print.warning(.panGestureAdded, arguments: #function, PresentDirection.left.name, PresentDirection.right.name, required: true) -// } -// -// return addPresentPanGesture(to: view) -// } -} diff --git a/Pod/Classes/SideMenuPresentStyle.swift b/Pod/Classes/SideMenuPresentStyle.swift index 5749fb9..d69586f 100644 --- a/Pod/Classes/SideMenuPresentStyle.swift +++ b/Pod/Classes/SideMenuPresentStyle.swift @@ -60,8 +60,6 @@ public extension SideMenuPresentStyle { $0.menuTranslateFactor = -1 $0.presentingTranslateFactor = 1 } - @available(*, deprecated, renamed: "viewSlideOutMenuIn") - static let viewSlideInOut = viewSlideOutMenuIn static let menuDissolveIn = SideMenuPresentStyle { $0.menuStartAlpha = 0 $0.menuOnTop = true diff --git a/Pod/Classes/UISideMenuNavigationController.swift b/Pod/Classes/UISideMenuNavigationController.swift index 1d76bb7..512b7dc 100644 --- a/Pod/Classes/UISideMenuNavigationController.swift +++ b/Pod/Classes/UISideMenuNavigationController.swift @@ -37,6 +37,7 @@ public struct SideMenuSettings: MenuModel { public var dismissDuration: Double = 0.35 public var dismissOnPresent: Bool = true public var dismissOnPush: Bool = true + public var dismissOnRotation: Bool = true public var dismissWhenBackgrounded: Bool = true public var enableSwipeGestures: Bool = true public var statusBarEndAlpha: CGFloat = 1 @@ -224,16 +225,16 @@ open class UISideMenuNavigationController: UINavigationController { rotating = true - let presentingViewControllerUseSnapshot = self.presentingViewControllerUseSnapshot + let dismiss = self.presentingViewControllerUseSnapshot || self.dismissOnRotation coordinator.animate(alongsideTransition: { _ in - if presentingViewControllerUseSnapshot { + if dismiss { transitionController.transition(presenting: false, animated: false, complete: false) } else { transitionController.layout() } }) { [weak self] _ in guard let self = self else { return } - if presentingViewControllerUseSnapshot { + if dismiss { self.dismissMenu(animated: false) } self.rotating = false @@ -304,6 +305,11 @@ extension UISideMenuNavigationController: MenuModel { set { settings.dismissOnPush = newValue } } + @IBInspectable open var dismissOnRotation: Bool { + get { return settings.dismissOnRotation } + set { settings.dismissOnRotation = newValue } + } + @IBInspectable open var dismissWhenBackgrounded: Bool { get { return settings.dismissWhenBackgrounded } set { settings.dismissWhenBackgrounded = newValue } diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index 197315a..94fd9df 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 84226FCE22CB466900DACB20 /* Initializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84226FCB22CB466900DACB20 /* Initializable.swift */; }; 84226FCF22CB466900DACB20 /* SideMenuPresentStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84226FCC22CB466900DACB20 /* SideMenuPresentStyle.swift */; }; 84226FD322CC906300DACB20 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84226FD222CC906300DACB20 /* Models.swift */; }; + 84226FD522CC987100DACB20 /* Deprecations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84226FD422CC987100DACB20 /* Deprecations.swift */; }; 84241FB721D6CB50002D4862 /* SideMenuInteractionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84241FB621D6CB50002D4862 /* SideMenuInteractionController.swift */; }; 8436EF15220EE97800A8861A /* Protected.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8436EF14220EE97800A8861A /* Protected.swift */; }; 8BC8C3FB652840612047B49E8D4B3B44 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6DFF15000AFE2A371BF499E7AFDA808 /* Foundation.framework */; }; @@ -54,6 +55,7 @@ 84226FCB22CB466900DACB20 /* Initializable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Initializable.swift; path = Pod/Classes/Initializable.swift; sourceTree = ""; }; 84226FCC22CB466900DACB20 /* SideMenuPresentStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SideMenuPresentStyle.swift; path = Pod/Classes/SideMenuPresentStyle.swift; sourceTree = ""; }; 84226FD222CC906300DACB20 /* Models.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Models.swift; path = Pod/Classes/Models.swift; sourceTree = ""; }; + 84226FD422CC987100DACB20 /* Deprecations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Deprecations.swift; sourceTree = ""; }; 84241FB621D6CB50002D4862 /* SideMenuInteractionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SideMenuInteractionController.swift; path = Pod/Classes/SideMenuInteractionController.swift; sourceTree = ""; }; 8436EF14220EE97800A8861A /* Protected.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Protected.swift; path = Pod/Classes/Protected.swift; sourceTree = ""; }; 8B22924AF0FECF030E052A8783CA4120 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -99,6 +101,7 @@ children = ( 8FA2C91F7C098E55AD6C36A44D885E67 /* Pod */, 9F412C3C9DC9016F76368C6285235102 /* Support Files */, + 84226FD422CC987100DACB20 /* Deprecations.swift */, 84226FCA22CB466900DACB20 /* Extensions.swift */, 84226FCB22CB466900DACB20 /* Initializable.swift */, 84226FD222CC906300DACB20 /* Models.swift */, @@ -323,6 +326,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84226FD522CC987100DACB20 /* Deprecations.swift in Sources */, 6672CE381BB9B1A0D633B5E98E9A412E /* Print.swift in Sources */, 84226FD322CC906300DACB20 /* Models.swift in Sources */, 84241FB721D6CB50002D4862 /* SideMenuInteractionController.swift in Sources */,