// // SettingMultivaluesTableViewCell.swift // Earthquake Network // // Created by Busi Andrea on 26/08/2020. // Copyright © 2020 Earthquake Network. All rights reserved. // import Foundation class SettingMultivaluesTableViewCell: UITableViewCell { static let Identifier = "MultivaluesCell" var isDisabled: Bool = false { didSet { updateUI() } } // MARK: - Properties lazy var titleLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 label.font = UIFont.preferredFont(forTextStyle: .body) label.textColor = AppTheme.shared.textColor return label }() lazy var valuesLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 label.font = UIFont.preferredFont(forTextStyle: .subheadline) label.textColor = AppTheme.shared.valueColor return label }() // MARK: - Init override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setupUI() } required init?(coder: NSCoder) { super.init(coder: coder) setupUI() } // MARK: - Private private func setupUI() { let stackView = UIStackView() stackView.translatesAutoresizingMaskIntoConstraints = false stackView.axis = .vertical stackView.distribution = .equalSpacing stackView.spacing = 8 stackView.addArrangedSubview(titleLabel) stackView.addArrangedSubview(valuesLabel) contentView.addSubview(stackView) stackView.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor).isActive = true stackView.trailingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor).isActive = true stackView.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor).isActive = true stackView.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor).isActive = true } private func updateUI() { let theme = AppTheme.shared titleLabel.textColor = isDisabled ? theme.textDisabledColor : theme.textColor valuesLabel.textColor = isDisabled ? theme.textDisabledColor : theme.valueColor } }