Skip to content

Commit

Permalink
Fixed MenuControllerMonitor implementation (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Nyondo authored and eBardX committed Jun 1, 2018
1 parent 5d0f603 commit 4a53882
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions Sources/Core/UIKit/Other/MenuControllerMonitor.swift
Expand Up @@ -121,39 +121,44 @@ public class MenuControllerMonitor: BaseNotificationMonitor {
super.addNotificationObservers()

if options.contains(.didHideMenu) {
observe(.UIMenuControllerDidHideMenu) { [unowned self] in
observe(.UIMenuControllerDidHideMenu,
object: UIMenuController.shared) { [unowned self] in
if let menu = $0.object as? UIMenuController {
self.handler(.didHideMenu(menu))
}
}
}

if options.contains(.didShowMenu) {
observe(.UIMenuControllerDidShowMenu) { [unowned self] in
observe(.UIMenuControllerDidShowMenu,
object: UIMenuController.shared) { [unowned self] in
if let menu = $0.object as? UIMenuController {
self.handler(.didShowMenu(menu))
}
}
}

if options.contains(.menuFrameDidChange) {
observe(.UIMenuControllerMenuFrameDidChange) { [unowned self] in
observe(.UIMenuControllerMenuFrameDidChange,
object: UIMenuController.shared) { [unowned self] in
if let menu = $0.object as? UIMenuController {
self.handler(.menuFrameDidChange(menu))
}
}
}

if options.contains(.willHideMenu) {
observe(.UIMenuControllerWillHideMenu) { [unowned self] in
observe(.UIMenuControllerWillHideMenu,
object: UIMenuController.shared) { [unowned self] in
if let menu = $0.object as? UIMenuController {
self.handler(.willHideMenu(menu))
}
}
}

if options.contains(.willShowMenu) {
observe(.UIMenuControllerWillShowMenu) { [unowned self] in
observe(.UIMenuControllerWillShowMenu,
object: UIMenuController.shared) { [unowned self] in
if let menu = $0.object as? UIMenuController {
self.handler(.willShowMenu(menu))
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/UIKit/Other/MenuControllerMonitorTests.swift
Expand Up @@ -13,7 +13,7 @@ import XCTest

internal class MenuControllerMonitorTests: XCTestCase {
let notificationCenter = MockNotificationCenter()
let menuController = UIMenuController()
let menuController = UIMenuController.shared

override func setUp() {
super.setUp()
Expand Down

0 comments on commit 4a53882

Please sign in to comment.