Skip to content

Commit

Permalink
Issue #416: Show heating indicator when thermostat mode is off
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed Sep 25, 2024
1 parent 7e5652d commit d5994db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions SUPLA/Core/UI/Buttons/UIIconButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ class UIIconButton: UIButton {
}

private func setColors() {
backgroundColor = isEnabled ? config.backgroundColor : config.backgroundDisabledColor
tintColor = isEnabled ? config.contentColor : config.contentDisabledColor

if let borderColor = config.borderColor {
layer.borderColor = isEnabled ? borderColor.cgColor : config.contentDisabledColor.cgColor
layer.borderWidth = 1
traitCollection.performAsCurrent {
backgroundColor = isEnabled ? config.backgroundColor : config.backgroundDisabledColor
tintColor = isEnabled ? config.contentColor : config.contentDisabledColor

if let borderColor = config.borderColor {
layer.borderColor = isEnabled ? borderColor.cgColor : config.contentDisabledColor.cgColor
layer.borderWidth = 1
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions SUPLA/Core/UI/Views/ThermostatControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ final class ThermostatControlView: UIView {
var currentPower: Int = 0 {
didSet {
temperatureCircleShape.currentPower = currentPower
currentPowerLabel.isHidden = !operationalMode.isStrictHeating && !operationalMode.isStrictCooling || currentPower <= 1
currentPowerLabel.isHidden = !operationalMode.isHeating && !operationalMode.isCooling || currentPower <= 1
currentPowerLabel.text = "\(currentPower - 1)%"

setNeedsLayout()
Expand Down Expand Up @@ -251,7 +251,7 @@ final class ThermostatControlView: UIView {
height: maxTemperatureView.intrinsicContentSize.height
)

let correction: CGFloat = (operationalMode.isStrictCooling || operationalMode.isStrictHeating) && currentPower > 1 ? 75 : 55
let correction: CGFloat = (operationalMode.isCooling || operationalMode.isHeating) && currentPower > 1 ? 75 : 55
indicatorHeatingShape.position = CGPoint(x: frame.width / 2, y: frame.height / 2 - correction)
indicatorCoolingShape.position = CGPoint(x: frame.width / 2, y: frame.height / 2 + correction)

Expand Down Expand Up @@ -416,7 +416,7 @@ private class TemperatureCircleLayer: CAShapeLayer {

var operationalMode: ThermostatOperationalMode = .offline {
didSet {
let powerHidden = !operationalMode.isStrictCooling && !operationalMode.isStrictHeating || currentPower <= 1
let powerHidden = !operationalMode.isCooling && !operationalMode.isHeating || currentPower <= 1
powerBackgroundSublayer.isHidden = powerHidden
powerIndicatorSublayer.isHidden = powerHidden

Expand All @@ -429,7 +429,7 @@ private class TemperatureCircleLayer: CAShapeLayer {

var currentPower: Int = 0 {
didSet {
let powerHidden = !operationalMode.isStrictCooling && !operationalMode.isStrictHeating || currentPower <= 1
let powerHidden = !operationalMode.isCooling && !operationalMode.isHeating || currentPower <= 1
powerBackgroundSublayer.isHidden = powerHidden
powerIndicatorSublayer.isHidden = powerHidden

Expand Down

0 comments on commit d5994db

Please sign in to comment.