<commit_before>//
//  ElloNavigationController.swift
//  Ello
//
//  Created by Sean on 1/19/15.
//  Copyright (c) 2015 Ello. All rights reserved.
//

import KINWebBrowser

public let externalWebNotification = TypedNotification<String>(name: "externalWebNotification")

public class ElloNavigationController: UINavigationController, UIGestureRecognizerDelegate {

    var interactionController: UIPercentDrivenInteractiveTransition?
    var externalWebObserver: NotificationObserver?
    let externalWebController: UINavigationController = KINWebBrowserViewController.navigationControllerWithWebBrowser()
    var rootViewControllerName : String?
    public var currentUser : User? {
        didSet { didSetCurrentUser() }
    }
    var profileResponseConfig: ResponseConfig?

    var backGesture: UIScreenEdgePanGestureRecognizer?

    enum RootViewControllers: String {
        case Notifications = "NotificationsViewController"
        case Profile = "ProfileViewController"
        case Omnibar = "OmnibarViewController"
        case Discover = "DiscoverViewController"

        func controllerInstance(user: User, responseConfig: ResponseConfig) -> BaseElloViewController {
            switch self {
            case Notifications: return NotificationsViewController()
            case Profile: return ProfileViewController(user: user, responseConfig: responseConfig)
            case Omnibar: return OmnibarViewController()
            case Discover: return DiscoverViewController()
            }
        }
    }

    func setProfileData(currentUser: User, responseConfig: ResponseConfig) {
        self.currentUser = currentUser
        self.profileResponseConfig = responseConfig
        if self.viewControllers.count == 0 {
            if let rootViewControllerName = rootViewControllerName {
                if let controller = RootViewControllers(rawValue:rootViewControllerName)?.controllerInstance(currentUser, responseConfig: responseConfig) {
                    controller.currentUser = currentUser
                    self.viewControllers = [controller]
                }
            }
        }
    }

    func didSetCurrentUser() {
        if self.viewControllers.count > 0 {
            var controllers = self.viewControllers as! [ControllerThatMightHaveTheCurrentUser]
            for controller in controllers {
                controller.currentUser = currentUser
            }
        }
    }

    override public func viewDidLoad() {
        super.viewDidLoad()
        self.setNavigationBarHidden(true, animated: false)

        transitioningDelegate = self
        delegate = self

        backGesture = UIScreenEdgePanGestureRecognizer(target: self, action: Selector("handleBackGesture:"))
        backGesture.map(self.view.addGestureRecognizer)

        externalWebObserver = NotificationObserver(notification: externalWebNotification) { url in
            self.showExternalWebView(url)
        }
    }

    func showExternalWebView(url: String) {
        Tracker.sharedTracker.screenAppeared("Web View: \(url)")
        presentViewController(externalWebController, animated: true, completion: nil)
        if let externalWebView = externalWebController.rootWebBrowser() {
            let xButton = UIBarButtonItem(title: "\u{2573}", style: UIBarButtonItemStyle.Done, target: externalWebView, action: Selector("doneButtonPressed:"))
            externalWebView.navigationItem.setRightBarButtonItem(xButton, animated: false)
            externalWebView.tintColor = UIColor.greyA()
            externalWebView.loadURLString(url)
        }
    }

    func handleBackGesture(gesture: UIScreenEdgePanGestureRecognizer) {
        let percentThroughView = gesture.percentageThroughView(gesture.edges)

        switch gesture.state {
        case .Began:
            interactionController = UIPercentDrivenInteractiveTransition()
            topViewController.backGestureAction()
        case .Changed:
            interactionController?.updateInteractiveTransition(percentThroughView)
        case .Ended, .Cancelled:
            if percentThroughView > 0.5 {
                interactionController?.finishInteractiveTransition()
            } else {
                interactionController?.cancelInteractiveTransition()
            }
            interactionController = nil
        default:
            interactionController = nil
        }
    }

}
<commit_msg>Black X on web browser<commit_after>//
//  ElloNavigationController.swift
//  Ello
//
//  Created by Sean on 1/19/15.
//  Copyright (c) 2015 Ello. All rights reserved.
//

import KINWebBrowser

public let externalWebNotification = TypedNotification<String>(name: "externalWebNotification")

public class ElloNavigationController: UINavigationController, UIGestureRecognizerDelegate {

    var interactionController: UIPercentDrivenInteractiveTransition?
    var externalWebObserver: NotificationObserver?
    let externalWebController: UINavigationController = KINWebBrowserViewController.navigationControllerWithWebBrowser()
    var rootViewControllerName : String?
    public var currentUser : User? {
        didSet { didSetCurrentUser() }
    }
    var profileResponseConfig: ResponseConfig?

    var backGesture: UIScreenEdgePanGestureRecognizer?

    enum RootViewControllers: String {
        case Notifications = "NotificationsViewController"
        case Profile = "ProfileViewController"
        case Omnibar = "OmnibarViewController"
        case Discover = "DiscoverViewController"

        func controllerInstance(user: User, responseConfig: ResponseConfig) -> BaseElloViewController {
            switch self {
            case Notifications: return NotificationsViewController()
            case Profile: return ProfileViewController(user: user, responseConfig: responseConfig)
            case Omnibar: return OmnibarViewController()
            case Discover: return DiscoverViewController()
            }
        }
    }

    func setProfileData(currentUser: User, responseConfig: ResponseConfig) {
        self.currentUser = currentUser
        self.profileResponseConfig = responseConfig
        if self.viewControllers.count == 0 {
            if let rootViewControllerName = rootViewControllerName {
                if let controller = RootViewControllers(rawValue:rootViewControllerName)?.controllerInstance(currentUser, responseConfig: responseConfig) {
                    controller.currentUser = currentUser
                    self.viewControllers = [controller]
                }
            }
        }
    }

    func didSetCurrentUser() {
        if self.viewControllers.count > 0 {
            var controllers = self.viewControllers as! [ControllerThatMightHaveTheCurrentUser]
            for controller in controllers {
                controller.currentUser = currentUser
            }
        }
    }

    override public func viewDidLoad() {
        super.viewDidLoad()
        self.setNavigationBarHidden(true, animated: false)

        transitioningDelegate = self
        delegate = self

        backGesture = UIScreenEdgePanGestureRecognizer(target: self, action: Selector("handleBackGesture:"))
        backGesture.map(self.view.addGestureRecognizer)

        externalWebObserver = NotificationObserver(notification: externalWebNotification) { url in
            self.showExternalWebView(url)
        }
    }

    func showExternalWebView(url: String) {
        Tracker.sharedTracker.screenAppeared("Web View: \(url)")
        presentViewController(externalWebController, animated: true, completion: nil)
        if let externalWebView = externalWebController.rootWebBrowser() {
            let xButton = UIBarButtonItem(title: "\u{2573}", style: UIBarButtonItemStyle.Done, target: externalWebView, action: Selector("doneButtonPressed:"))
            externalWebView.navigationItem.rightBarButtonItem?.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.blackColor()], forState: UIControlState.Normal)
            externalWebView.tintColor = UIColor.greyA()
            externalWebView.loadURLString(url)
        }
    }

    func handleBackGesture(gesture: UIScreenEdgePanGestureRecognizer) {
        let percentThroughView = gesture.percentageThroughView(gesture.edges)

        switch gesture.state {
        case .Began:
            interactionController = UIPercentDrivenInteractiveTransition()
            topViewController.backGestureAction()
        case .Changed:
            interactionController?.updateInteractiveTransition(percentThroughView)
        case .Ended, .Cancelled:
            if percentThroughView > 0.5 {
                interactionController?.finishInteractiveTransition()
            } else {
                interactionController?.cancelInteractiveTransition()
            }
            interactionController = nil
        default:
            interactionController = nil
        }
    }

}

{'fraction_non_alphanumeric': 0.07010611876270038, 'fraction_numerical': 0.0038383382253330323, 'mean_word_length': 2.9129858657243815, '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': '4223571', 'n_tokens_mistral': 2245, 'n_tokens_neox': 2122, 'n_words': 447}