Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.
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
4 changes: 4 additions & 0 deletions SideMenuController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -119,6 +121,7 @@
children = (
134E94E31D159C56001C1F7D /* CenterContainmentSegue.swift */,
13A7586C1D12A61B004488DA /* SideContainmentSegue.swift */,
5E4FDD3F512CE5D638BB4D6E /* CenterReplaceSegue.swift */,
);
name = Segues;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down
8 changes: 7 additions & 1 deletion Source/CenterContainmentSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
14 changes: 14 additions & 0 deletions Source/CenterReplaceSegue.swift
Original file line number Diff line number Diff line change
@@ -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
}

}
4 changes: 2 additions & 2 deletions Source/SideMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -118,7 +118,7 @@ public extension SideMenuController {
completion()
}

if sidePanelVisible {
if sidePanelVisible && hideSidePanel {
animate(toReveal: false)
}
}
Expand Down