         
     }
     
-    func finishWithTranslation(translation: CGPoint, velocity: CGPoint, completion: () -> Void) {
+    func finishWithTranslation(_ translation: CGPoint, velocity: CGPoint, completion: @escaping () -> Void) {
         
         guard let transitionContext = self.activeContext,
-            container = transitionContext.containerView(),
-            fromView = transitionContext.viewForKey(UITransitionContextFromViewKey),
-            toView = transitionContext.viewForKey(UITransitionContextToViewKey) else {
+            let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from),
+            let toView = transitionContext.view(forKey: UITransitionContextViewKey.to) else {
                 return
         }
         
+        let container = transitionContext.containerView
+        
         let maxDistance = container.bounds.size.width
-        let duration: NSTimeInterval
+        let duration: TimeInterval
 
         // Like a push mower, this gesture completion feels more
         // comfortable with a little added velocity.

    func prepForPop() {
        
        guard let transitionContext = self.activeContext,
            container = transitionContext.containerView(),
            fromView = transitionContext.viewForKey(UITransitionContextFromViewKey),
            toView = transitionContext.viewForKey(UITransitionContextToViewKey) else {
                return
        }
        
        let containerBounds = container.bounds
        
        self.frontContainerView.frame = containerBounds

        
    }
    
    func percentDismissedForTranslation(_ translation: CGPoint, container: UIView) -> CGFloat {
        let maxDistance = container.bounds.size.width
        return (min(maxDistance, max(0, translation.x))) / maxDistance
    }
    
    func durationForDistance(distance d: CGFloat, velocity v: CGFloat) -> TimeInterval {
        let minDuration: CGFloat = 0.08
        let maxDuration: CGFloat = 0.4
        return (TimeInterval)(max(min(maxDuration, d / v), minDuration))
    }
    
}

private class FrontContainerView: UIView {
    
    fileprivate let dropShadowView: UIView
    
    override init(frame: CGRect) {
        self.dropShadowView = FrontContainerView.newDropShadowView()
