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 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 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
21 changes: 21 additions & 0 deletions PanelKit/Model/PanelPinSide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions PanelKit/PanelManager/PanelManager+Default.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {

}

}
4 changes: 4 additions & 0 deletions PanelKit/PanelManager/PanelManager+Dragging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ extension PanelManager {
self.panelContentWrapperView.layoutIfNeeded()

self.didUpdatePinnedPanels()

self.panelManager(self, didUpdatePinnedStateFor: panel, side: side)

}, completion: { (_) in

Expand Down Expand Up @@ -281,6 +283,8 @@ extension PanelManager {
self.panelContentWrapperView.layoutIfNeeded()

self.didUpdatePinnedPanels()

self.panelManager(self, didUpdatePinnedStateFor: panel, side: side)

}, completion: { (_) in

Expand Down
2 changes: 2 additions & 0 deletions PanelKit/PanelManager/PanelManager+Pinning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions PanelKit/PanelManager/PanelManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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)

}

Expand Down