<commit_before>import UIKit

class VCameraCompressCell:UICollectionViewCell
{
    private weak var imageView:UIImageView!
    private weak var label:UILabel!
    private weak var percent:UILabel!
    private weak var selectedIcon:UIImageView!
    private let attributesTitle:[String:AnyObject]
    private let attributesSize:[String:AnyObject]
    private let stringSuffix:NSAttributedString
    private let kSuffix:String = " Kb"
    private let kLabelLeft:CGFloat = 6
    private let kLabelWidth:CGFloat = 250
    private let kPercentWidth:CGFloat = 80
    private let kSelectedWidth:CGFloat = 55
    private let kAlphaSelected:CGFloat = 1
    private let kAlphaNotSelected:CGFloat = 0.18
    
    override init(frame:CGRect)
    {
        attributesTitle = [
            NSFontAttributeName:UIFont.medium(size:14),
            NSForegroundColorAttributeName:UIColor.black]
        
        attributesSize = [
            NSFontAttributeName:UIFont.regular(size:24),
            NSForegroundColorAttributeName:UIColor(white:0.2, alpha:1)]
        
        let attributesSuffix:[String:AnyObject] = [
            NSFontAttributeName:UIFont.regular(size:13),
            NSForegroundColorAttributeName:UIColor(white:0.4, alpha:1)]
        
        stringSuffix = NSAttributedString(
            string:kSuffix,
            attributes:attributesSuffix)
        
        super.init(frame:frame)
        clipsToBounds = true
        backgroundColor = UIColor.white
        
        let label:UILabel = UILabel()
        label.isUserInteractionEnabled = false
        label.translatesAutoresizingMaskIntoConstraints = false
        label.backgroundColor = UIColor.clear
        label.numberOfLines = 0
        self.label = label
        
        let percent:UILabel = UILabel()
        percent.isUserInteractionEnabled = false
        percent.translatesAutoresizingMaskIntoConstraints = false
        percent.backgroundColor = UIColor.clear
        percent.font = UIFont.bold(size:22)
        percent.textAlignment = NSTextAlignment.right
        self.percent = percent
        
        let selectedIcon:UIImageView = UIImageView()
        selectedIcon.translatesAutoresizingMaskIntoConstraints = false
        selectedIcon.clipsToBounds = true
        selectedIcon.isUserInteractionEnabled = false
        selectedIcon.contentMode = UIViewContentMode.center
        selectedIcon.image = #imageLiteral(resourceName: "assetCameraFilterSelect")
        self.selectedIcon = selectedIcon
        
        addSubview(label)
        addSubview(percent)
        addSubview(selectedIcon)
        
        let constraintsSelectedVertical:[NSLayoutConstraint] = NSLayoutConstraint.equalsVertical(
            view:selectedIcon,
            toView:self)
        let constraintsLabelVertical:[NSLayoutConstraint] = NSLayoutConstraint.equalsVertical(
            view:label,
            toView:self)
        let constraintsPercentVertical:[NSLayoutConstraint] = NSLayoutConstraint.equalsVertical(
            view:percent,
            toView:self)
        
        let layoutSelectedRight:NSLayoutConstraint = NSLayoutConstraint.rightToRight(
            view:selectedIcon,
            toView:self)
        let layoutSelectedWidth:NSLayoutConstraint = NSLayoutConstraint.width(
            view:selectedIcon,
            constant:kSelectedWidth)
        
        let layoutLabelLeft:NSLayoutConstraint = NSLayoutConstraint.leftToRight(
            view:label,
            toView:percent,
            constant:kLabelLeft)
        let layoutLabelWidth:NSLayoutConstraint = NSLayoutConstraint.width(
            view:label,
            constant:kLabelWidth)
        
        let layoutPercentLeft:NSLayoutConstraint = NSLayoutConstraint.leftToLeft(
            view:percent,
            toView:self)
        let layoutPercentWidth:NSLayoutConstraint = NSLayoutConstraint.width(
            view:percent,
            constant:kPercentWidth)
        
        addConstraints(constraintsSelectedVertical)
        addConstraints(constraintsLabelVertical)
        addConstraints(constraintsPercentVertical)
        
        addConstraints([
            layoutSelectedWidth,
            layoutSelectedRight,
            layoutLabelLeft,
            layoutLabelWidth,
            layoutPercentLeft,
            layoutPercentWidth])
    }
    
    required init?(coder:NSCoder)
    {
        fatalError()
    }
    
    override var isSelected:Bool
    {
        didSet
        {
            hover()
        }
    }
    
    override var isHighlighted:Bool
    {
        didSet
        {
            hover()
        }
    }
    
    //MARK: private
    
    private func hover()
    {
        if isSelected || isHighlighted
        {
            selectedIcon.isHidden = false
            label.alpha = kAlphaSelected<commit_msg>refactor constraints<commit_after>import UIKit

class VCameraCompressCell:UICollectionViewCell
{
    private weak var imageView:UIImageView!
    private weak var label:UILabel!
    private weak var percent:UILabel!
    private weak var selectedIcon:UIImageView!
    private let attributesTitle:[String:AnyObject]
    private let attributesSize:[String:AnyObject]
    private let stringSuffix:NSAttributedString
    private let kSuffix:String = " Kb"
    private let kLabelLeft:CGFloat = 6
    private let kLabelWidth:CGFloat = 250
    private let kPercentWidth:CGFloat = 80
    private let kSelectedWidth:CGFloat = 55
    private let kAlphaSelected:CGFloat = 1
    private let kAlphaNotSelected:CGFloat = 0.18
    
    override init(frame:CGRect)
    {
        attributesTitle = [
            NSFontAttributeName:UIFont.medium(size:14),
            NSForegroundColorAttributeName:UIColor.black]
        
        attributesSize = [
            NSFontAttributeName:UIFont.regular(size:24),
            NSForegroundColorAttributeName:UIColor(white:0.2, alpha:1)]
        
        let attributesSuffix:[String:AnyObject] = [
            NSFontAttributeName:UIFont.regular(size:13),
            NSForegroundColorAttributeName:UIColor(white:0.4, alpha:1)]
        
        stringSuffix = NSAttributedString(
            string:kSuffix,
            attributes:attributesSuffix)
        
        super.init(frame:frame)
        clipsToBounds = true
        backgroundColor = UIColor.white
        
        let label:UILabel = UILabel()
        label.isUserInteractionEnabled = false
        label.translatesAutoresizingMaskIntoConstraints = false
        label.backgroundColor = UIColor.clear
        label.numberOfLines = 0
        self.label = label
        
        let percent:UILabel = UILabel()
        percent.isUserInteractionEnabled = false
        percent.translatesAutoresizingMaskIntoConstraints = false
        percent.backgroundColor = UIColor.clear
        percent.font = UIFont.bold(size:22)
        percent.textAlignment = NSTextAlignment.right
        self.percent = percent
        
        let selectedIcon:UIImageView = UIImageView()
        selectedIcon.translatesAutoresizingMaskIntoConstraints = false
        selectedIcon.clipsToBounds = true
        selectedIcon.isUserInteractionEnabled = false
        selectedIcon.contentMode = UIViewContentMode.center
        selectedIcon.image = #imageLiteral(resourceName: "assetCameraFilterSelect")
        self.selectedIcon = selectedIcon
        
        addSubview(label)
        addSubview(percent)
        addSubview(selectedIcon)
        
        NSLayoutConstraint.equalsVertical(
            view:selectedIcon,
            toView:self)
        NSLayoutConstraint.equalsVertical(
            view:label,
            toView:self)
        NSLayoutConstraint.equalsVertical(
            view:percent,
            toView:self)
        
        NSLayoutConstraint.rightToRight(
            view:selectedIcon,
            toView:self)
        NSLayoutConstraint.width(
            view:selectedIcon,
            constant:kSelectedWidth)
        
        NSLayoutConstraint.leftToRight(
            view:label,
            toView:percent,
            constant:kLabelLeft)
        NSLayoutConstraint.width(
            view:label,
            constant:kLabelWidth)
        
        NSLayoutConstraint.leftToLeft(
            view:percent,
            toView:self)
        NSLayoutConstraint.width(
            view:percent,
            constant:kPercentWidth)
    }
    
    required init?(coder:NSCoder)
    {
        fatalError()
    }
    
    override var isSelected:Bool
    {
        didSet
        {
            hover()
        }
    }
    
    override var isHighlighted:Bool
    {
        didSet
        {
            hover()
        }
    }
    
    //MARK: private
    
    private func hover()
    {
        if isSelected || isHighlighted
        {
            selectedIcon.isHidden = false
            label.alpha = kAlphaSelected
{'fraction_non_alphanumeric': 0.06375, 'fraction_numerical': 0.006136363636363636, 'mean_word_length': 2.213216502373129, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1366563', 'n_tokens_mistral': 2301, 'n_tokens_neox': 2275, 'n_words': 388}