Commit 8cb57fc3 by Demid Merzlyakov

IOS-22: additional wind smart text.

parent 40eab966
......@@ -36,11 +36,17 @@ private enum Macro: String {
func windType(from windSpeed: WindSpeed) -> String? {
let speedKPH = windSpeed.converted(to: .kilometersPerHour).value
guard speedKPH >= 75 else {
guard speedKPH >= 50 else {
return nil
}
var windType: String = ""
if speedKPH < 89 {
if speedKPH < 62 {
windType = "moderateGale"
}
else if speedKPH < 75 {
windType = "gale"
}
else if speedKPH < 89 {
windType = "strongGale"
}
else if speedKPH < 103 {
......@@ -194,9 +200,10 @@ fileprivate struct ApproachingPrecipitationSmartText: SmartText {
}
}
fileprivate struct StrongWindSmartText: SmartText {
let templateKey: String = "today.smart.strongWind"
fileprivate struct WindSmartText: SmartText {
let templateKey: String = "today.smart.wind"
let requiredMacros: [Macro] = [.windType, .windSpeed, .windDirection]
let minAllowedWindSpeed: WindSpeed
func applicable(to location: Location) -> Bool {
guard let today = location.today else {
......@@ -205,7 +212,7 @@ fileprivate struct StrongWindSmartText: SmartText {
guard let windSpeed = today.windSpeed, let _ = today.windDirection else {
return false
}
return windSpeed.converted(to: .kilometersPerHour).value >= 75
return windSpeed >= minAllowedWindSpeed
}
}
......@@ -225,9 +232,9 @@ class SmartTextProvider {
private var prioritizedSmartTexts: [SmartText] = [
OngoingPrecipitationSmartText(),
ApproachingPrecipitationSmartText(),
StrongWindSmartText(),
WindSmartText(minAllowedWindSpeed: WindSpeed(value: 75, unit: .kilometersPerHour)),
HumiditySmartText(),
//Continue adding here.
WindSmartText(minAllowedWindSpeed: WindSpeed(value: 50, unit: .kilometersPerHour)),
DefaultSmartText()]
......
......@@ -39,7 +39,7 @@
"today.smart.default" = "Feels like #FEELS_LIKE_TEMP#.";
"today.smart.ongoingPrecipitation" = "#WEATHER_TYPE# until #WEATHER_TYPE_CHANGE_HOUR#.";
"today.smart.approachingPrecipitation" = "#EXPECTED_PRECIPITATION_PROBABILITY#% chance of #EXPECTED_PRECIPITATION_WEATHER_TYPE# by #EXPECTED_PRECIPITATION_HOUR#.";
"today.smart.strongWind" = "#WIND_TYPE# - #WIND_SPEED# blowing from #WIND_DIRECTION#.";
"today.smart.wind" = "#WIND_TYPE# - #WIND_SPEED# blowing from #WIND_DIRECTION#.";
"today.smart.humidity" = "Feels like #FEELS_LIKE_TEMP# due to #HUMIDITY_TYPE# humidity (#HUMIDITY#%).";
//Forecast
......@@ -255,6 +255,8 @@
"wind.direction.NNW" = "North North West";
// Wind type
"wind.type.moderateGale" = "Moderate gale";
"wind.type.gale" = "Gale";
"wind.type.strongGale" = "Strong gale";
"wind.type.storm" = "Storm";
"wind.type.violentStorm" = "Violent storm";
......
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