<commit_before>//
//  PockItemView.swift
//  Pock
//
//  Created by <NAME> on 10/09/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Cocoa
import SnapKit

@available(OSX 10.12.2, *)
public class PockItemView: NSView {
    
    /// UI
    private var iconView: NSImageView? = nil
    private var dotView: NSView!
    private var dotSize: CGFloat = 2.5
    
    /// Data
    public var dockItem: DockItem? {
        didSet {
            
            /// Set icon
            self.initIconView()
            
            /// Update is running UI
            self.updateRunningDot()
            
        }
    }
    
    override public init(frame frameRect: NSRect) {
        super.init(frame: NSRect(origin: .zero, size: NSSize(width: 40, height: 30)))
        
        /// Set corner radius
        self.layer?.cornerRadius = 3.6
        
    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initIconView() {
    
        /// Init icon view
        self.iconView = NSImageView(image: self.dockItem?.icon ?? NSImage(size: .zero))
        self.addSubview(self.iconView!)
        self.iconView?.snp.remakeConstraints({ make in
            make.size.width.equalTo(25)
            make.size.height.equalTo(25)
            make.centerX.equalToSuperview()
            make.top.equalTo(1)
        })
    
    }
    
    private func updateRunningDot() {
    
        /// Remove dot icon
        self.dotView?.removeFromSuperview()
        
        /// Check if is running
        if self.dockItem?.isRunning ?? false {
            self.dotView = NSView(frame: .zero)
            self.dotView.wantsLayer = true
            self.dotView.layer?.backgroundColor = NSColor.white.cgColor
            self.dotView.layer?.cornerRadius = self.dotSize / 2
            self.addSubview(self.dotView)
            self.dotView.snp.makeConstraints({ make in
                make.size.width.equalTo(self.dotSize)
                make.size.height.equalTo(self.dotSize)
                make.centerX.equalToSuperview()
                make.bottom.equalTo(-1)
            })
        }
        
        /// Check if is frontmostApplication
        if self.dockItem?.isFrontmostApplication ?? false {
            self.wantsLayer = true
            self.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.6).cgColor
        }else {
            self.wantsLayer = false
            self.layer?.backgroundColor = NSColor.clear.cgColor
        }
    <commit_msg>Fixed missing corner radius on selected icon view.<commit_after>//
//  PockItemView.swift
//  Pock
//
//  Created by <NAME> on 10/09/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import Cocoa
import SnapKit

@available(OSX 10.12.2, *)
public class PockItemView: NSView {
    
    /// UI
    private var iconView: NSImageView? = nil
    private var dotView: NSView!
    private var dotSize: CGFloat = 2.5
    
    /// Data
    public var dockItem: DockItem? {
        didSet {
            
            /// Set icon
            self.initIconView()
            
            /// Update is running UI
            self.updateRunningDot()
            
        }
    }
    
    override public init(frame frameRect: NSRect) {
        super.init(frame: NSRect(origin: .zero, size: NSSize(width: 40, height: 30)))
    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initIconView() {
    
        /// Init icon view
        self.iconView = NSImageView(image: self.dockItem?.icon ?? NSImage(size: .zero))
        self.addSubview(self.iconView!)
        self.iconView?.snp.remakeConstraints({ make in
            make.size.width.equalTo(25)
            make.size.height.equalTo(25)
            make.centerX.equalToSuperview()
            make.top.equalTo(1)
        })
    
    }
    
    private func updateRunningDot() {
    
        /// Remove dot icon
        self.dotView?.removeFromSuperview()
        
        /// Check if is running
        if self.dockItem?.isRunning ?? false {
            self.dotView = NSView(frame: .zero)
            self.dotView.wantsLayer = true
            self.dotView.layer?.backgroundColor = NSColor.white.cgColor
            self.dotView.layer?.cornerRadius = self.dotSize / 2
            self.addSubview(self.dotView)
            self.dotView.snp.makeConstraints({ make in
                make.size.width.equalTo(self.dotSize)
                make.size.height.equalTo(self.dotSize)
                make.centerX.equalToSuperview()
                make.bottom.equalTo(-1)
            })
        }
        
        /// Check if is frontmostApplication
        if self.dockItem?.isFrontmostApplication ?? false {
            self.wantsLayer = true
            self.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.6).cgColor
        }else {
            self.wantsLayer = false
            self.layer?.backgroundColor = NSColor.clear.cgColor
        }
    
        /// Set corner radius
        self.layer?.cornerRadius = 3.6
        
{'fraction_non_alphanumeric': 0.10587084148727985, 'fraction_numerical': 0.012524461839530333, 'mean_word_length': 1.653686396677051, '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': '1423476', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1467, 'n_words': 303}