|
| 1 | +import UIKit |
| 2 | + |
| 3 | +class PropertyInfoView: UIView { |
| 4 | + |
| 5 | + private lazy var priceLabel: UILabel = { |
| 6 | + let label = UILabel() |
| 7 | + label.text = " R$ 405.000" |
| 8 | + label.font = .systemFont(ofSize: 20) |
| 9 | + label.tintColor = .black |
| 10 | + label.font = .boldSystemFont(ofSize: 20) |
| 11 | + label.translatesAutoresizingMaskIntoConstraints = false |
| 12 | + return label |
| 13 | + }() |
| 14 | + |
| 15 | + private lazy var buildingLabel: UILabel = { |
| 16 | + let label = UILabel() |
| 17 | + label.text = "Condomínio R$ 495 IPTU R$ 0" |
| 18 | + label.tintColor = .black |
| 19 | + label.translatesAutoresizingMaskIntoConstraints = false |
| 20 | + return label |
| 21 | + }() |
| 22 | + |
| 23 | + private lazy var infoLabel: UILabel = { |
| 24 | + let label = UILabel() |
| 25 | + label.text = "69 m² 3 quartos 2 banheiros 1 vaga" |
| 26 | + label.font = UIFont.systemFont(ofSize: 14) |
| 27 | + label.textColor = UIColor.lightGray.withAlphaComponent(0.9) |
| 28 | + label.translatesAutoresizingMaskIntoConstraints = false |
| 29 | + return label |
| 30 | + }() |
| 31 | + |
| 32 | + private lazy var addressLabel: UILabel = { |
| 33 | + let label = UILabel() |
| 34 | + label.text = "Sem endereço" |
| 35 | + label.font = UIFont.systemFont(ofSize: 14) |
| 36 | + label.textColor = UIColor.lightGray.withAlphaComponent(0.9) |
| 37 | + label.translatesAutoresizingMaskIntoConstraints = false |
| 38 | + return label |
| 39 | + }() |
| 40 | + |
| 41 | + init() { |
| 42 | + super.init(frame: .zero) |
| 43 | + self.hierarchy() |
| 44 | + self.setConstraints() |
| 45 | + } |
| 46 | + |
| 47 | + required init?(coder: NSCoder) { |
| 48 | + fatalError("init(coder:) has not been implemented") |
| 49 | + } |
| 50 | + |
| 51 | + func hierarchy() { |
| 52 | + [priceLabel, buildingLabel, infoLabel, addressLabel].forEach { |
| 53 | + addSubview($0) |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + func setConstraints() { |
| 58 | + NSLayoutConstraint.activate([ |
| 59 | + priceLabel.topAnchor.constraint(equalTo: bottomAnchor, constant: 10), |
| 60 | + priceLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16), |
| 61 | + priceLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16), |
| 62 | + |
| 63 | + buildingLabel.topAnchor.constraint(equalTo: priceLabel.bottomAnchor, constant: 10), |
| 64 | + buildingLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16), |
| 65 | + buildingLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16), |
| 66 | + |
| 67 | + infoLabel.topAnchor.constraint(equalTo: buildingLabel.bottomAnchor, constant: 10), |
| 68 | + infoLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16), |
| 69 | + infoLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16), |
| 70 | + |
| 71 | + addressLabel.topAnchor.constraint(equalTo: infoLabel.bottomAnchor, constant: 10), |
| 72 | + addressLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16), |
| 73 | + addressLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 16), |
| 74 | + |
| 75 | + bottomAnchor.constraint(equalTo: addressLabel.bottomAnchor, constant: 10) |
| 76 | + ]) |
| 77 | + } |
| 78 | +} |
0 commit comments