<commit_before>//
//  DropView.swift
//  EatFit
//
//  Created by aleksey on 08.07.15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation
import UIKit

class DropView : UIView {
    var chartThickness: CGFloat = 0
    var logo: UIImage {
        set {
            logoImageView.image = newValue
            logoImageView.frame = CGRect(x: 0.0, y: 0.0, width: newValue.size.width, height: newValue.size.height)
        }
        get {
            return logoImageView.image!
        }
    }
    let fallEaseIn = CAMediaTimingFunction(controlPoints: 0.4, 0.0, 1.0, 0.4)
    let fallEaseOut = CAMediaTimingFunction(controlPoints: 0.0, 0.4, 0.4, 1.0)
    let logoImageView: UIImageView = UIImageView()

    var color: UIColor {
        set {
            drop.fillColor = newValue.CGColor
            logoImageView.tintColor = newValue
        }
        get {
            return UIColor(CGColor: drop.fillColor!)
        }
    }
    var drop: CAShapeLayer = CAShapeLayer()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        addSubview(logoImageView)
        logoImageView.layer.transform = CATransform3DMakeScale(0.0, 0.0, 0.0)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        drop.frame = CGRect(x: (bounds.width - chartThickness) / 2.0, y: -(chartThickness / 2.0), width: chartThickness, height: chartThickness)
        drop.path = UIBezierPath(ovalInRect: drop.bounds).CGPath
        
         logoImageView.frame = CGRect(x: (bounds.width - 30.0) / 2.0, y: -chartThickness, width: 30.0, height: 30.0)
    }
    
    func animateDrop (delay delay: NSTimeInterval) {
        self.layer.addSublayer(drop)
        
        let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)))
        
        dispatch_after(time, dispatch_get_main_queue()) {
            self.performDropAnimation()
        }
    }
    
    func performDropAnimation () {
        let dropFall: CABasicAnimation = CABasicAnimation(keyPath:"transform.translation.y")
        dropFall.duration = 0.3
        dropFall.toValue = self.frame.size.height - chartThickness
        dropFall.timingFunction = fallEaseIn
        
        let dropLay: CABasicAnimation = CABasicAnimation(keyPath:"transform.translation.y")
        dropLay.duration = 0.05<commit_msg>Fix 'NSConcreteValue doubleValue unrecognized selector' crash when swiping<commit_after>//
//  DropView.swift
//  EatFit
//
//  Created by aleksey on 08.07.15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation
import UIKit

class DropView : UIView {
    var chartThickness: CGFloat = 0
    var logo: UIImage {
        set {
            logoImageView.image = newValue
            logoImageView.frame = CGRect(x: 0.0, y: 0.0, width: newValue.size.width, height: newValue.size.height)
        }
        get {
            return logoImageView.image!
        }
    }
    let fallEaseIn = CAMediaTimingFunction(controlPoints: 0.4, 0.0, 1.0, 0.4)
    let fallEaseOut = CAMediaTimingFunction(controlPoints: 0.0, 0.4, 0.4, 1.0)
    let logoImageView: UIImageView = UIImageView()

    var color: UIColor {
        set {
            drop.fillColor = newValue.CGColor
            logoImageView.tintColor = newValue
        }
        get {
            return UIColor(CGColor: drop.fillColor!)
        }
    }
    var drop: CAShapeLayer = CAShapeLayer()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        addSubview(logoImageView)
        logoImageView.layer.transform = CATransform3DMakeScale(0.0, 0.0, 0.0)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        drop.frame = CGRect(x: (ceil(bounds.width) - chartThickness) / 2.0, y: -(chartThickness / 2.0), width: chartThickness, height: chartThickness)
        drop.path = UIBezierPath(ovalInRect: drop.bounds).CGPath
        
         logoImageView.frame = CGRect(x: (bounds.width - 30.0) / 2.0, y: -chartThickness, width: 30.0, height: 30.0)
    }
    
    func animateDrop (delay delay: NSTimeInterval) {
        self.layer.addSublayer(drop)
        
        let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)))
        
        dispatch_after(time, dispatch_get_main_queue()) {
            self.performDropAnimation()
        }
    }
    
    func performDropAnimation () {
        let dropFall: CABasicAnimation = CABasicAnimation(keyPath:"transform.translation.y")
        dropFall.duration = 0.3
        dropFall.toValue = self.frame.size.height - chartThickness
        dropFall.timingFunction = fallEaseIn
        
        let dropLay: CABasicAnimation = CABasicAnimation(keyPath:"transform.translation.y")
        dropLay.duration = 0.05
{'fraction_non_alphanumeric': 0.10450602919399196, 'fraction_numerical': 0.025386079966151893, 'mean_word_length': 2.3437057991513437, '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': '2198695', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1489, 'n_words': 306}