Commit 98860eea by Demid Merzlyakov

AirQuality: colored text for pollutants status.

parent 8ced8829
...@@ -58,6 +58,49 @@ public enum HealthStatus: String { ...@@ -58,6 +58,49 @@ public enum HealthStatus: String {
return self.rawValue.localized() return self.rawValue.localized()
} }
public var textColor: UIColor {
get {
switch self {
case .good:
guard let result = UIColor(named: "good_text") else {
assertionFailure("Color not available fair quality good_textor !")
return UIColor(red: 8.0 / 255.0, green: 207.0 / 255.0, blue: 0.0 / 97.0, alpha: 1.0)
}
return result
case .moderate:
guard let result = UIColor(named: "moderate_text") else {
assertionFailure("Color not available for air quality moderate_text!")
return UIColor(red: 255.0 / 255.0, green: 191.0 / 255.0, blue: 69.0 / 255.0, alpha: 1.0)
}
return result
case .unhealthyForSensitiveGroups:
guard let result = UIColor(named: "unhealthy_for_sensitive_groups_text") else {
assertionFailure("Color not available for air quality unhealthy_for_sensitive_groups_text!")
return UIColor(red: 255.0 / 255.0, green: 127.0 / 255.0, blue: 0.0 / 255.0, alpha: 1.0)
}
return result
case .unhealthy:
guard let result = UIColor(named: "unhealthy_text") else {
assertionFailure("Color not available for air quality unhealthy_text!")
return UIColor(red: 237.0 / 255.0, green: 81.0 / 255.0, blue: 81.0 / 255.0, alpha: 1.0)
}
return result
case .veryUnhealthy:
guard let result = UIColor(named: "very_unhealthy_text") else {
assertionFailure("Color not available for air quality very_unhealthy_text!")
return UIColor(red: 143.0 / 255.0, green: 63.0 / 255.0, blue: 151.0 / 255.0, alpha: 1.0)
}
return result
case .hazardous:
guard let result = UIColor(named: "hazardous_text") else {
assertionFailure("Color not available for air quality hazardous_text!")
return UIColor(red: 126.0 / 255.0, green: 0.0 / 255.0, blue: 34.0 / 255.0, alpha: 1.0)
}
return result
}
}
}
public var gradientColorStart: UIColor { public var gradientColorStart: UIColor {
get { get {
switch self { switch self {
......
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "97",
"green" : "207",
"red" : "8"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.380",
"green" : "0.812",
"red" : "0.031"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "36",
"green" : "20",
"red" : "115"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.143",
"green" : "0.080",
"red" : "0.452"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "69",
"green" : "191",
"red" : "255"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.272",
"green" : "0.748",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.341",
"green" : "0.362",
"red" : "0.863"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.341",
"green" : "0.362",
"red" : "0.863"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "81",
"green" : "81",
"red" : "238"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.317",
"green" : "0.318",
"red" : "0.932"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.578",
"green" : "0.266",
"red" : "0.523"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.578",
"green" : "0.266",
"red" : "0.523"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -42,6 +42,7 @@ class PollutantView: UIView { ...@@ -42,6 +42,7 @@ class PollutantView: UIView {
typeLabel.text = pollutant.name.localized typeLabel.text = pollutant.name.localized
valueLabel.text = "\(Int(pollutant.value))" valueLabel.text = "\(Int(pollutant.value))"
statusLabel.text = pollutant.status.localized statusLabel.text = pollutant.status.localized
statusLabel.textColor = pollutant.status.textColor
progressValue = pollutant.progress progressValue = pollutant.progress
progressGradient.colors = [pollutant.status.gradientColorStart.cgColor, progressGradient.colors = [pollutant.status.gradientColorStart.cgColor,
pollutant.status.gradientColorEnd.cgColor] pollutant.status.gradientColorEnd.cgColor]
......
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