Commit e5a7196d by Demid Merzlyakov

Today Conditions Cells layout changed to center vertically.

parent 9d247a4e
...@@ -14,13 +14,15 @@ class TodayConditionButton: UIControl { ...@@ -14,13 +14,15 @@ class TodayConditionButton: UIControl {
private let valueLabel = UILabel() private let valueLabel = UILabel()
private let nameLabel = UILabel() private let nameLabel = UILabel()
private let descriptionLabel = UILabel() private let descriptionLabel = UILabel()
private let containerView = UIView()
init(type: WeatherConditionType) { init(type: WeatherConditionType) {
self.conditionType = type self.conditionType = type
super.init(frame: .zero) super.init(frame: .zero)
prepareSelf()
prepareButton() prepareButton()
prepareSelf()
prepareContainer()
prepareImageView() prepareImageView()
prepareLabels() prepareLabels()
} }
...@@ -60,7 +62,16 @@ class TodayConditionButton: UIControl { ...@@ -60,7 +62,16 @@ class TodayConditionButton: UIControl {
private extension TodayConditionButton { private extension TodayConditionButton {
func prepareSelf() { func prepareSelf() {
snp.makeConstraints { (make) in 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 { ...@@ -82,7 +93,7 @@ private extension TodayConditionButton {
imageView.contentMode = .scaleAspectFit imageView.contentMode = .scaleAspectFit
imageView.clipsToBounds = true imageView.clipsToBounds = true
imageView.image = conditionType.image imageView.image = conditionType.image
addSubview(imageView) containerView.addSubview(imageView)
imageView.snp.makeConstraints { (make) in imageView.snp.makeConstraints { (make) in
make.left.top.equalToSuperview().inset(20) make.left.top.equalToSuperview().inset(20)
...@@ -97,10 +108,11 @@ private extension TodayConditionButton { ...@@ -97,10 +108,11 @@ private extension TodayConditionButton {
valueLabel.textColor = ThemeManager.currentTheme.secondaryTextColor valueLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
valueLabel.textAlignment = .left valueLabel.textAlignment = .left
valueLabel.text = "21%" valueLabel.text = "21%"
addSubview(valueLabel) containerView.addSubview(valueLabel)
valueLabel.snp.makeConstraints { (make) in valueLabel.snp.makeConstraints { (make) in
make.left.equalTo(imageView.snp.right).offset(13) make.left.equalTo(imageView.snp.right).offset(13)
make.right.lessThanOrEqualToSuperview().inset(20)
make.top.equalToSuperview().inset(16) make.top.equalToSuperview().inset(16)
} }
...@@ -110,24 +122,26 @@ private extension TodayConditionButton { ...@@ -110,24 +122,26 @@ private extension TodayConditionButton {
nameLabel.textColor = ThemeManager.currentTheme.secondaryTextColor nameLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
nameLabel.textAlignment = .left nameLabel.textAlignment = .left
nameLabel.text = conditionType.localized nameLabel.text = conditionType.localized
addSubview(nameLabel) containerView.addSubview(nameLabel)
nameLabel.snp.makeConstraints { (make) in nameLabel.snp.makeConstraints { (make) in
make.left.equalTo(valueLabel) make.left.equalTo(valueLabel)
make.right.lessThanOrEqualToSuperview().inset(20)
make.top.equalTo(valueLabel.snp.bottom).offset(2) make.top.equalTo(valueLabel.snp.bottom).offset(2)
make.bottom.equalToSuperview().inset(20)
} }
//Description // //Description
descriptionLabel.isUserInteractionEnabled = false // descriptionLabel.isUserInteractionEnabled = false
descriptionLabel.font = AppFont.SFPro.regular(size: 12) // descriptionLabel.font = AppFont.SFPro.regular(size: 12)
descriptionLabel.textColor = ThemeManager.currentTheme.secondaryTextColor // descriptionLabel.textColor = ThemeManager.currentTheme.secondaryTextColor
descriptionLabel.textAlignment = .left // descriptionLabel.textAlignment = .left
addSubview(descriptionLabel) // addSubview(descriptionLabel)
//
descriptionLabel.snp.makeConstraints { (make) in // descriptionLabel.snp.makeConstraints { (make) in
make.left.right.equalToSuperview().inset(20) // make.left.right.equalToSuperview().inset(20)
make.top.equalTo(imageView.snp.bottom).offset(20) // make.top.equalTo(imageView.snp.bottom).offset(20)
make.bottom.equalToSuperview().inset(13) // make.bottom.equalToSuperview().inset(13)
} // }
} }
} }
...@@ -59,7 +59,7 @@ private extension TodayConditionsCell { ...@@ -59,7 +59,7 @@ private extension TodayConditionsCell {
scrollView.snp.makeConstraints { (make) in scrollView.snp.makeConstraints { (make) in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalToSuperview().inset(18) make.top.equalToSuperview().inset(18)
make.height.equalTo(115) make.height.equalTo(90)
} }
} }
...@@ -78,6 +78,9 @@ private extension TodayConditionsCell { ...@@ -78,6 +78,9 @@ private extension TodayConditionsCell {
for conditionType in WeatherConditionType.allCases { for conditionType in WeatherConditionType.allCases {
let button = TodayConditionButton(type: conditionType) let button = TodayConditionButton(type: conditionType)
stackView.addArrangedSubview(button) 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