//
//  TSBaseNavigationC.swift
//  TSLiveWallpaper
//
//  Created by 100Years on 2024/12/20.
//

import UIKit

class TSBaseNavigationC: UINavigationController, UIGestureRecognizerDelegate, UINavigationControllerDelegate, UINavigationBarDelegate {

//    /// Whether to use system pop gesture. If false, full-screen pop gesture will be set.
//    static let useSystemGesture: Bool = false
//    /// Whether to enable global pop gestures. The default is true.
//    static let popGestureEnabled: Bool = true
//
//    private var vcsDic: [String: Bool] = [:]

    override func viewDidLoad() {
        super.viewDidLoad()
        configureNavigationBar()
//        configureNavigationGestures()
        view.backgroundColor = .clear
        interactivePopGestureRecognizer?.isEnabled = true;
    }

    private func configureNavigationBar() {
        self.navigationBar.isHidden = true
    }
//
//    private func configureNavigationGestures() {
//        vcsDic = [:]
//        self.interactivePopGestureRecognizer?.delegate = self
//    }
//
//    // Override pushViewController to initialize interactive pop gesture here.
//    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
//        // Hide bottom bar only for the first pushed view controller
//        viewController.hidesBottomBarWhenPushed = self.viewControllers.count == 1
//        super.pushViewController(viewController, animated: animated)
//        self.interactivePopGestureRecognizer?.isEnabled = TSBaseNavigationC.popGestureEnabled
//    }
//
//    // MARK: - UIGestureRecognizerDelegate
//
//    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
//        // Disable pop gesture if it's the root view controller
//        if self.viewControllers.count == 1 {
//            return false
//        }
//        let vcKey = vcKeyFromVC(self.topViewController)
//        if let vcKey = vcKey, let isEnabled = vcsDic[vcKey] {
//            return isEnabled
//        }
//        return self.interactivePopGestureRecognizer?.isEnabled ?? true
//    }
//
//    // MARK: - UINavigationControllerDelegate
//
//    func navigationController(_ navigationController: UINavigationController,
//                              willShow viewController: UIViewController,
//                              animated: Bool) {
//        if #available(iOS 10.0, *) {
//            viewController.transitionCoordinator?.notifyWhenInteractionChanges { context in
//                if context.isCancelled { return }
//                debugPrint("notifyWhenInteractionChanges context.isCancelled=\(context.isCancelled)")
//            }
//        }
//    }
//
//    func navigationController(_ navigationController: UINavigationController,
//                              didShow viewController: UIViewController,
//                              animated: Bool) {
//        let vcKey = vcKeyFromVC(viewController)
//        if let vcKey = vcKey, vcsDic[vcKey] == nil {
//            // Save pop gesture enabled value for each child view controller
//            vcsDic[vcKey] = self.interactivePopGestureRecognizer?.isEnabled ?? true
//        }
//    }
//
//    // MARK: - UINavigationBarDelegate
//
//    func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {
//        return true
//    }
//
//    // MARK: - Convenience Methods
//
//    private func vcKeyFromVC(_ viewController: UIViewController?) -> String? {
//        guard let viewController = viewController else { return nil }
//        return String(describing: type(of: viewController))
//    }
//
//    func setSpecifiedViewControllerInteractivePopGestureEnabled(_ enabled: Bool) {
//        let vcKey = vcKeyFromVC(self.topViewController)
//        if let vcKey = vcKey {
//            vcsDic[vcKey] = enabled
//        }
//    }
//
//    // MARK: - Status Bar
//
//    override var childForStatusBarStyle: UIViewController? {
//        return self.topViewController
//    }
//
//    deinit {
////        debugPrint("TGRootNavigationController deinitialized")
//    }
}
