<commit_before>//
//  IntroductionViewController.swift
//  CharacterAdvisor
//
//  Created by <NAME> on 7/4/16.
//  Copyright © 2016 Pilgrimage Software. All rights reserved.
//

import UIKit


/**
 * A protocol defining the delegate methods for a conductor view.
 */
public protocol ConductorDelegate : class {

    /**
     * A method that is called when the conductor finishes, whether from skipping or making it all the way to the end.
     */
    func conductorControllerFinished(_ controller : ConductorViewController)

    /**
     * Method called when the user has tapped the "skip" button. The delegate should dismiss the conductor UI and
     * continue with the app.
     */
    func conductorController(_ controller : ConductorViewController, userWantsToSkipAtPage pageNumber : Int)

}

/**
 * The view controller that manages the entire conductor UI.
 */
public class ConductorViewController: UIViewController, UIPageViewControllerDelegate {

    // MARK: - Properties

    fileprivate var currentPage : Int = 0
    fileprivate var pageViewController : UIPageViewController!

    /**
     * Interface Builder property for the background image of the conductor view.
     */
    @IBOutlet open weak var backgroundImageView: UIImageView!

    /**
     * An optional delegate for the conductor.
     */
    public weak var delegate : ConductorDelegate?
    /**
     * The data source for the conductor. This should be set before the view is loaded.
     */
    public var dataSource : ConductorDataSource!
    /**
     * The image to use for the page view background.
     */
    public var backgroundImage : UIImage?


    // MARK: - Initialization

    override public func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        if let image = backgroundImage {
            self.backgroundImageView.image = image
        }
    }


    // MARK: - Responder chain methods

    /**
     * This method is called via the responder chain when the user wants to advance the UI to the next page.
     */
    public func advance(_ sender : AnyObject?) {

        if currentPage >= dataSource.pageData.count {
            self.delegate?.conductorControllerFinished(self)

            if let nav = self.navigationController {
                nav.popViewController(animated: true)
            }
            else {
                self.dismiss(animated: true) {
                }
            }
        }
        else {
            if let vc = dataSource.viewController(for: currentPage + 1, from: self.storyboard!) {
                self.pageViewController.setViewControllers([ vc ], direction: .forward, animated: true, completion: nil)
                currentPage += 1
            }
            else {
                // there are no view controllers left, so send a finish message
                self.delegate?.conductorControllerFinished(self)
            }
        }
    }

    /**
     * This method is called via the responder chain when the user wants to skip the UI.
     */
    public func skip(_ sender : AnyObject?) {

        self.delegate?.conductorController(self, userWantsToSkipAtPage: self.currentPage)

        if let nav = self.navigationController {
            nav.popViewController(animated: true)
        }
        else {
            self.dismiss(animated: true) {
            }
        }
    }


    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override public func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        if segue.identifier == "EmbedPageView",
            let vc = segue.destination as? UIPageViewController {
            vc.dataSource = self.dataSource
            vc.delegate = self

            self.pageViewController = vc

            if let cpv = vc.storyboard?.instantiateViewController(withIdentifier: "ConductorPageView") as? ConductorPageViewController,
                let data = self.dataSource.pageData.first {
                cpv.pageData = data
                vc.setViewControllers([ cpv ], direction: .forward, animated: true) { completed in }
            }
        }
    }


    // MARK: - Page view controller delegate methods

    @objc public func pageViewControllerSupportedInterfaceOrientations(_ pageViewController: UIPageViewController) -> UIInterfaceOrientationMask {
        return .all
    }

    @objc public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) {

        if let cc = pendingViewControllers.first as? ConductorPageViewController {
            currentPage = cc.pageNumber
        }
    }

    //    @objc func pageViewController(pageViewController: UIPageViewController, spineLocationForInterfaceOrientation orientation: UIInterfaceOrientation) -> UIPageViewControllerSpineLocation {
    //        return .None
    //    }

    @objc public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
        
    }
    
}
<commit_msg>Remove the empty completion callback.<commit_after>//
//  IntroductionViewController.swift
//  CharacterAdvisor
//
//  Created by <NAME> on 7/4/16.
//  Copyright © 2016 Pilgrimage Software. All rights reserved.
//

import UIKit


/**
 * A protocol defining the delegate methods for a conductor view.
 */
public protocol ConductorDelegate : class {

    /**
     * A method that is called when the conductor finishes, whether from skipping or making it all the way to the end.
     */
    func conductorControllerFinished(_ controller : ConductorViewController)

    /**
     * Method called when the user has tapped the "skip" button. The delegate should dismiss the conductor UI and
     * continue with the app.
     */
    func conductorController(_ controller : ConductorViewController, userWantsToSkipAtPage pageNumber : Int)

}

/**
 * The view controller that manages the entire conductor UI.
 */
public class ConductorViewController: UIViewController, UIPageViewControllerDelegate {

    // MARK: - Properties

    fileprivate var currentPage : Int = 0
    fileprivate var pageViewController : UIPageViewController!

    /**
     * Interface Builder property for the background image of the conductor view.
     */
    @IBOutlet open weak var backgroundImageView: UIImageView!

    /**
     * An optional delegate for the conductor.
     */
    public weak var delegate : ConductorDelegate?
    /**
     * The data source for the conductor. This should be set before the view is loaded.
     */
    public var dataSource : ConductorDataSource!
    /**
     * The image to use for the page view background.
     */
    public var backgroundImage : UIImage?


    // MARK: - Initialization

    override public func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        if let image = backgroundImage {
            self.backgroundImageView.image = image
        }
    }


    // MARK: - Responder chain methods

    /**
     * This method is called via the responder chain when the user wants to advance the UI to the next page.
     */
    public func advance(_ sender : AnyObject?) {

        if currentPage >= dataSource.pageData.count {
            self.delegate?.conductorControllerFinished(self)

            if let nav = self.navigationController {
                nav.popViewController(animated: true)
            }
            else {
                self.dismiss(animated: true) {
                }
            }
        }
        else {
            if let vc = dataSource.viewController(for: currentPage + 1, from: self.storyboard!) {
                self.pageViewController.setViewControllers([ vc ], direction: .forward, animated: true, completion: nil)
                currentPage += 1
            }
            else {
                // there are no view controllers left, so send a finish message
                self.delegate?.conductorControllerFinished(self)
            }
        }
    }

    /**
     * This method is called via the responder chain when the user wants to skip the UI.
     */
    public func skip(_ sender : AnyObject?) {

        self.delegate?.conductorController(self, userWantsToSkipAtPage: self.currentPage)

        if let nav = self.navigationController {
            nav.popViewController(animated: true)
        }
        else {
            self.dismiss(animated: true, completion: nil)
        }
    }


    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override public func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        if segue.identifier == "EmbedPageView",
            let vc = segue.destination as? UIPageViewController {
            vc.dataSource = self.dataSource
            vc.delegate = self

            self.pageViewController = vc

            if let cpv = vc.storyboard?.instantiateViewController(withIdentifier: "ConductorPageView") as? ConductorPageViewController,
                let data = self.dataSource.pageData.first {
                cpv.pageData = data
                vc.setViewControllers([ cpv ], direction: .forward, animated: true) { completed in }
            }
        }
    }


    // MARK: - Page view controller delegate methods

    @objc public func pageViewControllerSupportedInterfaceOrientations(_ pageViewController: UIPageViewController) -> UIInterfaceOrientationMask {
        return .all
    }

    @objc public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) {

        if let cc = pendingViewControllers.first as? ConductorPageViewController {
            currentPage = cc.pageNumber
        }
    }

    //    @objc func pageViewController(pageViewController: UIPageViewController, spineLocationForInterfaceOrientation orientation: UIInterfaceOrientation) -> UIPageViewControllerSpineLocation {
    //        return .None
    //    }

    @objc public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
        
    }
    
}

{'fraction_non_alphanumeric': 0.07379278012189405, 'fraction_numerical': 0.002062822315986873, 'mean_word_length': 2.4011479591836733, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '353229', 'n_tokens_mistral': 2783, 'n_tokens_neox': 2522, 'n_words': 866}