<commit_before>//
//  ShiftKey.swift
//  Keyboard
//
//  Created by <NAME> on 6/17/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit

class ShiftKey: UIButton {
	
	// MARK: Public Properties
	
	var disabledTintColor: UIColor = UIColor.lightGrayColor() as UIColor {
		didSet {
			refreshAppearance()
		}
	}
	
	var enabledTintColor: UIColor = UIColor.blueColor() as UIColor {
		didSet {
			refreshAppearance()
		}
	}
	
	var shiftState: KeyboardShiftState {
		didSet {
			// Update appearance.
			refreshAppearance()
		}
	}
	
	var shiftStateChangeHandler: (shitState: KeyboardShiftState) -> () = {shiftState in}
	
	
	// MARK: Initialization
	
	convenience init() {
		self.init(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
	}
	
    init(frame: CGRect) {
		// Disabled is the default state.
		self.shiftState = .Disabled
		
        super.init(frame: frame)
        // Initialization code
		
		refreshAppearance()
		
		self.setTranslatesAutoresizingMaskIntoConstraints(false)
		
		self.addSubview(arrowImageView)
		self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[arrowImageView]|", options: nil, metrics: nil, views: ["arrowImageView": arrowImageView]))
		self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[arrowImageView]|", options: nil, metrics: nil, views: ["arrowImageView": arrowImageView]))
		
		self.addTarget(self, action: "didTap:", forControlEvents: .TouchUpInside)
    }
	
	// MARK: Private
	
	// MARK: UI
	
	let arrowImageView: UIImageView = {
		let view = UIImageView()
		view.setTranslatesAutoresizingMaskIntoConstraints(false)
		view.contentMode = .ScaleAspectFit
		return view
	}()
	
	
	// MARK: Toggling state
	
	func refreshAppearance() {
		switch shiftState {
			case .Disabled:
				arrowImageView.tintColor = disabledTintColor
				arrowImageView.image = UIImage(named: "Shift Disabled")
			case .Enabled:
				arrowImageView.tintColor = enabledTintColor
				arrowImageView.image = UIImage(named: "Shift Enabled")
			case .Locked:
				arrowImageView.tintColor = enabledTintColor<commit_msg>Fixes an issue where the shift key graphic was blurry.<commit_after>//
//  ShiftKey.swift
//  Keyboard
//
//  Created by <NAME> on 6/17/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit

class ShiftKey: UIButton {
	
	// MARK: Public Properties
	
	var disabledTintColor: UIColor = UIColor.lightGrayColor() as UIColor {
		didSet {
			refreshAppearance()
		}
	}
	
	var enabledTintColor: UIColor = UIColor.blueColor() as UIColor {
		didSet {
			refreshAppearance()
		}
	}
	
	var shiftState: KeyboardShiftState {
		didSet {
			// Update appearance.
			refreshAppearance()
		}
	}
	
	var shiftStateChangeHandler: (shitState: KeyboardShiftState) -> () = {shiftState in}
	
	
	// MARK: Initialization
	
	convenience init() {
		self.init(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
	}
	
    init(frame: CGRect) {
		// Disabled is the default state.
		self.shiftState = .Disabled
		
        super.init(frame: frame)
        // Initialization code
		
		refreshAppearance()
		
		self.setTranslatesAutoresizingMaskIntoConstraints(false)
		
		self.addSubview(arrowImageView)
		self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[arrowImageView]|", options: nil, metrics: nil, views: ["arrowImageView": arrowImageView]))
		self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[arrowImageView]|", options: nil, metrics: nil, views: ["arrowImageView": arrowImageView]))
		
		self.addTarget(self, action: "didTap:", forControlEvents: .TouchUpInside)
    }
	
	// MARK: Private
	
	// MARK: UI
	
	let arrowImageView: UIImageView = {
		let view = UIImageView()
		view.setTranslatesAutoresizingMaskIntoConstraints(false)
		view.contentMode = .Center
		return view
	}()
	
	
	// MARK: Toggling state
	
	func refreshAppearance() {
		switch shiftState {
			case .Disabled:
				arrowImageView.tintColor = disabledTintColor
				arrowImageView.image = UIImage(named: "Shift Disabled")
			case .Enabled:
				arrowImageView.tintColor = enabledTintColor
				arrowImageView.image = UIImage(named: "Shift Enabled")
			case .Locked:
				arrowImageView.tintColor = enabledTintColor
{'fraction_non_alphanumeric': 0.11254480286738351, 'fraction_numerical': 0.007168458781362007, 'mean_word_length': 3.817031070195627, 'pattern_counts': {'":': 4, '<': 7, '<?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': '2208214', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1294, 'n_words': 296}