Skip to content

Commit

Permalink
Merge pull request #5 from Jauzee/master
Browse files Browse the repository at this point in the history
Added new delegate method both to DropdownMenu & DropUpMenu
  • Loading branch information
suricforever authored Apr 12, 2017
2 parents 273fe3c + d92ff5a commit fc8388d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions DropdownMenu/DropUpMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public protocol DropUpMenuDelegate: class {
func dropUpMenu(_ dropUpMenu: DropUpMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell?
func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath)
func dropUpMenuCancel(_ dropUpMenu: DropUpMenu)
func dropUpMenuWillDismiss(_ dropUpMenu: DropdownMenu)
}

public extension DropUpMenuDelegate {
Expand All @@ -32,6 +33,9 @@ public extension DropUpMenuDelegate {

func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) {
}

func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) {
}
}

private let screenRect = UIScreen.main.bounds
Expand Down Expand Up @@ -181,6 +185,7 @@ open class DropUpMenu: UIView {
}

open func hideMenu(isSelectAction: Bool = false) {
delegate?.dropUpMenuWillDismiss(self)
UIView.animate(withDuration: animateDuration, animations: {
self.backgroundColor = self.backgroudBeginColor
self.tableView.frame.origin.y = screenRect.height - self.bottomOffsetY
Expand Down
3 changes: 3 additions & 0 deletions DropdownMenu/DropdownMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ public protocol DropdownMenuDelegate: class {
func dropdownMenu(_ dropdownMenu: DropdownMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell?
func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath)
func dropdownMenuCancel(_ dropdownMenu: DropdownMenu)
func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu)
}

public extension DropdownMenuDelegate {
func dropdownMenu(_ dropdownMenu: DropdownMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell? { return nil }
func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) { }
func dropdownMenuCancel(_ dropdownMenu: DropdownMenu) { }
func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu) { }
}

open class DropdownMenu: UIView {
Expand Down Expand Up @@ -234,6 +236,7 @@ open class DropdownMenu: UIView {
}

open func hideMenu(isSelectAction: Bool = false) {
delegate?.dropdownMenuWillDismiss(self)
UIView.animate(withDuration: animateDuration, animations: {
self.backgroundColor = self.backgroudBeginColor
self.tableView.frame.origin.y = -self.tableViewHeight
Expand Down

0 comments on commit fc8388d

Please sign in to comment.