<commit_before>//
//  NavigationControllerDelegate.swift
//  AnimatedTabBar
//
//  Created by <NAME> on 24/12/2015.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit

//class NavigationControllerDelegate: NSObject, UINavigationControllerDelegate {
//    func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
//        return MoveTransitionAnimator()
//    }
//}

class TabBarControllerDelegate: NSObject, UITabBarControllerDelegate {
    @IBOutlet weak var tabBarController: UITabBarController!
    
    var lastSelectedIndex = 0
    
    func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return MoveTransitionAnimator(tabBarController: self.tabBarController, lastIndex: tabBarController.selectedIndex)
    }
    
    func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
        
    }
}

class MoveTransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {
    weak var transitionContext: UIViewControllerContextTransitioning?
    var tabBarController: UITabBarController!
    var lastIndex = 0
    
    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.4
    }
    
    init(tabBarController: UITabBarController, lastIndex: Int) {
        self.tabBarController = tabBarController
        self.lastIndex = lastIndex
    }
    
    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        self.transitionContext = transitionContext
        
        let containerView = transitionContext.containerView()
        let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)
        let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)
        
        containerView?.addSubview(toViewController!.view)
        
        var viewWidth = CGRectGetWidth(toViewController!.view.bounds)
        
        if tabBarController.selectedIndex < lastIndex {
            viewWidth = -viewWidth
        }
        
        toViewController!.view.transform = CGAffineTransformMakeTranslation(viewWidth, 0)
        
        UIView.animateWithDuration(self.transitionDuration((self.transitionContext)), delay: 0.0, usingSpringWithDamping: 1.2, initialSpringVelocity: 2.5, options: .TransitionNone, animations: {
            toViewController!.view.transform = CGAffineTransformIdentity
            fromViewController!.view.transform = CGAffineTransformMakeTranslation(-viewWidth, 0)
            }, completion: { _ in
                self.transitionContext?.completeTransition(!self.transitionContext!.transitionWasCancelled())
                fromViewController!.view.transform = CGAffineTransformIdentity
        })
    }
}
<commit_msg>Removed commented out NavigationControllerDelegate<commit_after>//
//  NavigationControllerDelegate.swift
//  AnimatedTabBar
//
//  Created by <NAME> on 24/12/2015.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit

class TabBarControllerDelegate: NSObject, UITabBarControllerDelegate {
    @IBOutlet weak var tabBarController: UITabBarController!
    
    var lastSelectedIndex = 0
    
    func tabBarController(tabBarController: UITabBarController, animationControllerForTransitionFromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return MoveTransitionAnimator(tabBarController: self.tabBarController, lastIndex: tabBarController.selectedIndex)
    }
    
    func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
        
    }
}

class MoveTransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {
    weak var transitionContext: UIViewControllerContextTransitioning?
    var tabBarController: UITabBarController!
    var lastIndex = 0
    
    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.4
    }
    
    init(tabBarController: UITabBarController, lastIndex: Int) {
        self.tabBarController = tabBarController
        self.lastIndex = lastIndex
    }
    
    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        self.transitionContext = transitionContext
        
        let containerView = transitionContext.containerView()
        let fromViewController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)
        let toViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)
        
        containerView?.addSubview(toViewController!.view)
        
        var viewWidth = CGRectGetWidth(toViewController!.view.bounds)
        
        if tabBarController.selectedIndex < lastIndex {
            viewWidth = -viewWidth
        }
        
        toViewController!.view.transform = CGAffineTransformMakeTranslation(viewWidth, 0)
        
        UIView.animateWithDuration(self.transitionDuration((self.transitionContext)), delay: 0.0, usingSpringWithDamping: 1.2, initialSpringVelocity: 2.5, options: .TransitionNone, animations: {
            toViewController!.view.transform = CGAffineTransformIdentity
            fromViewController!.view.transform = CGAffineTransformMakeTranslation(-viewWidth, 0)
            }, completion: { _ in
                self.transitionContext?.completeTransition(!self.transitionContext!.transitionWasCancelled())
                fromViewController!.view.transform = CGAffineTransformIdentity
        })
    }
}

{'fraction_non_alphanumeric': 0.06822321576419937, 'fraction_numerical': 0.007948335817188276, 'mean_word_length': 3.926590538336052, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6881737', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1414, 'n_words': 270}