<commit_before>//
//  Copyright (c) 2014-2016 Actor LLC. <https://actor.im>
//

import UIKit

public enum AACommonCellStyle {
    case Normal
    case DestructiveCentered
    case Destructive
    case Switch
    case Action
    case ActionCentered
    case Navigation
    case Hint
    case Checkmark
}

public class AACommonCell: AATableViewCell {
    
    private var switcher: UISwitch?
    private var titleLabel = UILabel()
    private var hintLabel = UILabel()
    
    public var style: AACommonCellStyle = .Normal { didSet { updateCellStyle() } }
    public var switchBlock: ((Bool) -> ())?
    public var contentInset: CGFloat = 15
    
    public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        titleLabel.font = UIFont.systemFontOfSize(17.0)
        contentView.addSubview(titleLabel)
        
        hintLabel.font = UIFont.systemFontOfSize(17.0)
        hintLabel.textColor = appStyle.cellHintColor
        contentView.addSubview(hintLabel)
    }
    
    public required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // Setting text content
    
    public func setContent(content: String?) {
        titleLabel.text = content
    }
    
    public func setHint(hint: String?) {
        if hint == nil {
            hintLabel.hidden = true
        } else {
            hintLabel.text = hint
            hintLabel.hidden = false
        }
    }
    
    // Setting switcher content
    
    public func setSwitcherOn(on: Bool) {
        setSwitcherOn(on, animated: false)
    }
    
    public func setSwitcherOn(on: Bool, animated: Bool) {
        switcher?.setOn(on, animated: animated)
    }
    
    public func setSwitcherEnabled(enabled: Bool) {
        switcher?.enabled = enabled
    }
    
    // Private methods
    
    private func updateCellStyle() {
        switch (style) {
        case .Normal:
            titleLabel.textColor = appStyle.cellTextColor
            titleLabel.textAlignment = NSTextAlignment.Left
            switcher?.hidden = true
            accessoryType = UITableViewCellAccessoryType.None
            break<commit_msg>fix(iOS): Fixing not updating common cell on hide/show label<commit_after>//
//  Copyright (c) 2014-2016 Actor LLC. <https://actor.im>
//

import UIKit

public enum AACommonCellStyle {
    case Normal
    case DestructiveCentered
    case Destructive
    case Switch
    case Action
    case ActionCentered
    case Navigation
    case Hint
    case Checkmark
}

public class AACommonCell: AATableViewCell {
    
    private var switcher: UISwitch?
    private var titleLabel = UILabel()
    private var hintLabel = UILabel()
    
    public var style: AACommonCellStyle = .Normal { didSet { updateCellStyle() } }
    public var switchBlock: ((Bool) -> ())?
    public var contentInset: CGFloat = 15
    
    public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        titleLabel.font = UIFont.systemFontOfSize(17.0)
        contentView.addSubview(titleLabel)
        
        hintLabel.font = UIFont.systemFontOfSize(17.0)
        hintLabel.textColor = appStyle.cellHintColor
        contentView.addSubview(hintLabel)
    }
    
    public required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // Setting text content
    
    public func setContent(content: String?) {
        titleLabel.text = content
    }
    
    public func setHint(hint: String?) {
        if hint == nil {
            hintLabel.hidden = true
        } else {
            hintLabel.text = hint
            hintLabel.hidden = false
        }
        setNeedsLayout()
    }
    
    // Setting switcher content
    
    public func setSwitcherOn(on: Bool) {
        setSwitcherOn(on, animated: false)
    }
    
    public func setSwitcherOn(on: Bool, animated: Bool) {
        switcher?.setOn(on, animated: animated)
    }
    
    public func setSwitcherEnabled(enabled: Bool) {
        switcher?.enabled = enabled
    }
    
    // Private methods
    
    private func updateCellStyle() {
        switch (style) {
        case .Normal:
            titleLabel.textColor = appStyle.cellTextColor
            titleLabel.textAlignment = NSTextAlignment.Left
            switcher?.hidden = true
            accessoryType = UITableViewCellAccessoryType.None
            break
{'fraction_non_alphanumeric': 0.08047493403693931, 'fraction_numerical': 0.007036059806508356, 'mean_word_length': 2.2423378474697078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '6648574', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1305, 'n_words': 320}