Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add blacklist #16

Open
wants to merge 2 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
9 changes: 9 additions & 0 deletions Sources/UINavigationController+WXNavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extension UINavigationController {
let cls = UINavigationController.self
swizzleMethod(cls, #selector(UINavigationController.pushViewController(_:animated:)), #selector(UINavigationController.wx_pushViewController(_:animated:)))
swizzleMethod(cls, #selector(UINavigationController.setViewControllers(_:animated:)), #selector(UINavigationController.wx_setViewControllers(_:animated:)))
swizzleMethod(cls, #selector(UINavigationController.viewDidLoad), #selector(UINavigationController.wx_navigationViewDidLoad))
}()

func configureNavigationBar() {
Expand Down Expand Up @@ -128,6 +129,14 @@ extension UINavigationController {

}

@objc private func wx_navigationViewDidLoad() {
let type = "\(self.classForCoder)"
let set = WXNavigationBarManger.shared.blackUINavigationControllers
let enableWXNavigationBar: Bool = set.contains(type) ? false : true
wx_enableWXNavigationBar = enableWXNavigationBar
wx_navigationViewDidLoad()
}

private func enableFullscreenPopGesture() {
guard let gestureRecognizers = interactivePopGestureRecognizer?.view?.gestureRecognizers else {
return
Expand Down
15 changes: 14 additions & 1 deletion Sources/WXNavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@

import UIKit

public class WXNavigationBarManger {
public static let shared = WXNavigationBarManger()
/// 黑名单
var blackUINavigationControllers: Set<String> = []

/// 启动 WXNavigationBar黑名单,黑名单内的UINavigationController将关闭WXNavigationBar
/// - Parameter blackUINavigationControllers: 黑名单(类名字符串集合)
public func setup(_ blackUINavigationControllers: Set<String> = []) {
self.blackUINavigationControllers = blackUINavigationControllers
}
}

public class WXNavigationBar: UIView {

/// Global settings of NavigationBar
Expand Down Expand Up @@ -116,7 +128,8 @@ public class WXNavigationBar: UIView {
containerView.addSubview(subView)
}

public static func setup() {
public static func setup(_ blackUINavigationControllers: Set<String> = []) {
WXNavigationBarManger.shared.setup(blackUINavigationControllers)
UIApplication.runOnce
}
}