Style the weather forecast after classic cable graphics
This commit is contained in:
@@ -6,22 +6,60 @@
|
||||
<children>
|
||||
<Audio id="weatherAudio" loop="true" />
|
||||
<Group id="weather" visible="false">
|
||||
<Rectangle width="1280" height="720" color="0x122D62FF" />
|
||||
<Rectangle translation="[70,120]" width="1140" height="5" color="0x78E5EBFF" />
|
||||
<Rectangle width="1280" height="720" color="0x21114FFF" />
|
||||
<Rectangle translation="[70,120]" width="1140" height="5" color="0xFFC45CFF" />
|
||||
<Label translation="[70,55]" width="900" height="55" text="retroLabs Weather"
|
||||
font="font:LargeBoldSystemFont" color="0xF8F7EFFF" />
|
||||
font="font:LargeBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="weatherLocation" translation="[70,135]" width="1140" height="50"
|
||||
font="font:MediumBoldSystemFont" color="0x78E5EBFF" />
|
||||
<Label id="weatherHeading" translation="[70,198]" width="1140" height="42"
|
||||
font="font:MediumBoldSystemFont" />
|
||||
<Label id="weatherBody" translation="[70,252]" width="700" height="285"
|
||||
<Rectangle translation="[66,248]" width="708" height="293" color="0xCF8B38FF" />
|
||||
<Rectangle translation="[69,251]" width="702" height="287" color="0x233A99FF" />
|
||||
<Label id="weatherBody" translation="[87,267]" width="663" height="285"
|
||||
font="font:SmallSystemFont" wrap="true" numLines="8" />
|
||||
<Group id="forecastCards" translation="[70,251]" visible="false">
|
||||
<Group translation="[0,0]">
|
||||
<Rectangle width="232" height="287" color="0xCE8B38FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="281" color="0x2943A8FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="54" color="0x342371FF" />
|
||||
<Label id="forecastDay0" translation="[8,9]" width="216" height="42"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="forecastCondition0" translation="[16,83]" width="200" height="100"
|
||||
horizAlign="center" vertAlign="center" wrap="true" numLines="3" font="font:SmallSystemFont" />
|
||||
<Label id="forecastTemps0" translation="[8,213]" width="216" height="50"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" />
|
||||
</Group>
|
||||
<Group translation="[234,0]">
|
||||
<Rectangle width="232" height="287" color="0xCE8B38FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="281" color="0x2943A8FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="54" color="0x342371FF" />
|
||||
<Label id="forecastDay1" translation="[8,9]" width="216" height="42"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="forecastCondition1" translation="[16,83]" width="200" height="100"
|
||||
horizAlign="center" vertAlign="center" wrap="true" numLines="3" font="font:SmallSystemFont" />
|
||||
<Label id="forecastTemps1" translation="[8,213]" width="216" height="50"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" />
|
||||
</Group>
|
||||
<Group translation="[468,0]">
|
||||
<Rectangle width="232" height="287" color="0xCE8B38FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="281" color="0x2943A8FF" />
|
||||
<Rectangle translation="[3,3]" width="226" height="54" color="0x342371FF" />
|
||||
<Label id="forecastDay2" translation="[8,9]" width="216" height="42"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" color="0xFFE192FF" />
|
||||
<Label id="forecastCondition2" translation="[16,83]" width="200" height="100"
|
||||
horizAlign="center" vertAlign="center" wrap="true" numLines="3" font="font:SmallSystemFont" />
|
||||
<Label id="forecastTemps2" translation="[8,213]" width="216" height="50"
|
||||
horizAlign="center" font="font:SmallBoldSystemFont" />
|
||||
</Group>
|
||||
</Group>
|
||||
<Rectangle id="weatherPreviewFrame" translation="[800,208]" width="416" height="238"
|
||||
color="0x78E5EBFF" visible="false" />
|
||||
<Label id="weatherPreviewLabel" translation="[802,454]" width="412" height="70"
|
||||
font="font:SmallBoldSystemFont" wrap="true" numLines="2" />
|
||||
<Label id="weatherAlerts" translation="[70,553]" width="1140" height="74"
|
||||
font="font:SmallBoldSystemFont" color="0xFFD57AFF" wrap="true" numLines="2" />
|
||||
<Rectangle translation="[0,637]" width="1280" height="83" color="0x171D54FF" />
|
||||
<Label id="weatherSource" translation="[70,646]" width="1140" height="32"
|
||||
font="font:SmallSystemFont" color="0xB7D4E9FF" />
|
||||
</Group>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user