Commit 3d8b7b8f by Demid Merzlyakov

Fix Health progress / status issues.

parent 410cb441
......@@ -17,7 +17,7 @@ public struct AirQuality: Equatable, Hashable {
self.index = index
self.advice = advice
var progressValue = CGFloat(sqrt(0.1 + (index * 0.9) / 400)) // just to make it look nicer, so that we didn't have too short gradient circle in areas with generally good air.
var progressValue = CGFloat(sqrt(0.1 + (max(index, 0) * 0.9) / 400)) // just to make it look nicer, so that we didn't have too short gradient circle in areas with generally good air.
progressValue = max(0, progressValue)
progressValue = min(1, progressValue)
......@@ -25,13 +25,21 @@ public struct AirQuality: Equatable, Hashable {
}
public var status: HealthStatus {
switch index {
case 0...50: return .good
case 51...100: return .moderate
case 101...150: return .unhealthyForSensitiveGroups
case 151...200: return .unhealthy
case 201...300: return .veryUnhealthy
default: return .hazardous
if index <= 50 {
return .good
}
if index <= 100 {
return .moderate
}
if index <= 150 {
return .unhealthyForSensitiveGroups
}
if index <= 200 {
return .unhealthy
}
if index <= 300 {
return .veryUnhealthy
}
return .hazardous
}
}
......@@ -50,7 +50,7 @@ public struct Pollutant: Equatable, Hashable {
self.status = statusValue
if let hazardousLevelStart = self.hazardousLevelStart {
var progressValue = max(0, CGFloat(0.1 + value * 0.9 / hazardousLevelStart))
var progressValue = CGFloat(sqrt(0.1 + max(0, value) * 0.9 / hazardousLevelStart))
progressValue = min(1, progressValue)
self.progress = progressValue
}
......
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