diff --git a/SideMenuController.xcodeproj/project.pbxproj b/SideMenuController.xcodeproj/project.pbxproj index b4f1c50..f8dafd7 100644 --- a/SideMenuController.xcodeproj/project.pbxproj +++ b/SideMenuController.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 13F653271D3E007300700656 /* SideMenuController+CustomTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F653241D3E007300700656 /* SideMenuController+CustomTypes.swift */; }; 13F653281D3E007300700656 /* SideMenuController+SideOver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F653251D3E007300700656 /* SideMenuController+SideOver.swift */; }; 13F653291D3E007300700656 /* SideMenuController+SideUnder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F653261D3E007300700656 /* SideMenuController+SideUnder.swift */; }; + 5E4FD4E9A8CF329050F77FD9 /* CenterReplaceSegue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E4FDD3F512CE5D638BB4D6E /* CenterReplaceSegue.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -45,6 +46,7 @@ 13F653241D3E007300700656 /* SideMenuController+CustomTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "SideMenuController+CustomTypes.swift"; path = "Source/SideMenuController+CustomTypes.swift"; sourceTree = SOURCE_ROOT; }; 13F653251D3E007300700656 /* SideMenuController+SideOver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "SideMenuController+SideOver.swift"; path = "Source/SideMenuController+SideOver.swift"; sourceTree = SOURCE_ROOT; }; 13F653261D3E007300700656 /* SideMenuController+SideUnder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "SideMenuController+SideUnder.swift"; path = "Source/SideMenuController+SideUnder.swift"; sourceTree = SOURCE_ROOT; }; + 5E4FDD3F512CE5D638BB4D6E /* CenterReplaceSegue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CenterReplaceSegue.swift; path = Source/CenterReplaceSegue.swift; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -119,6 +121,7 @@ children = ( 134E94E31D159C56001C1F7D /* CenterContainmentSegue.swift */, 13A7586C1D12A61B004488DA /* SideContainmentSegue.swift */, + 5E4FDD3F512CE5D638BB4D6E /* CenterReplaceSegue.swift */, ); name = Segues; sourceTree = ""; @@ -252,6 +255,7 @@ 13F653291D3E007300700656 /* SideMenuController+SideUnder.swift in Sources */, 13F653271D3E007300700656 /* SideMenuController+CustomTypes.swift in Sources */, 134E94E51D159C56001C1F7D /* CenterContainmentSegue.swift in Sources */, + 5E4FD4E9A8CF329050F77FD9 /* CenterReplaceSegue.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/CenterContainmentSegue.swift b/Source/CenterContainmentSegue.swift index 14578e5..bd8912f 100644 --- a/Source/CenterContainmentSegue.swift +++ b/Source/CenterContainmentSegue.swift @@ -21,14 +21,20 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +import UIKit + open class CenterContainmentSegue: UIStoryboardSegue{ + + var needCloseSidePanel: Bool { + return true + } override open func perform() { if let sideController = self.source as? SideMenuController { guard let destinationController = destination as? UINavigationController else { fatalError("Destination controller needs to be an instance of UINavigationController") } - sideController.embed(centerViewController: destinationController) + sideController.embed(centerViewController: destinationController, hideSidePanel: needCloseSidePanel) } else { fatalError("This type of segue must only be used from a SideMenuController") } diff --git a/Source/CenterReplaceSegue.swift b/Source/CenterReplaceSegue.swift new file mode 100644 index 0000000..ca0fe0f --- /dev/null +++ b/Source/CenterReplaceSegue.swift @@ -0,0 +1,14 @@ +// +// Created by Alexander Zalutskiy on 16.12.16. +// Copyright (c) 2016 teodorpatras. All rights reserved. +// + +import Foundation + +open class CenterReplaceSegue: CenterContainmentSegue { + + override var needCloseSidePanel: Bool { + return false + } + +} \ No newline at end of file diff --git a/Source/SideMenuController.swift b/Source/SideMenuController.swift index a4f1aa9..70b07d1 100644 --- a/Source/SideMenuController.swift +++ b/Source/SideMenuController.swift @@ -87,7 +87,7 @@ public extension SideMenuController { - parameter centerViewController: controller to be embedded - parameter cacheIdentifier: identifier for the view controllers cache */ - public func embed(centerViewController controller: UIViewController, cacheIdentifier: String? = nil) { + public func embed(centerViewController controller: UIViewController, cacheIdentifier: String? = nil, hideSidePanel: Bool = true) { if let id = cacheIdentifier { controllersCache[id] = controller @@ -118,7 +118,7 @@ public extension SideMenuController { completion() } - if sidePanelVisible { + if sidePanelVisible && hideSidePanel { animate(toReveal: false) } }