import UIKit

/// person table view cell
class OsobaTableViewCell: UITableViewCell {
    
    public let title: UILabel = {
        let view = UILabel()
        view.numberOfLines = 0
        view.textColor = .black
        view.textAlignment = .center
        return view
    }()
    
    public let subtitle: UILabel = {
        let view = UILabel()
        view.numberOfLines = 0
        view.textColor = .gray
        view.textAlignment = .center
        return view
    }()
    
    private let stackView: UIStackView = {
        let view = UIStackView()
        view.translatesAutoresizingMaskIntoConstraints = false
        view.axis = .horizontal
        view.spacing = 10
        view.distribution = .fillProportionally
        return view
    }()
    
    static let cellIdentifier: String = "OsobaTableViewCellIdentifier"
    
    /// initialization function
    /// - Parameters:
    ///   - style: style of the cell
    ///   - reuseIdentifier: reuse identifier for cell
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        stackView.addArrangedSubview(title)
        stackView.addArrangedSubview(subtitle)
        addSubview(stackView)
        NSLayoutConstraint.activate([
            stackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
            stackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
            stackView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
            stackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8)
        ])
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
