<commit_before>//
//  TranslationTransitioningController.swift
//
//  Created by <NAME> on 21/03/2016.
//  Copyright © 2016 BareFeetWare.
//  Free to use at your own risk, with acknowledgement to BareFeetWare.
//

import UIKit

class TranslationTransitioningController: NSObject, UIViewControllerTransitioningDelegate {

    // MARK: - Variables

    @IBInspectable var duration: NSTimeInterval = 0.3
    @IBInspectable var leftInset: CGFloat = 0.0
    @IBInspectable var rightInset: CGFloat = 0.0
    @IBInspectable var topInset: CGFloat = 0.0
    @IBInspectable var bottomInset: CGFloat = 0.0
    @IBInspectable var belowTopGuide: Bool = false
    var direction: Direction = .Left // Direction to which it presents. Dismiss direction defaults to opposite.

    @IBInspectable var direction_: Int {
        get {
            return direction.rawValue
        }
        set {
            direction = Direction(rawValue: newValue) ?? .Left
        }
    }

    // MARK: - Private functions

    private lazy var animationController: TranslationAnimationController  = {
        let animationController = TranslationAnimationController()
        animationController.duration = self.duration
        animationController.leftInset = self.leftInset
        animationController.rightInset = self.rightInset
        animationController.topInset = self.topInset
        animationController.bottomInset = self.bottomInset
        animationController.belowTopGuide = self.belowTopGuide
        animationController.direction = self.direction
        return animationController
    }()

    // MARK: - UIViewControllerTransitioningDelegate

    func animationControllerForPresentedController(
        presented: UIViewController,
        presentingController presenting: UIViewController,
                             sourceController source: UIViewController
        ) -> UIViewControllerAnimatedTransitioning?
    {
        let animationController = self.animationController
        animationController.isPresenting = true
        return animationController
    }

    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        let animationController = self.animationController
        animationController.isPresenting = false
        return animationController
    }

}

extension UIViewController {

    @IBOutlet var transitioningDelegateOutlet: NSObject? {
        get {
            return transitioningDelegate as? NSObject
        }
        set {
            transitioningDelegate = newValue as? UIViewControllerTransitioningDelegate
        }
    }

}
<commit_msg>Changing from lazy variable to standard variable and separating animationController customisations in separate function.<commit_after>//
//  TranslationTransitioningController.swift
//
//  Created by <NAME> on 21/03/2016.
//  Copyright © 2016 BareFeetWare.
//  Free to use at your own risk, with acknowledgement to BareFeetWare.
//

import UIKit

class TranslationTransitioningController: NSObject, UIViewControllerTransitioningDelegate {

    // MARK: - Variables

    @IBInspectable var duration: NSTimeInterval = 0.3
    @IBInspectable var leftInset: CGFloat = 0.0
    @IBInspectable var rightInset: CGFloat = 0.0
    @IBInspectable var topInset: CGFloat = 0.0
    @IBInspectable var bottomInset: CGFloat = 0.0
    @IBInspectable var belowTopGuide: Bool = false
    var direction: Direction = .Left // Direction to which it presents. Dismiss direction defaults to opposite.

    @IBInspectable var direction_: Int {
        get {
            return direction.rawValue
        }
        set {
            direction = Direction(rawValue: newValue) ?? .Left
        }
    }

    private let animationController = TranslationAnimationController()

    // MARK: - Private functions

    private func updateAnimationController() {
        animationController.duration = self.duration
        animationController.leftInset = self.leftInset
        animationController.rightInset = self.rightInset
        animationController.topInset = self.topInset
        animationController.bottomInset = self.bottomInset
        animationController.belowTopGuide = self.belowTopGuide
        animationController.direction = self.direction
    }

    // MARK: - UIViewControllerTransitioningDelegate

    func animationControllerForPresentedController(
        presented: UIViewController,
        presentingController presenting: UIViewController,
                             sourceController source: UIViewController
        ) -> UIViewControllerAnimatedTransitioning?
    {
        let animationController = self.animationController
        updateAnimationController()
        animationController.isPresenting = true
        return animationController
    }

    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        let animationController = self.animationController
        updateAnimationController()
        animationController.isPresenting = false
        return animationController
    }

}

extension UIViewController {

    @IBOutlet var transitioningDelegateOutlet: NSObject? {
        get {
            return transitioningDelegate as? NSObject
        }
        set {
            transitioningDelegate = newValue as? UIViewControllerTransitioningDelegate
        }
    }

}

{'fraction_non_alphanumeric': 0.06045386904761905, 'fraction_numerical': 0.00818452380952381, 'mean_word_length': 2.9624170965364773, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7592343', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1284, 'n_words': 332}