<commit_before>/*
 |  _   ____   ____   _
 | | |‾|  ⚈ |-| ⚈  |‾| |
 | | |  ‾‾‾‾| |‾‾‾‾  | |
 |  ‾        ‾        ‾
 */

import UIKit

@IBDesignable open class CustomTableView: UITableView, BackgroundColorNameable {
    
    // MARK: - Inspectable properties

    @IBInspectable open var backgroundColorName: String? {
        didSet {
            applyBackgroundColorName()
        }
    }
    
    @IBInspectable open var separatorColorName: String? {
        didSet {
            updateSeparatorColor()
        }
    }
    
    @IBInspectable open var tapToDeselect: Bool = false

    
    // MARK: - Initializers
    
    override public init(frame: CGRect, style: UITableViewStyle) {
        super.init(frame: frame, style: style)
        registerForNotifications()
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        registerForNotifications()
    }
    
    open override func awakeFromNib() {
        super.awakeFromNib()
        updateSeparatorColor()
    }
    
    
    // MARK: - Lifecycle overrides
    
    open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        let result = super.hitTest(point, with: event)
        guard tapToDeselect else { return result }
        if result == self, let selected = indexPathForSelectedRow {
            deselectRow(at: selected, animated: true)
        }
        return result
    }
    <commit_msg>Add protocol for deselection in custom table<commit_after>/*
 |  _   ____   ____   _
 | | |‾|  ⚈ |-| ⚈  |‾| |
 | | |  ‾‾‾‾| |‾‾‾‾  | |
 |  ‾        ‾        ‾
 */

import UIKit

public protocol CustomTableViewDelegate: class {
    func didDeselectOnTap(in tableView: CustomTableView)
}

@IBDesignable open class CustomTableView: UITableView, BackgroundColorNameable {
    
    // MARK: - Inspectable properties

    @IBInspectable open var backgroundColorName: String? {
        didSet {
            applyBackgroundColorName()
        }
    }
    
    @IBInspectable open var separatorColorName: String? {
        didSet {
            updateSeparatorColor()
        }
    }
    
    @IBInspectable open var tapToDeselect: Bool = false
    
    
    // MARK: - Public properties
    
    public weak var deselectionDelegate: CustomTableViewDelegate?

    
    // MARK: - Initializers
    
    override public init(frame: CGRect, style: UITableViewStyle) {
        super.init(frame: frame, style: style)
        registerForNotifications()
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        registerForNotifications()
    }
    
    open override func awakeFromNib() {
        super.awakeFromNib()
        updateSeparatorColor()
    }
    
    
    // MARK: - Lifecycle overrides
    
    open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        let result = super.hitTest(point, with: event)
        guard tapToDeselect else { return result }
        if result == self, let selected = indexPathForSelectedRow {
            deselectRow(at: selected, animated: true)
            deselectionDelegate?.didDeselectOnTap(in: self)
        }
        return result
    }
    
{'fraction_non_alphanumeric': 0.09555137844611529, 'fraction_numerical': 0.0, 'mean_word_length': 2.1090555014605648, 'pattern_counts': {'":': 0, '<': 3, '<?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': '790036', 'n_tokens_mistral': 1029, 'n_tokens_neox': 979, 'n_words': 230}