Commit 2ecc807f by Demid Merzlyakov

AQI: scaled the circular air quality gradient to make it look nicer.

parent c25ff0f3
......@@ -17,11 +17,19 @@ public struct Health: Equatable, Hashable {
public struct AirQuality: Equatable, Hashable {
public let index: Double
public let advice: String //TODO: support for localization
public var progress:CGFloat {
var progressValue = max(0, CGFloat(index / 500))
public let progress: CGFloat
public init(index: Double, advice: String) {
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.
progressValue = max(0, progressValue)
progressValue = min(1, progressValue)
return progressValue
self.progress = progressValue
}
public var status: HealthStatus {
switch index {
case 0...50: return .good
......
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