Commit e5a7196d by Demid Merzlyakov

Today Conditions Cells layout changed to center vertically.

parent 9d247a4e
......@@ -14,13 +14,15 @@ class TodayConditionButton: UIControl {
private let valueLabel = UILabel()
private let nameLabel = UILabel()
private let descriptionLabel = UILabel()
private let containerView = UIView()
init(type: WeatherConditionType) {
self.conditionType = type
super.init(frame: .zero)
prepareSelf()
prepareButton()
prepareSelf()
prepareContainer()
prepareImageView()
prepareLabels()
}
......@@ -60,7 +62,16 @@ class TodayConditionButton: UIControl {
private extension TodayConditionButton {
func prepareSelf() {
snp.makeConstraints { (make) in
make.width.equalTo(200)
make.width.equalTo(180)
}
}
func prepareContainer() {
containerView.backgroundColor = .clear
addSubview(containerView)
containerView.snp.makeConstraints { (make) in
make.centerY.equalToSuperview()
make.left.equalToSuperview()
}
}
......@@ -82,7 +93,7 @@ private extension TodayConditionButton {
imageView.contentMode = .scaleAspectFit
imageView.clipsToBounds = true
imageView.image = conditionType.image
addSubview(imageView)
containerView.addSubview(imageView)
imageView.snp.makeConstraints { (make) in
make.left.top.equalToSuperview().inset(20)
......@@ -97,10 +108,11 @@ private extension TodayConditionButton {
valueLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
valueLabel.textAlignment = .left
valueLabel.text = "21%"
addSubview(valueLabel)
containerView.addSubview(valueLabel)
valueLabel.snp.makeConstraints { (make) in
make.left.equalTo(imageView.snp.right).offset(13)
make.right.lessThanOrEqualToSuperview().inset(20)
make.top.equalToSuperview().inset(16)
}
......@@ -110,24 +122,26 @@ private extension TodayConditionButton {
nameLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
nameLabel.textAlignment = .left
nameLabel.text = conditionType.localized
addSubview(nameLabel)
containerView.addSubview(nameLabel)
nameLabel.snp.makeConstraints { (make) in
make.left.equalTo(valueLabel)
make.right.lessThanOrEqualToSuperview().inset(20)
make.top.equalTo(valueLabel.snp.bottom).offset(2)
make.bottom.equalToSuperview().inset(20)
}
//Description
descriptionLabel.isUserInteractionEnabled = false
descriptionLabel.font = AppFont.SFPro.regular(size: 12)
descriptionLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
descriptionLabel.textAlignment = .left
addSubview(descriptionLabel)
descriptionLabel.snp.makeConstraints { (make) in
make.left.right.equalToSuperview().inset(20)
make.top.equalTo(imageView.snp.bottom).offset(20)
make.bottom.equalToSuperview().inset(13)
}
// //Description
// descriptionLabel.isUserInteractionEnabled = false
// descriptionLabel.font = AppFont.SFPro.regular(size: 12)
// descriptionLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
// descriptionLabel.textAlignment = .left
// addSubview(descriptionLabel)
//
// descriptionLabel.snp.makeConstraints { (make) in
// make.left.right.equalToSuperview().inset(20)
// make.top.equalTo(imageView.snp.bottom).offset(20)
// make.bottom.equalToSuperview().inset(13)
// }
}
}
......@@ -59,7 +59,7 @@ private extension TodayConditionsCell {
scrollView.snp.makeConstraints { (make) in
make.left.right.equalToSuperview()
make.top.equalToSuperview().inset(18)
make.height.equalTo(115)
make.height.equalTo(90)
}
}
......@@ -78,6 +78,9 @@ private extension TodayConditionsCell {
for conditionType in WeatherConditionType.allCases {
let button = TodayConditionButton(type: conditionType)
stackView.addArrangedSubview(button)
button.snp.makeConstraints { (make) in
make.height.equalToSuperview()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment