CNSlideBaseNavigationController.swift 1.51 KB
//
//  CNSlideBaseNavigationController.swift
//  metaCode
//
//  Created by zx on 2023/10/26.
//

import Foundation

class CNSlideBaseNavigationController: UINavigationController
    ,UIViewControllerTransitioningDelegate {
    var dismissClosure: (()->())?
    var cellType:CNLiveHomePageCellType = .course
    
    init(rootViewController: UIViewController,cellType:CNLiveHomePageCellType) {
        super.init(rootViewController: rootViewController)
        self.cellType = cellType

    }
        
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
        
    override func viewDidLoad() {
        super.viewDidLoad()
        modalPresentationStyle = .custom
        transitioningDelegate = self
    }

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return CNUpSlideAnimationTransition(animationType: .present, cellType: self.cellType)
    }
    
    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return CNUpSlideAnimationTransition(animationType:  .dismiss, cellType: self.cellType)
    }
    
    func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        return CNUpSlideCardPresentationController(presentedViewController: presented, presenting: presenting)
    }
}