<commit_before>//
//  ImageLabel.swift
//  Scholarship
//
//  Created by <NAME> on 07/02/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import Cartography
import ReactiveCocoa

class TopicButton: UIButton {
    
    var topic: Topic?
    
    // MARK: - Initialization
    
    override init() {
        super.init(frame: CGRectZero)
        
        self.adjustsImageWhenHighlighted = false
        if let imageView = self.imageView {
            let effect = UIBlurEffect(style: .Light)
            let blurView = UIVisualEffectView(effect: effect)
            blurView.userInteractionEnabled = false
            self.insertSubview(blurView, aboveSubview: imageView)
            
            // Swift bug
            constrain(self, blurView) { view, blurView in
                blurView.edges == view.edges; return
            }
        }
        
        self.rac_valuesForKeyPath("topic", observer: self).subscribeNext { _ in
            self.setTitle(self.topic?.title, forState: .Normal)
            self.setBackgroundImage(self.topic?.headerImage, forState: .Normal)
        }
        
        self.rac_valuesForKeyPath("highlighted", observer: self).subscribeNext { _ in
            UIView.animateWithDuration(0.2, delay: 0.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.0, options: .BeginFromCurrentState, animations: {
                self.transform = (self.highlighted) ? CGAffineTransformMakeScale(0.95, 0.95) : CGAffineTransformIdentity<commit_msg>Fix reactive cocoa crash ugh<commit_after>//
//  ImageLabel.swift
//  Scholarship
//
//  Created by <NAME> on 07/02/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import Cartography
import ReactiveCocoa

class TopicButton: UIButton {
    
    var topic: Topic? {
        didSet {
            self.setTitle(self.topic?.title, forState: .Normal)
            self.setBackgroundImage(self.topic?.headerImage, forState: .Normal)
        }
    }
    
    // MARK: - Initialization
    
    override init() {
        super.init(frame: CGRectZero)
        
        self.adjustsImageWhenHighlighted = false
        if let imageView = self.imageView {
            let effect = UIBlurEffect(style: .Light)
            let blurView = UIVisualEffectView(effect: effect)
            blurView.userInteractionEnabled = false
            self.insertSubview(blurView, aboveSubview: imageView)
            
            // Swift bug
            constrain(self, blurView) { view, blurView in
                blurView.edges == view.edges; return
            }
        }
        
        self.rac_valuesForKeyPath("highlighted", observer: self).subscribeNext { _ in
            UIView.animateWithDuration(0.2, delay: 0.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.0, options: .BeginFromCurrentState, animations: {
                self.transform = (self.highlighted) ? CGAffineTransformMakeScale(0.95, 0.95) : CGAffineTransformIdentity
{'fraction_non_alphanumeric': 0.09704784526637258, 'fraction_numerical': 0.016287750254496098, 'mean_word_length': 2.246696035242291, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5390055', 'n_tokens_mistral': 898, 'n_tokens_neox': 846, 'n_words': 182}