TSBaseNavigationC.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // TSBaseNavigationC.swift
  3. // TSLiveWallpaper
  4. //
  5. // Created by 100Years on 2024/12/20.
  6. //
  7. import UIKit
  8. open class TSBaseNavigationC: UINavigationController, UIGestureRecognizerDelegate, UINavigationControllerDelegate, UINavigationBarDelegate {
  9. // /// Whether to use system pop gesture. If false, full-screen pop gesture will be set.
  10. // static let useSystemGesture: Bool = false
  11. // /// Whether to enable global pop gestures. The default is true.
  12. // static let popGestureEnabled: Bool = true
  13. //
  14. // private var vcsDic: [String: Bool] = [:]
  15. open override func viewDidLoad() {
  16. super.viewDidLoad()
  17. configureNavigationBar()
  18. // configureNavigationGestures()
  19. view.backgroundColor = .clear
  20. interactivePopGestureRecognizer?.isEnabled = true;
  21. }
  22. private func configureNavigationBar() {
  23. self.navigationBar.isHidden = true
  24. }
  25. //
  26. // private func configureNavigationGestures() {
  27. // vcsDic = [:]
  28. // self.interactivePopGestureRecognizer?.delegate = self
  29. // }
  30. //
  31. // // Override pushViewController to initialize interactive pop gesture here.
  32. // override func pushViewController(_ viewController: UIViewController, animated: Bool) {
  33. // // Hide bottom bar only for the first pushed view controller
  34. // viewController.hidesBottomBarWhenPushed = self.viewControllers.count == 1
  35. // super.pushViewController(viewController, animated: animated)
  36. // self.interactivePopGestureRecognizer?.isEnabled = TSBaseNavigationC.popGestureEnabled
  37. // }
  38. //
  39. // // MARK: - UIGestureRecognizerDelegate
  40. //
  41. // func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
  42. // // Disable pop gesture if it's the root view controller
  43. // if self.viewControllers.count == 1 {
  44. // return false
  45. // }
  46. // let vcKey = vcKeyFromVC(self.topViewController)
  47. // if let vcKey = vcKey, let isEnabled = vcsDic[vcKey] {
  48. // return isEnabled
  49. // }
  50. // return self.interactivePopGestureRecognizer?.isEnabled ?? true
  51. // }
  52. //
  53. // // MARK: - UINavigationControllerDelegate
  54. //
  55. // func navigationController(_ navigationController: UINavigationController,
  56. // willShow viewController: UIViewController,
  57. // animated: Bool) {
  58. // if #available(iOS 10.0, *) {
  59. // viewController.transitionCoordinator?.notifyWhenInteractionChanges { context in
  60. // if context.isCancelled { return }
  61. // debugPrint("notifyWhenInteractionChanges context.isCancelled=\(context.isCancelled)")
  62. // }
  63. // }
  64. // }
  65. //
  66. // func navigationController(_ navigationController: UINavigationController,
  67. // didShow viewController: UIViewController,
  68. // animated: Bool) {
  69. // let vcKey = vcKeyFromVC(viewController)
  70. // if let vcKey = vcKey, vcsDic[vcKey] == nil {
  71. // // Save pop gesture enabled value for each child view controller
  72. // vcsDic[vcKey] = self.interactivePopGestureRecognizer?.isEnabled ?? true
  73. // }
  74. // }
  75. //
  76. // // MARK: - UINavigationBarDelegate
  77. //
  78. // func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {
  79. // return true
  80. // }
  81. //
  82. // // MARK: - Convenience Methods
  83. //
  84. // private func vcKeyFromVC(_ viewController: UIViewController?) -> String? {
  85. // guard let viewController = viewController else { return nil }
  86. // return String(describing: type(of: viewController))
  87. // }
  88. //
  89. // func setSpecifiedViewControllerInteractivePopGestureEnabled(_ enabled: Bool) {
  90. // let vcKey = vcKeyFromVC(self.topViewController)
  91. // if let vcKey = vcKey {
  92. // vcsDic[vcKey] = enabled
  93. // }
  94. // }
  95. //
  96. // // MARK: - Status Bar
  97. //
  98. // override var childForStatusBarStyle: UIViewController? {
  99. // return self.topViewController
  100. // }
  101. //
  102. // deinit {
  103. //// debugPrint("TGRootNavigationController deinitialized")
  104. // }
  105. }