12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import Foundation
- class NCMainNavigationController: UINavigationController {
-
- var isPushing = false
- required init?(coder: NSCoder) {
- super.init(coder: coder)
-
- NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCBrandGlobal.shared.notificationCenterChangeTheming), object: nil)
-
- changeTheming()
- }
-
-
- override func pushViewController(_ viewController: UIViewController, animated: Bool) {
-
- if !isPushing {
- isPushing = true
- CATransaction.begin()
- CATransaction.setCompletionBlock {
- self.isPushing = false
- }
- super.pushViewController(viewController, animated: animated)
- CATransaction.commit()
- }
- }
-
- @objc func changeTheming() {
-
- if #available(iOS 13.0, *) {
-
- var navBarAppearance = UINavigationBarAppearance()
-
- navBarAppearance.configureWithOpaqueBackground()
- navBarAppearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.shared.textView]
- navBarAppearance.backgroundColor = NCBrandColor.shared.backgroundView
-
- navBarAppearance = UINavigationBarAppearance()
-
- navBarAppearance.configureWithOpaqueBackground()
- navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.shared.textView]
- navBarAppearance.backgroundColor = NCBrandColor.shared.tabBar
- navigationBar.scrollEdgeAppearance = navBarAppearance
- navigationBar.standardAppearance = navBarAppearance
-
- } else {
-
- navigationBar.barStyle = .default
- navigationBar.barTintColor = NCBrandColor.shared.backgroundView
- navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.shared.textView]
- navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.shared.textView]
- }
-
- navigationBar.tintColor = NCBrandColor.shared.brandElement
- navigationBar.setNeedsLayout()
- }
- }
|