 //  Created by Nikita Ermolenko on 29/09/2017.
 //
 
-import Foundation
 import UIKit
 
 protocol Closable: class {

        }
    }

    func close() {
        if let closableTransition = openTransition {
            close(viewController, transition: closableTransition)
        }
    }
    
    func open(_ presentedViewController: UIViewController?, transition: Transition) {
        guard let presentedViewController = presentedViewController else {
            assertionFailure("Can't present a nil view controller.")
            return
        }
        animator = nil

        switch transition {
        case let .push(parameters):
            if let animator = parameters.animator {
                self.animator = animator
                navigationController?.delegate = self
            }
            navigationController?.pushViewController(presentedViewController, animated: parameters.animated)
        case let .modal(parameters):
            if let animator = parameters.animator {
                self.animator = animator
                presentedViewController.transitioningDelegate = self
            }
            viewController?.present(presentedViewController, animated: parameters.animated, completion: nil)
        }
    }
    
    func close(_ closedViewController: UIViewController?, transition: Transition) {
        guard let closedViewController = closedViewController else {
            assertionFailure("Can't close a nil view controller.")
            return
        }
        switch transition {
        case let .push(parameters):
            navigationController?.popViewController(animated: parameters.animated)
        case let .modal(parameters):
            closedViewController.dismiss(animated: parameters.animated) { [unowned self] in
                self.animator = nil
            }
        }
    }
    
    // MARK: - UINavigationControllerDelegate
    
    func navigationController(_ navigationController: UINavigationController,

}

protocol RouterProtocol: class {

    associatedtype V: UIViewController
    weak var viewController: V? { get }
    
