<commit_before>//
//  SpeakButton.swift
//  WalkieTalkie
//
//  Created by <NAME> on 18/10/14.
//  Copyright (c) 2014 CocoaHeadsBY. All rights reserved.
//

import Foundation
import UIKit

protocol SpeakButtonDelegate : class {
    
    func speakButtonWasTouched(speakButton: SpeakButton)
    func speakButtonWasReleased(speakButton: SpeakButton)
}

class SpeakButton : UIView {

    @IBOutlet weak var overlayButton : UIButton!
    
    weak var delegate : SpeakButtonDelegate?

    func linkEvents(){

        self.overlayButton.addTarget(self, action: "didTouchDown:", forControlEvents: .TouchDown)
        self.overlayButton.addTarget(self, action: "didTouchUp:", forControlEvents: .TouchUpInside)
        self.overlayButton.addTarget(self, action: "didTouchUp:", forControlEvents: .TouchUpOutside)
    }
    
    func commonInit(){
        self.linkEvents()
        
        self.layer.cornerRadius = 10.0;
    }
    
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
    }

    override func awakeFromNib() {
        
        self.addViewFromNib()
        self.commonInit()
        
        
    }
    
    /*
    UIView* detailsView = [[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil] lastObject];
    
    detailsView.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:detailsView];
    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[detailsView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(detailsView, self)]];
    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[detailsView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(detailsView, self)]];
    
    [self addSubview:detailsView];
*/
    
    func addViewFromNib(){
        
        var views : [AnyObject] = NSBundle.mainBundle().loadNibNamed("SpeakButton", owner: self, options: nil)
        
        var view = views.first as UIView
        view.setTranslatesAutoresizingMaskIntoConstraints(false)
        self.addSubview(view)
        
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[view]-0-|", options: .allZeros, metrics: nil, views:[ "view" : view, "self" : self ]))
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[view]-0-|", options: .allZeros, metrics: nil, views:[ "view" : view, "self" : self ]))
    }
    
    func didTouchDown(sender : AnyObject){
        
        println("didTouchDown")
        
        UIView.beginAnimations("TouchDown", context: nil)
        
        self.backgroundColor = UIColor(red: 20.0/255, green: 148.0/255, blue: 73.0/255, alpha: 1)
        
        UIView.commitAnimations()
        
        delegate?.speakButtonWasTouched(self)
    }
    
    func didTouchUp(sender : AnyObject){
        
        println("didTouchUp")
        
        UIView.beginAnimations("TouchUp", context: nil)
        
        self.backgroundColor = UIColor(red: 162.0/255, green: 21.0/255, blue: 1.0/255, alpha: 1)
        UIView.commitAnimations()
        <commit_msg>new look of SpeakButton<commit_after>//
//  SpeakButton.swift
//  WalkieTalkie
//
//  Created by <NAME> on 18/10/14.
//  Copyright (c) 2014 CocoaHeadsBY. All rights reserved.
//

import Foundation
import UIKit


protocol SpeakButtonDelegate : class {
    
    func speakButtonWasTouched(speakButton: SpeakButton)
    func speakButtonWasReleased(speakButton: SpeakButton)
}

class SpeakButton : UIView {

    @IBOutlet weak var overlayButton : UIButton!
    
    weak var delegate : SpeakButtonDelegate?

    func linkEvents(){

        self.overlayButton.addTarget(self, action: "didTouchDown:", forControlEvents: .TouchDown)
        self.overlayButton.addTarget(self, action: "didTouchUp:", forControlEvents: .TouchUpInside)
        self.overlayButton.addTarget(self, action: "didTouchUp:", forControlEvents: .TouchUpOutside)
    }
    
    func commonInit(){
        self.linkEvents()
        
        self.layer.cornerRadius = 10.0;
    }
    
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
    }

    override func awakeFromNib() {
        
        self.addViewFromNib()
        self.commonInit()
        
        
    }
    
    /*
    UIView* detailsView = [[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil] lastObject];
    
    detailsView.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:detailsView];
    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[detailsView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(detailsView, self)]];
    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[detailsView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(detailsView, self)]];
    
    [self addSubview:detailsView];
*/
    
    func addViewFromNib(){
        
        var views : [AnyObject] = NSBundle.mainBundle().loadNibNamed("SpeakButton", owner: self, options: nil)
        
        var view = views.first as UIView
        view.setTranslatesAutoresizingMaskIntoConstraints(false)
        self.addSubview(view)
        
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[view]-0-|", options: .allZeros, metrics: nil, views:[ "view" : view, "self" : self ]))
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[view]-0-|", options: .allZeros, metrics: nil, views:[ "view" : view, "self" : self ]))
    }
    
    func didTouchDown(sender : AnyObject){
        
        println("didTouchDown")
        
        UIView.beginAnimations("TouchDown", context: nil)
        
        self.backgroundColor = UIColor(red: 162.0/255, green: 21.0/255, blue: 1.0/255, alpha: 1)
        //UIColor(red: 20.0/255, green: 148.0/255, blue: 73.0/255, alpha: 1)
        
        UIView.commitAnimations()
        
        delegate?.speakButtonWasTouched(self)
    }
    
    func didTouchUp(sender : AnyObject){
        
        println("didTouchUp")
        
        UIView.beginAnimations("TouchUp", context: nil)
        
        self.backgroundColor = UIColor(red: 145.0/255, green: 145.0/255, blue: 145.0/255, alpha: 1)
        UIView.commitAnimations()
        
{'fraction_non_alphanumeric': 0.11705844980940279, 'fraction_numerical': 0.02318932655654384, 'mean_word_length': 2.9136109384711, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2002714', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1907, 'n_words': 357}