diff --git a/PanelKit/Controller/PanelViewController.swift b/PanelKit/Controller/PanelViewController.swift index 6f42cb4..075e827 100644 --- a/PanelKit/Controller/PanelViewController.swift +++ b/PanelKit/Controller/PanelViewController.swift @@ -179,6 +179,7 @@ import UIKit print("\(self) viewWillAppear") } + manager?.panelWillAppear(self, animated: animated) } override public func viewDidAppear(_ animated: Bool) { @@ -191,6 +192,7 @@ import UIKit print("\(self) viewDidAppear") } + manager?.panelDidAppear(self, animated: animated) } override public func viewWillDisappear(_ animated: Bool) { @@ -202,6 +204,7 @@ import UIKit print("\(self) viewWillDisappear") } + manager?.panelWillDisappear(self, animated: animated) } override public func viewDidDisappear(_ animated: Bool) { @@ -213,6 +216,7 @@ import UIKit print("\(self) viewDidDisappear") } + manager?.panelDidDisappear(self, animated: animated) } override public func viewWillLayoutSubviews() { diff --git a/PanelKit/Model/PanelPinSide.swift b/PanelKit/Model/PanelPinSide.swift index 18485ec..e9194ed 100644 --- a/PanelKit/Model/PanelPinSide.swift +++ b/PanelKit/Model/PanelPinSide.swift @@ -16,6 +16,27 @@ import Foundation case bottom } +public extension PanelPinSide { + + public var isVertical: Bool { + + let sides: [PanelPinSide] + + sides = [.top, .bottom] + + return sides.contains(self) + } + + public var isHorizontal: Bool { + + let sides: [PanelPinSide] + + sides = [.left, .right] + + return sides.contains(self) + } +} + extension PanelPinSide: CustomStringConvertible { public var description: String { diff --git a/PanelKit/PanelManager/PanelManager+Default.swift b/PanelKit/PanelManager/PanelManager+Default.swift index eb5aeb8..6a5b05a 100644 --- a/PanelKit/PanelManager/PanelManager+Default.swift +++ b/PanelKit/PanelManager/PanelManager+Default.swift @@ -14,6 +14,10 @@ public extension PanelManager { func didUpdatePinnedPanels() { } + + func panelManager(_ manager: PanelManager, didUpdatePinnedStateFor panel: PanelViewController, side: PanelPinSide) { + + } func enablePanelShadow(for panel: PanelViewController) -> Bool { return true @@ -50,5 +54,21 @@ public extension PanelManager { var exposeOverlayBlurEffect: UIBlurEffect { return UIBlurEffect(style: .light) } + + func panelWillAppear(_ panel: PanelViewController, animated: Bool) { + + } + + func panelWillDisappear(_ panel: PanelViewController, animated: Bool) { + + } + + func panelDidAppear(_ panel: PanelViewController, animated: Bool) { + + } + + func panelDidDisappear(_ panel: PanelViewController, animated: Bool) { + + } } diff --git a/PanelKit/PanelManager/PanelManager+Dragging.swift b/PanelKit/PanelManager/PanelManager+Dragging.swift index 3a68408..f0ecd6d 100644 --- a/PanelKit/PanelManager/PanelManager+Dragging.swift +++ b/PanelKit/PanelManager/PanelManager+Dragging.swift @@ -137,6 +137,8 @@ extension PanelManager { self.panelContentWrapperView.layoutIfNeeded() self.didUpdatePinnedPanels() + + self.panelManager(self, didUpdatePinnedStateFor: panel, side: side) }, completion: { (_) in @@ -281,6 +283,8 @@ extension PanelManager { self.panelContentWrapperView.layoutIfNeeded() self.didUpdatePinnedPanels() + + self.panelManager(self, didUpdatePinnedStateFor: panel, side: side) }, completion: { (_) in diff --git a/PanelKit/PanelManager/PanelManager+Pinning.swift b/PanelKit/PanelManager/PanelManager+Pinning.swift index 9f601d3..1559401 100644 --- a/PanelKit/PanelManager/PanelManager+Pinning.swift +++ b/PanelKit/PanelManager/PanelManager+Pinning.swift @@ -411,6 +411,8 @@ public extension PanelManager { self.panelContentWrapperView.layoutIfNeeded() self.didUpdatePinnedPanels() + + self.panelManager(self, didUpdatePinnedStateFor: panel, side: side) // Send panel and preview view to back, so (shadows of) non-pinned panels are on top self.panelContentWrapperView.insertSubview(panelView, aboveSubview: self.panelContentView) diff --git a/PanelKit/PanelManager/PanelManager.swift b/PanelKit/PanelManager/PanelManager.swift index 597dc76..1ff24b6 100644 --- a/PanelKit/PanelManager/PanelManager.swift +++ b/PanelKit/PanelManager/PanelManager.swift @@ -57,6 +57,12 @@ public protocol PanelManager: class { /// This will be called when a panel is pinned or unpinned. /// The default implementation is an empty function. func didUpdatePinnedPanels() + + /// This will be called when a panel is pinned or unpinned. + /// The default implementation is an empty function. + func panelManager(_ manager: PanelManager, + didUpdatePinnedStateFor panel: PanelViewController, + side: PanelPinSide) /// Drag insets for panel. /// @@ -77,6 +83,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) }