<commit_before>//
//  DotView.swift
//  Freetime
//
//  Created by <NAME> on 10/19/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit
import SnapKit

class DotListView: UIView, UICollectionViewDataSource {

    private let collectionView: UICollectionView
    private var colors = [UIColor]()

    init(frame: CGRect = .zero,
         dotSize: CGSize = CGSize(width: 10, height: 10)) {

        let layout = UICollectionViewFlowLayout()
        layout.scrollDirection = .horizontal
        layout.itemSize = dotSize
        layout.minimumLineSpacing = Styles.Sizes.columnSpacing / 2.0
        collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
        collectionView.translatesAutoresizingMaskIntoConstraints = false
        collectionView.backgroundColor = .clear
        collectionView.isUserInteractionEnabled = false
        collectionView.register(IssueLabelDotCell.self, forCellWithReuseIdentifier: IssueLabelDotCell.reuse)

        super.init(frame: frame)

        collectionView.dataSource = self
        addSubview(collectionView)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        collectionView.frame = bounds
    }

    // MARK: UICollectionViewDataSource

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        guard let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { fatalError("Missing layout") }
        let max = Int(bounds.width / (layout.itemSize.width + layout.minimumLineSpacing))
        return colors.count <= max ? colors.count : max
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: IssueLabelSummaryCell.reuse, for: indexPath)
        cell.backgroundColor = colors[indexPath.item]
        return cell
    }

    // MARK: Public API

    func configure(colors: [UIColor]) {
        self.colors = colors
        collectionView.reloadData()
    }
}
<commit_msg>added dot list reload if collection view frame changes (#1178)<commit_after>//
//  DotView.swift
//  Freetime
//
//  Created by <NAME> on 10/19/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit
import SnapKit

class DotListView: UIView, UICollectionViewDataSource {

    private let collectionView: UICollectionView
    private var colors = [UIColor]()

    init(frame: CGRect = .zero,
         dotSize: CGSize = CGSize(width: 10, height: 10)) {

        let layout = UICollectionViewFlowLayout()
        layout.scrollDirection = .horizontal
        layout.itemSize = dotSize
        layout.minimumLineSpacing = Styles.Sizes.columnSpacing / 2.0
        collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
        collectionView.translatesAutoresizingMaskIntoConstraints = false
        collectionView.backgroundColor = .clear
        collectionView.isUserInteractionEnabled = false
        collectionView.register(IssueLabelDotCell.self, forCellWithReuseIdentifier: IssueLabelDotCell.reuse)

        super.init(frame: frame)

        collectionView.dataSource = self
        addSubview(collectionView)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        if collectionView.frame != bounds {
            collectionView.frame = bounds
            collectionView.reloadData()
        }
    }

    // MARK: UICollectionViewDataSource

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        guard let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { fatalError("Missing layout") }
        let max = Int(bounds.width / (layout.itemSize.width + layout.minimumLineSpacing))
        return colors.count <= max ? colors.count : max
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: IssueLabelSummaryCell.reuse, for: indexPath)
        cell.backgroundColor = colors[indexPath.item]
        return cell
    }

    // MARK: Public API

    func configure(colors: [UIColor]) {
        self.colors = colors
        collectionView.reloadData()
    }
}

{'fraction_non_alphanumeric': 0.08632311372037399, 'fraction_numerical': 0.007827788649706457, 'mean_word_length': 3.170444242973708, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2245005', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1242, 'n_words': 293}