<commit_before>//
//  DebugConfigurationManager.swift
//  Yoshi
//
//  Created by <NAME> on 12/22/15.
//  Copyright © 2015 Prolific Interactive. All rights reserved.
//

import UIKit

/// The configuration manager for the debug menu.
internal final class YoshiConfigurationManager {

    /// The default instance.
    static let sharedInstance = YoshiConfigurationManager()

    private var yoshiMenuItems = [YoshiMenu]()
    private var presentingWindow: UIWindow?

    /**
     Sets the debug options to use for presenting the debug menu.

     - parameter menuItems: The menu items for presentation.
     */
    func setupDebugMenuOptions(menuItems: [YoshiMenu]) {
        yoshiMenuItems = menuItems
    }

    /**
     Invokes the display of the debug menu.
     */
    func showDebugActionSheet() {
        guard presentingWindow == nil else {
            return
        }

        let navigationController = UINavigationController()
        let debugViewController = DebugViewController(options: yoshiMenuItems, completion: { [weak self] in
            self?.animate({
                    self?.presentingWindow?.alpha = 0.0
                }, completed: {
                    self?.presentingWindow = nil
            })
        })

        navigationController.setViewControllers([debugViewController], animated: false)

        let window = UIWindow()
        window.rootViewController = navigationController
        window.windowLevel = UIWindowLevelAlert
        presentingWindow = window

        window.makeKeyAndVisible()
        window.alpha = 0.0
        window.rootViewController?.view.layoutIfNeeded()
        animate {
            window.alpha = 1
        }
    }

    private func animate(animations: () -> Void) {
        animate(animations, completed: nil)
    }

    private func animate(animations: () -> Void, completed: ( () -> Void)?) {
        UIView.animateWithDuration(0.3, animations: {
                animations()<commit_msg>Made the debug window level to normal.<commit_after>//
//  DebugConfigurationManager.swift
//  Yoshi
//
//  Created by <NAME> on 12/22/15.
//  Copyright © 2015 Prolific Interactive. All rights reserved.
//

import UIKit

/// The configuration manager for the debug menu.
internal final class YoshiConfigurationManager {

    /// The default instance.
    static let sharedInstance = YoshiConfigurationManager()

    private var yoshiMenuItems = [YoshiMenu]()
    private var presentingWindow: UIWindow?

    /**
     Sets the debug options to use for presenting the debug menu.

     - parameter menuItems: The menu items for presentation.
     */
    func setupDebugMenuOptions(menuItems: [YoshiMenu]) {
        yoshiMenuItems = menuItems
    }

    /**
     Invokes the display of the debug menu.
     */
    func showDebugActionSheet() {
        guard presentingWindow == nil else {
            return
        }

        let navigationController = UINavigationController()
        let debugViewController = DebugViewController(options: yoshiMenuItems, completion: { [weak self] in
            self?.animate({
                    self?.presentingWindow?.alpha = 0.0
                }, completed: {
                    self?.presentingWindow = nil
            })
        })

        navigationController.setViewControllers([debugViewController], animated: false)

        let window = UIWindow()
        window.rootViewController = navigationController
        window.windowLevel = UIWindowLevelNormal
        presentingWindow = window

        window.makeKeyAndVisible()
        window.alpha = 0.0
        window.rootViewController?.view.layoutIfNeeded()
        animate {
            window.alpha = 1
        }
    }

    private func animate(animations: () -> Void) {
        animate(animations, completed: nil)
    }

    private func animate(animations: () -> Void, completed: ( () -> Void)?) {
        UIView.animateWithDuration(0.3, animations: {
                animations()
{'fraction_non_alphanumeric': 0.0901015228426396, 'fraction_numerical': 0.008629441624365483, 'mean_word_length': 2.2732558139534884, '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': '5925821', 'n_tokens_mistral': 1044, 'n_tokens_neox': 958, 'n_words': 271}