<commit_before>//
//  ContainerViewController.swift
//  OrthodoxCalendar
//
//  Created by <NAME> on 9/10/16.
//  Copyright © 2016 Appose Studio Inc. All rights reserved.
//

import UIKit

//Container View Controller, which swaps between two view controllers
//based on: http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers
//
class ContainerViewController: UIViewController {

    static let SegueIdentifierFirst = "embedFirst"
    static let SegueIdentifierSecond = "embedSecond"
    static let SegueIdentifierEmpty = "empty"

    internal var currentSegueIdentifier: String = "empty"

    override func viewDidLoad() {
        super.viewDidLoad()

        if self.currentSegueIdentifier == ContainerViewController.SegueIdentifierEmpty {
            self.currentSegueIdentifier = ContainerViewController.SegueIdentifierFirst
        }

        self.performSegue(withIdentifier: self.currentSegueIdentifier, sender: nil)
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == ContainerViewController.SegueIdentifierFirst {
            if !self.childViewControllers.isEmpty {
                self.swapFromViewController(fromViewController: self.childViewControllers[0], toViewController: segue.destination, offset: 44.0)
            } else {
                segue.destination.view.frame = CGRect(origin: CGPoint.zero, size: self.view.frame.size)
                self.swapFromViewController(fromViewController: nil, toViewController: segue.destination, offset: 44.0)
            }
        } else if segue.identifier == ContainerViewController.SegueIdentifierSecond {
            if !self.childViewControllers.isEmpty {
                self.swapFromViewController(fromViewController: self.childViewControllers[0], toViewController: segue.destination, offset: 44.0)
            } else {
                segue.destination.view.frame = CGRect(origin: CGPoint.zero, size: self.view.frame.size)
                self.swapFromViewController(fromViewController: nil, toViewController: segue.destination, offset: 44.0)
            }
        }
    }

    func swapFromViewController(fromViewController: UIViewController?, toViewController: UIViewController, offset: CGFloat) -> Void {

        toViewController.view.frame = CGRect(x: 0, y: 0 + offset, width: self.view.frame.size.width, height: self.view.frame.size.height - offset)

        // DEBUG
        print("Frame: \(toViewController.view.frame)")

        if let fromViewController = fromViewController {
            fromViewController.willMove(toParentViewController: nil)
            addChildViewController(toViewController)

            transition(from: fromViewController, to: toViewController, duration: 1.0,
                       options: UIViewAnimationOptions.transitionCrossDissolve, animations: nil) { (finished) in
                        fromViewController.removeFromParentViewController()
                        toViewController.didMove(toParentViewController: self)
            }
        } else {
            addChildViewController(toViewController)
            self.view.addSubview(toViewController.view)
            toViewController.didMove(toParentViewController: self)
        }

    }

    func swapViewControllers() -> Void {
        if self.currentSegueIdentifier == ContainerViewController.SegueIdentifierFirst {
            self.currentSegueIdentifier = ContainerViewController.SegueIdentifierSecond
        } else {
            self.currentSegueIdentifier = ContainerViewController.SegueIdentifierFirst
        }

        self.performSegue(withIdentifier: self.currentSegueIdentifier, sender: nil)
    }
    
}<commit_msg>Removing unnecessary self.<commit_after>//
//  ContainerViewController.swift
//  OrthodoxCalendar
//
//  Created by <NAME> on 9/10/16.
//  Copyright © 2016 Appose Studio Inc. All rights reserved.
//

import UIKit

//Container View Controller, which swaps between two view controllers
//based on: http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers
//
class ContainerViewController: UIViewController {

    static let SegueIdentifierFirst = "embedFirst"
    static let SegueIdentifierSecond = "embedSecond"
    static let SegueIdentifierEmpty = "empty"

    internal var currentSegueIdentifier: String = "empty"

    override func viewDidLoad() {
        super.viewDidLoad()

        if currentSegueIdentifier == ContainerViewController.SegueIdentifierEmpty {
            currentSegueIdentifier = ContainerViewController.SegueIdentifierFirst
        }

        performSegue(withIdentifier: currentSegueIdentifier, sender: nil)
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == ContainerViewController.SegueIdentifierFirst {
            if !childViewControllers.isEmpty {
                swapFromViewController(fromViewController: childViewControllers[0], toViewController: segue.destination, offset: 44.0)
            } else {
                segue.destination.view.frame = CGRect(origin: CGPoint.zero, size: view.frame.size)
                swapFromViewController(fromViewController: nil, toViewController: segue.destination, offset: 44.0)
            }
        } else if segue.identifier == ContainerViewController.SegueIdentifierSecond {
            if !childViewControllers.isEmpty {
                swapFromViewController(fromViewController: childViewControllers[0], toViewController: segue.destination, offset: 44.0)
            } else {
                segue.destination.view.frame = CGRect(origin: CGPoint.zero, size: view.frame.size)
                swapFromViewController(fromViewController: nil, toViewController: segue.destination, offset: 44.0)
            }
        }
    }

    func swapFromViewController(fromViewController: UIViewController?, toViewController: UIViewController, offset: CGFloat) -> Void {

        toViewController.view.frame = CGRect(x: 0, y: 0 + offset, width: view.frame.size.width, height: view.frame.size.height - offset)

        // DEBUG
        print("Frame: \(toViewController.view.frame)")

        if let fromViewController = fromViewController {
            fromViewController.willMove(toParentViewController: nil)
            addChildViewController(toViewController)

            transition(from: fromViewController, to: toViewController, duration: 1.0,
                       options: UIViewAnimationOptions.transitionCrossDissolve, animations: nil) { (finished) in
                        fromViewController.removeFromParentViewController()
                        toViewController.didMove(toParentViewController: self)
            }
        } else {
            addChildViewController(toViewController)
            view.addSubview(toViewController.view)
            toViewController.didMove(toParentViewController: self)
        }

    }

    func swapViewControllers() -> Void {
        if currentSegueIdentifier == ContainerViewController.SegueIdentifierFirst {
            currentSegueIdentifier = ContainerViewController.SegueIdentifierSecond
        } else {
            currentSegueIdentifier = ContainerViewController.SegueIdentifierFirst
        }

        performSegue(withIdentifier: currentSegueIdentifier, sender: nil)
    }
    
}
{'fraction_non_alphanumeric': 0.08233676975945017, 'fraction_numerical': 0.010446735395189003, 'mean_word_length': 2.9716157205240177, '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': '7632615', 'n_tokens_mistral': 1936, 'n_tokens_neox': 1734, 'n_words': 366}