 //
-//  JTSSloppyNavigationController.swift
-//  JTSSloppyNavigationController
+//  JTSSloppySwiping.swift
+//  JTSSloppySwiping
 //
 //  Created by Jared Sinclair on 8/1/15.
 //  Copyright © 2015 Nice Boy LLC. All rights reserved.
 //
 
 import UIKit
-import Darwin
+// import Darwin
 
 /**
 This is a convenience subclass, which relieves you of the burden of keeping a 
-strong reference to the required JTSSloppySwiping instance. You can use any 
+strong reference to the required SloppySwiping instance. You can use any 
 other navigation controller if you wish, but you'll be responsible for
-initializing JTSSloppySwiping and keeping a reference to it.
+initializing SloppySwiping and keeping a reference to it.
 */
-class JTSSloppyNavigationController: UINavigationController {
-    
-    private lazy var sloppySwiping: JTSSloppySwiping = {
-        return JTSSloppySwiping(navigationController: self)
+@objc(JTSSloppyNavigationController)
+class SloppyNavigationController: UINavigationController {
+    
+    fileprivate lazy var sloppySwiping: SloppySwiping = {
+        return SloppySwiping(navigationController: self)
     }()
     
-    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
+    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
         super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
         self.delegate = self.sloppySwiping
     }

        container.addSubview(self.frontContainerView)
    }
    
    func updateViewsWithTranslation(translation: CGPoint) {
        
        guard let transitionContext = self.activeContext,
            container = transitionContext.containerView(),
            toView = transitionContext.viewForKey(UITransitionContextToViewKey) else {
                return
        }
        
        let maxDistance = container.bounds.size.width
        let percent = self.percentDismissedForTranslation(translation, container: container)


    
}

private let defaultCancelPopDuration: TimeInterval = 0.16
private let maxBackViewTranslationPercentage: CGFloat = 0.30
private let minimumDismissalPercentage: CGFloat = 0.5
private let minimumThresholdVelocity: CGFloat = 100.0

private class InteractivePopAnimator: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerInteractiveTransitioning {
    
    var translation: CGPoint = CGPoint.zero {
        didSet {
            self.updateViewsWithTranslation(translation)
        }
    }
    
    fileprivate var activeContext: UIViewControllerContextTransitioning? = nil
    fileprivate var activeDuration: TimeInterval? = nil
    
    fileprivate let backOverlayView: UIView = {
        let backOverlayView = UIView(frame: CGRect.zero)
        backOverlayView.backgroundColor = UIColor(white: 0.0, alpha: 0.1)
        backOverlayView.alpha = 1.0
        return backOverlayView
        }()
    
    fileprivate let frontContainerView: FrontContainerView = {
        return FrontContainerView(frame: CGRect.zero)
    }()
    
    // MARK: UIViewControllerAnimatedTransitioning
    
    @objc func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        if let duration = self.activeDuration {
            return duration
        }
        return 0
    }
    
    @objc func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        fatalError("this class should not be used for non-interactive transitions")
    }
    
    // MARK: UIViewControllerInteractiveTransitioning
    
    @objc func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning) {
        self.activeContext = transitionContext
        self.prepForPop()
    }
