<commit_before>//
//  SidebarStatusBarView.swift
//  Evergreen
//
//  Created by <NAME> on 9/17/16.
//  Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//

import AppKit
import RSCore
import Data
import RSWeb
import Account

final class SidebarStatusBarView: NSView {

	@IBOutlet var progressIndicator: NSProgressIndicator!
	@IBOutlet var progressLabel: NSTextField!

	private var didConfigureLayer = false

	private var isAnimatingProgress = false {
		didSet {
			progressIndicator.isHidden = !isAnimatingProgress
			progressLabel.isHidden = !isAnimatingProgress
		}
	}

	private var progress: CombinedRefreshProgress? = nil {
		didSet {
			CoalescingQueue.standard.add(self, #selector(updateUI))
		}
	}
	override var isFlipped: Bool {
		return true
	}

	override var wantsUpdateLayer: Bool {
		return true
	}

	override func awakeFromNib() {

		progressIndicator.isHidden = true
		progressLabel.isHidden = true

		let progressLabelFontSize = progressLabel.font?.pointSize ?? 13.0
		progressLabel.font = NSFont.monospacedDigitSystemFont(ofSize: progressLabelFontSize, weight: NSFont.Weight.regular)
		progressLabel.stringValue = ""		
		
		NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
	}

	override func updateLayer() {

		guard let layer = layer, !didConfigureLayer else {
			return
		}

		let color = NSColor(calibratedWhite: 0.96, alpha: 1.0)
		layer.backgroundColor = color.cgColor
		didConfigureLayer = true
	}

	@objc func updateUI() {

		guard let progress = progress else {
			stopProgressIfNeeded()
			return
		}

		updateProgressIndicator(progress)
		updateProgressLabel(progress)
	}

	// MARK: Notifications

	@objc dynamic func progressDidChange(_ notification: Notification) {
<commit_msg>Make sidebar status bar vibrant. Fix #369.<commit_after>//
//  SidebarStatusBarView.swift
//  Evergreen
//
//  Created by <NAME> on 9/17/16.
//  Copyright © 2016 Ranchero Software, LLC. All rights reserved.
//

import AppKit
import RSCore
import Data
import RSWeb
import Account

final class SidebarStatusBarView: NSView {

	@IBOutlet var progressIndicator: NSProgressIndicator!
	@IBOutlet var progressLabel: NSTextField!

	private var isAnimatingProgress = false {
		didSet {
			progressIndicator.isHidden = !isAnimatingProgress
			progressLabel.isHidden = !isAnimatingProgress
		}
	}

	private var progress: CombinedRefreshProgress? = nil {
		didSet {
			CoalescingQueue.standard.add(self, #selector(updateUI))
		}
	}
	override var isFlipped: Bool {
		return true
	}

	override func awakeFromNib() {

		progressIndicator.isHidden = true
		progressLabel.isHidden = true

		let progressLabelFontSize = progressLabel.font?.pointSize ?? 13.0
		progressLabel.font = NSFont.monospacedDigitSystemFont(ofSize: progressLabelFontSize, weight: NSFont.Weight.regular)
		progressLabel.stringValue = ""		
		
		NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
	}

	@objc func updateUI() {

		guard let progress = progress else {
			stopProgressIfNeeded()
			return
		}

		updateProgressIndicator(progress)
		updateProgressLabel(progress)
	}

	// MARK: Notifications

	@objc dynamic func progressDidChange(_ notification: Notification) {

{'fraction_non_alphanumeric': 0.08768768768768768, 'fraction_numerical': 0.00960960960960961, 'mean_word_length': 4.505785123966942, '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': '369243', 'n_tokens_mistral': 1115, 'n_tokens_neox': 994, 'n_words': 248}