<commit_before>//
//  ViewController.swift
//  SoundCloudTransition
//
//  Created by xxxAIRINxxx on 2015/02/25.
//  Copyright (c) 2015 xxxAIRINxxx. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var imageView : UIImageView!
    @IBOutlet weak var button : UIButton!
    
    var animator : ARNTransitionAnimator!
    var modalVC : ModalViewController!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
        self.modalVC = storyboard.instantiateViewControllerWithIdentifier("ModalViewController") as? ModalViewController
        self.modalVC.modalPresentationStyle = .Custom
        
        self.setupAnimator()
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
        self.animator.interactiveType = .Present
    }
    
    @IBAction func tapButton(sender: UIButton) {
        self.animator.interactiveType = .None
        self.presentViewController(self.modalVC, animated: true, completion: nil)
    }

    func setupAnimator() {
        self.animator = ARNTransitionAnimator(operationType: .Present, fromVC: self, toVC: modalVC!)
        
        self.animator.presentationBeforeHandler = { [weak self] (containerView: UIView, transitionContext: UIViewControllerContextTransitioning) in
            
            containerView.addSubview(self!.modalVC.view)
            
            self!.modalVC.view.layoutIfNeeded()
            
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height
            self!.modalVC.tabBar!.alpha = 0.0
            self!.button!.alpha = 1.0
            self!.imageView!.alpha = 1.0
            self!.imageView!.transform = CGAffineTransformIdentity
        }
        
        self.animator.presentationCancelAnimationHandler = { [weak self] (containerView: UIView) in
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height
            self!.modalVC.tabBar!.alpha = 0.0
            self!.button!.alpha = 1.0
            self!.imageView!.alpha = 1.0
            self!.imageView!.transform = CGAffineTransformIdentity
        }
        
        self.animator.presentationAnimationHandler = { [weak self] (containerView: UIView, percentComplete: CGFloat) in
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight + containerViewHeight * percentComplete
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5 + 0.5 * percentComplete
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height - self!.modalVC.tabBar.frame.size.height * percentComplete
            self!.modalVC.tabBar.alpha = 1.0 * percentComplete
            self!.modalVC.containerView.alpha = 1.0 * percentComplete
            self!.button.alpha = 1.0 - 1.5 * percentComplete
            self!.imageView.alpha = 1.0 - 0.2 * percentComplete
            self!.imageView.transform = CGAffineTransformIdentity
            self!.imageView.transform = CGAffineTransformScale(self!.imageView.transform, 1.0 - 0.1 * percentComplete, 1.0 - 0.1 * percentComplete)
        }
        
        self.animator.dismissalCompletionHandler = { [weak self] (containerView: UIView, completeTransition: Bool) in
            self!.animator.interactiveType = .Present
        }
        
        self.animator.dismissalAnimationHandler = { [weak self] (containerView: UIView, percentComplete: CGFloat) in
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height
            self!.modalVC.tabBar.alpha = 0.0
            self!.button.alpha = 1.0
            self!.imageView.alpha = 1.0
            self!.imageView.transform = CGAffineTransformIdentity
        }
        
        self.modalVC.transitioningDelegate = self.animator
    }
}<commit_msg>refactoring<commit_after>//
//  ViewController.swift
//  SoundCloudTransition
//
//  Created by xxxAIRINxxx on 2015/02/25.
//  Copyright (c) 2015 xxxAIRINxxx. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var imageView : UIImageView!
    @IBOutlet weak var button : UIButton!
    
    var animator : ARNTransitionAnimator!
    var modalVC : ModalViewController!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
        self.modalVC = storyboard.instantiateViewControllerWithIdentifier("ModalViewController") as? ModalViewController
        self.modalVC.modalPresentationStyle = .Custom
        
        self.setupAnimator()
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
        self.animator.interactiveType = .Present
    }
    
    @IBAction func tapButton(sender: UIButton) {
        self.animator.interactiveType = .None
        self.presentViewController(self.modalVC, animated: true, completion: nil)
    }

    func setupAnimator() {
        self.animator = ARNTransitionAnimator(operationType: .Present, fromVC: self, toVC: modalVC!)
        
        // Present
        
        self.animator.presentationBeforeHandler = { [weak self] (containerView: UIView, transitionContext: UIViewControllerContextTransitioning) in
            
            containerView.addSubview(self!.modalVC.view)
            
            self!.modalVC.view.layoutIfNeeded()
            
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height
            self!.modalVC.tabBar!.alpha = 0.0
            self!.button!.alpha = 1.0
            self!.imageView!.alpha = 1.0
            self!.imageView!.transform = CGAffineTransformIdentity
        }
        
        self.animator.presentationCancelAnimationHandler = { [weak self] (containerView: UIView) in
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height
            self!.modalVC.tabBar!.alpha = 0.0
            self!.button!.alpha = 1.0
            self!.imageView!.alpha = 1.0
            self!.imageView!.transform = CGAffineTransformIdentity
        }
        
        self.animator.presentationAnimationHandler = { [weak self] (containerView: UIView, percentComplete: CGFloat) in
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight + containerViewHeight * percentComplete
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5 + 0.5 * percentComplete
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height - self!.modalVC.tabBar.frame.size.height * percentComplete
            self!.modalVC.tabBar.alpha = 1.0 * percentComplete
            self!.modalVC.containerView.alpha = 1.0 * percentComplete
            self!.button.alpha = 1.0 - 1.5 * percentComplete
            self!.imageView.alpha = 1.0 - 0.2 * percentComplete
            self!.imageView.transform = CGAffineTransformIdentity
            self!.imageView.transform = CGAffineTransformScale(self!.imageView.transform, 1.0 - 0.1 * percentComplete, 1.0 - 0.1 * percentComplete)
        }
        
        // Dismiss
        
        self.animator.dismissalAnimationHandler = { [weak self] (containerView: UIView, percentComplete: CGFloat) in
            let containerViewHeight = self!.modalVC.containerView.frame.size.height
            self!.modalVC.containerView.frame.origin.y = -containerViewHeight
            for subview in self!.modalVC.containerView.subviews as! [UIView] {
                subview.alpha = 0.5
            }
            
            self!.modalVC.tabBar.frame.origin.y = containerView.frame.size.height
            self!.modalVC.tabBar.alpha = 0.0
            self!.button.alpha = 1.0
            self!.imageView.alpha = 1.0
            self!.imageView.transform = CGAffineTransformIdentity
        }
        
        self.animator.dismissalCompletionHandler = { [weak self] (containerView: UIView, completeTransition: Bool) in
            self!.animator.interactiveType = .Present
        }
        
        self.modalVC.transitioningDelegate = self.animator
    }
}
{'fraction_non_alphanumeric': 0.09616542862878939, 'fraction_numerical': 0.012045773940975708, 'mean_word_length': 2.190201729106628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3857268', 'n_tokens_mistral': 2904, 'n_tokens_neox': 2687, 'n_words': 478}