<commit_before>//
//  KamaConfig.swift
//  KamaUIKit
//
//  Created by <NAME> on 13/02/16.
//  Copyright © 2016 1985. All rights reserved.
//

import Foundation
import UIKit


public class PineBaseViewController : UIViewController {
    
    override public func viewDidLoad() {
        super.viewDidLoad()
        determineBackButton()
    }
    
    override public func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
    }
    
    public func pushViewController(viewController: UIViewController){
        self.navigationController?.pushViewController(viewController, animated: true)
    }
    
    func determineBackButton(){
        let count = self.navigationController?.viewControllers.count
        var action = "openmenu:"
        
        if count > 1 {
            action = "goback:"
        }
        
        let icon = preferredBackButton()
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: icon, landscapeImagePhone: .None, style: .Plain, target: self, action: Selector(action))
    }
    
    func goback(sender: AnyObject? = nil){
        self.navigationController?.popViewControllerAnimated(true)
    }
    
    
    func openmenu(sender: AnyObject? = nil){
        let parent = self.parentViewController?.parentViewController as! PineMenuViewController
        parent.toggleMenu()
    }
    
    /* BUTTONS */
    func preferredBackButton() -> UIImage {
        let count = self.navigationController?.viewControllers.count
        let name = count <= 1 ? "menu" : "back"
        return (UIImage(named: name)?.imageWithRenderingMode(.AlwaysOriginal))!
    }
    
}<commit_msg>backbuttonitem<commit_after>//
//  KamaConfig.swift
//  KamaUIKit
//
//  Created by <NAME> on 13/02/16.
//  Copyright © 2016 1985. All rights reserved.
//

import Foundation
import UIKit


public class PineBaseViewController : UIViewController {
    
    override public func viewDidLoad() {
        super.viewDidLoad()
        determineBackButton()
    }
    
    override public func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
    }
    
    public func pushViewController(viewController: UIViewController){
        self.navigationController?.pushViewController(viewController, animated: true)
    }
    
    func determineBackButton(){
        self.navigationItem.leftBarButtonItem = preferredLeftBarButtonItem()
    }
    
    func goback(sender: AnyObject? = nil){
        self.navigationController?.popViewControllerAnimated(true)
    }
    
    
    func openmenu(sender: AnyObject? = nil){
        let parent = self.parentViewController?.parentViewController as! PineMenuViewController
        parent.toggleMenu()
    }
    
    /* BUTTONS */
    func preferredBackButton() -> UIImage {
        let count = self.navigationController?.viewControllers.count
        let name = count <= 1 ? "menu" : "back"
        return (UIImage(named: name)?.imageWithRenderingMode(.AlwaysOriginal))!
    }
    
    func preferredLeftBarButtonItem() -> UIBarButtonItem {
        let count = self.navigationController?.viewControllers.count
        let action =  count > 1 ? "goback:" : "openmenu:"
        return UIBarButtonItem(image: preferredBackButton(), landscapeImagePhone: .None, style: .Plain, target: self, action: Selector(action))
    }
    
}
{'fraction_non_alphanumeric': 0.09909365558912386, 'fraction_numerical': 0.009667673716012085, 'mean_word_length': 2.792668957617411, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '7306922', 'n_tokens_mistral': 955, 'n_tokens_neox': 904, 'n_words': 200}