Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

panel appearance callbacks in manager #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
added panel closing callback
  • Loading branch information
omiz committed Jan 14, 2019
commit b07a1fc0c6438e466d65a52c706373bf769152c6
4 changes: 4 additions & 0 deletions PanelKit/Controller/PanelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ import UIKit
print("\(self) viewWillAppear")
}

manager?.panelWillAppear(self, animated: animated)
}

override public func viewDidAppear(_ animated: Bool) {
Expand All @@ -191,6 +192,7 @@ import UIKit
print("\(self) viewDidAppear")
}

manager?.panelDidAppear(self, animated: animated)
}

override public func viewWillDisappear(_ animated: Bool) {
Expand All @@ -202,6 +204,7 @@ import UIKit
print("\(self) viewWillDisappear")
}

manager?.panelWillDisappear(self, animated: animated)
}

override public func viewDidDisappear(_ animated: Bool) {
Expand All @@ -213,6 +216,7 @@ import UIKit
print("\(self) viewDidDisappear")
}

manager?.panelDidDisappear(self, animated: animated)
}

override public func viewWillLayoutSubviews() {
Expand Down
30 changes: 30 additions & 0 deletions PanelKit/PanelManager/PanelManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ public protocol PanelManager: class {
/// Called when exposé is about to be exited.
/// The default implementation is an empty function.
func willExitExpose()

/// Called when panel is about to appear.
/// The default implementation is an empty function.
func panelWillAppear(_ panel: PanelViewController, animated: Bool)

/// Called when panel is about to disappear.
/// The default implementation is an empty function.
func panelWillDisappear(_ panel: PanelViewController, animated: Bool)

/// Called when panel has appeared.
/// The default implementation is an empty function.
func panelDidAppear(_ panel: PanelViewController, animated: Bool)

/// Called when panel has disappeared.
/// The default implementation is an empty function.
func panelDidDisappear(_ panel: PanelViewController, animated: Bool)

}

Expand Down Expand Up @@ -125,3 +141,17 @@ public extension PanelManager {
}

}

// MARK: - Default implementation

extension PanelManager {

func panelWillAppear(_ panel: PanelViewController, animated: Bool) {}

func panelWillDisappear(_ panel: PanelViewController, animated: Bool) {}

func panelDidAppear(_ panel: PanelViewController, animated: Bool) {}

func panelDidDisappear(_ panel: PanelViewController, animated: Bool) {}
}