<commit_before>//
//  Created by <NAME> on 2/25/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

/**
 System Flip Animator - To support Flip animation (Four flip directions supported: left, right, top, bottom)
 */
public class SystemFlipAnimator: NSObject, AnimatedTransitioning {
  // MARK: - AnimatorProtocol
  public var transitionAnimationType: TransitionAnimationType
  public var transitionDuration: Duration = defaultTransitionDuration
  public var reverseAnimationType: TransitionAnimationType?
  public var interactiveGestureType: InteractiveGestureType?

  // MARK: - private
  private var fromDirection: TransitionFromDirection
  private var animationOption: UIViewAnimationOptions
  
  init(fromDirection: TransitionFromDirection, transitionDuration: Duration) {
    self.fromDirection = fromDirection
    self.transitionDuration = transitionDuration
    
    switch fromDirection {
    case .Left:
      self.transitionAnimationType = .SystemFlip(direction: .Left)
      self.reverseAnimationType = .SystemFlip(direction: .Right)
      self.animationOption = .TransitionFlipFromLeft
    case .Right:
      self.transitionAnimationType = .SystemFlip(direction: .Right)
      self.reverseAnimationType = .SystemFlip(direction: .Left)
      self.animationOption = .TransitionFlipFromRight
    case .Top:
      self.transitionAnimationType = .SystemFlip(direction: .Top)
      self.reverseAnimationType = .SystemFlip(direction: .Bottom)
      self.animationOption = .TransitionFlipFromTop
    case .Bottom:
      self.transitionAnimationType = .SystemFlip(direction: .Bottom)
      self.reverseAnimationType = .SystemFlip(direction: .Top)
      self.animationOption = .TransitionFlipFromBottom
    }
    
    super.init()
  }
}

extension SystemFlipAnimator: UIViewControllerAnimatedTransitioning {
  public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
    return retrieveTransitionDuration(transitionContext)
  }
  
  public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
    let (tempFromView, tempToView, tempContainerView) = retrieveViews(transitionContext)
    guard let fromView = tempFromView, toView = tempToView, _ = tempContainerView else {
      transitionContext.completeTransition(true)
      return
    }
    
    UIView.transitionFromView(fromView, toView: toView,
      duration: transitionDuration(transitionContext), options: animationOption,
      completion: { _ in
        transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
      }
    )
  }
}<commit_msg>Make FlipAnimator use CA transition method<commit_after>//
//  Created by <NAME> on 2/25/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

/**
 System Flip Animator - To support Flip animation (Four flip directions supported: left, right, top, bottom)
 */
public class SystemFlipAnimator: NSObject, AnimatedTransitioning {
  // MARK: - AnimatorProtocol
  public var transitionAnimationType: TransitionAnimationType
  public var transitionDuration: Duration = defaultTransitionDuration
  public var reverseAnimationType: TransitionAnimationType?
  public var interactiveGestureType: InteractiveGestureType?

  // MARK: - private
  private var fromDirection: TransitionFromDirection
  private var animationOption: UIViewAnimationOptions
  
  init(fromDirection: TransitionFromDirection, transitionDuration: Duration) {
    self.fromDirection = fromDirection
    self.transitionDuration = transitionDuration
    
    switch fromDirection {
    case .Left:
      self.transitionAnimationType = .SystemFlip(direction: .Left)
      self.reverseAnimationType = .SystemFlip(direction: .Right)
      self.animationOption = .TransitionFlipFromLeft
    case .Right:
      self.transitionAnimationType = .SystemFlip(direction: .Right)
      self.reverseAnimationType = .SystemFlip(direction: .Left)
      self.animationOption = .TransitionFlipFromRight
    case .Top:
      self.transitionAnimationType = .SystemFlip(direction: .Top)
      self.reverseAnimationType = .SystemFlip(direction: .Bottom)
      self.animationOption = .TransitionFlipFromTop
    case .Bottom:
      self.transitionAnimationType = .SystemFlip(direction: .Bottom)
      self.reverseAnimationType = .SystemFlip(direction: .Top)
      self.animationOption = .TransitionFlipFromBottom
    }
    
    super.init()
  }
}

extension SystemFlipAnimator: UIViewControllerAnimatedTransitioning {
  public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
    return retrieveTransitionDuration(transitionContext)
  }
  
  public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
    animateWithCATransition(transitionContext, type: SystemTransitionType.Flip, subtype: fromDirection.stringValue)
  }
}
{'fraction_non_alphanumeric': 0.07668711656441718, 'fraction_numerical': 0.0036809815950920245, 'mean_word_length': 4.410398230088496, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4316035', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1236, 'n_words': 293}