Skip to content

Commit

Permalink
Merge pull request #6 from Jauzee/master
Browse files Browse the repository at this point in the history
Fixed typo in last PR & added menuWillShow methods to delegates
  • Loading branch information
suricforever authored Apr 19, 2017
2 parents fc8388d + 9bed1c0 commit f03064e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
15 changes: 8 additions & 7 deletions DropdownMenu/DropUpMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ 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)
func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu)
func dropUpMenuWillShow(_ dropUpMenu: DropUpMenu)
}

public extension DropUpMenuDelegate {
func dropUpMenu(_ dropUpMenu: DropUpMenu, cellForRowAt indexPath: IndexPath) -> UITableViewCell? {
return nil
}

func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) {
}
func dropUpMenu(_ dropUpMenu: DropUpMenu, didSelectRowAt indexPath: IndexPath) { }

func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) {
}
func dropUpMenuCancel(_ dropUpMenu: DropUpMenu) { }

func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) {
}
func dropUpMenuWillDismiss(_ dropUpMenu: DropUpMenu) { }

func dropUpMenuWillShow(_ dropUpMenu: DropUpMenu) { }
}

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

open func showMenu() {
delegate?.dropUpMenuWillShow(self)
if isShow {
hideMenu()
return
Expand Down
9 changes: 8 additions & 1 deletion DropdownMenu/DropdownMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ public protocol DropdownMenuDelegate: class {
func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath)
func dropdownMenuCancel(_ dropdownMenu: DropdownMenu)
func dropdownMenuWillDismiss(_ dropdownMenu: DropdownMenu)
func dropdownMenuWillShow(_ 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) { }
func dropdownMenuWillShow(_ dropdownMenu: DropdownMenu) { }
}

open class DropdownMenu: UIView {
Expand All @@ -36,7 +38,11 @@ open class DropdownMenu: UIView {
fileprivate let portraitTopOffset: CGFloat = 64.0
fileprivate let landscapeTopOffset: CGFloat = 32.0
fileprivate var topLayoutConstraintConstant: CGFloat {
return navigationController.navigationBar.frame.height + navigationController.navigationBar.frame.origin.y + topOffsetY
var offset: CGFloat = 0
if !navigationController.isNavigationBarHidden {
offset = navigationController.navigationBar.frame.height + navigationController.navigationBar.frame.origin.y
}
return offset + topOffsetY
}

open weak var delegate: DropdownMenuDelegate?
Expand Down Expand Up @@ -197,6 +203,7 @@ open class DropdownMenu: UIView {
}

open func showMenu(isOnNavigaitionView: Bool = false) {
delegate?.dropdownMenuWillShow(self)
if isShow {
hideMenu()
return
Expand Down
2 changes: 1 addition & 1 deletion TBDropdownMenu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "TBDropdownMenu"
s.version = "2.3.0"
s.version = "2.4.1"
s.summary = "TBDropdownMenu is a dropdown menu for navigationController in Swift"

# This description is used to generate tags and improve search results.
Expand Down

0 comments on commit f03064e

Please sign in to comment.