Style the weather forecast after classic cable graphics

This commit is contained in:
Josh
2026-11-13 15:16:28 -05:00
parent ccec1e7044
commit 61bff9a6e6
4 changed files with 74 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
sub initWeather()
for each id in ["weatherLocation", "weatherHeading", "weatherBody", "weatherAlerts", "weatherSource", "weatherRotation", "weatherRefresh", "weatherAudio", "weatherPreviewFrame", "weatherPreviewLabel"]
for each id in ["weatherLocation", "weatherHeading", "weatherBody", "weatherAlerts", "weatherSource", "weatherRotation", "weatherRefresh", "weatherAudio", "weatherPreviewFrame", "weatherPreviewLabel", "forecastCards"]
m[id] = m.top.FindNode(id)
end for
m.weatherRotation.ObserveField("fire", "rotateWeather")
@@ -9,6 +9,8 @@ end sub
sub startWeather()
m.weatherPage = 0
m.weatherData = invalid
m.forecastCards.visible = false
m.weatherBody.visible = true
m.weatherLocation.text = ""
m.weatherHeading.text = "Loading local weather"
m.weatherBody.text = ""
@@ -90,6 +92,8 @@ sub rotateWeather()
end sub
sub renderWeather()
m.forecastCards.visible = false
m.weatherBody.visible = true
data = m.weatherData
m.weatherAlerts.text = ""
m.weatherSource.text = ""
@@ -134,8 +138,9 @@ sub renderWeather()
periods = data.hourly
m.weatherHeading.text = "NEXT SIX HOURS"
if m.weatherPage = 2
periods = data.forecast
m.weatherHeading.text = "EXTENDED FORECAST"
if showForecastCards(data.forecast) then return
periods = data.forecast
end if
lines = []
for each period in periods
@@ -162,3 +167,24 @@ sub updateWeatherMusic(path as dynamic)
m.weatherAudio.content = track
m.weatherAudio.control = "play"
end sub
function showForecastCards(periods as object) as boolean
days = []
for i = 0 to periods.Count() - 2
day = periods[i]
night = periods[i + 1]
if day.daytime = true and night.daytime = false then days.Push({day: day, night: night})
if days.Count() = 3 then exit for
end for
if days.Count() < 3 then return false
for i = 0 to 2
suffix = StrI(i).Trim()
forecast = days[i]
m.top.FindNode("forecastDay" + suffix).text = UCase(forecast.day.name)
m.top.FindNode("forecastCondition" + suffix).text = forecast.day.conditions
m.top.FindNode("forecastTemps" + suffix).text = "Lo " + tempLabel(forecast.night.temperature) + " Hi " + tempLabel(forecast.day.temperature)
end for
m.weatherBody.visible = false
m.forecastCards.visible = true
return true
end function