A Series of Upcoming Days
Calculation is based on a horizontal stack of data groups. Each data group contains all the info for that day. (This is basically a glorified daily forecast blueprint.)
Global Formulas
To get the index of the group for the data inside it, create a global text:
gv(index)
$si(mindex, 3)$
Can be different based on how you set up groups.To get the number for each day create a global text with this formula:
gv(day)
$df(d, a+gv(index)+d)$
You can also display the weekday with another global text:
gv(weekday)
$df(E, a+gv(index)+d)$
Making the Group
Make a horizontal stack group;
in it, create an overlap (or vertical stack) group;
inside it, add a text object linked to the Day global formula above.
Just copy and paste the group as many times as you like and the days will be generated automatically.
NOTE: The second group is unnecessary just for a simple series of days, but we'll need it later for adding more info to each day - so better always use it as it makes expanding the widget's functionality easier.
Additionally you can highlight the current day text by using this formula to show a different text color:
$if(gv(index) = 0, COLOR0, COLOR1)$
Replace COLOR0 and COLOR1 with the preferred HEX values (I suggest you use globals).You can also use that formula to show an indicator for the current day.
You can also change the color of the weekend days by using this formula to show a different text color:
$if(df(f, a+gv(index)+d) > 5, COLOR0, COLOR1)$
Replace COLOR0 and COLOR1 with the preferred HEX values (I suggest you use globals).Show Events
To add event indicators to the series we need two more globals (which you'll recognize from the Calendar blueprint).
Global Formulas
We need to get the date of each day and the number of events for that specific date.
To get the date for each day, create a global text with this formula:
gv(daydate)
$dp(a+gv(index)+d)$
To get the number of events for each date, create a global text with this formula:
gv(dayevent)
$ci(ecount, gv(daydate)) + ci(acount, gv(daydate))$
Making the Group
Inside the group that holds the text object for the Day formula add a shape (or a number).
If you chose a number, make it show $gv(dayevent)$.
If you chose a shape, change its color like so:
$ce(COLOR, alpha, 100*(gv(dayevent)>0))$
Replace COLOR with the preferred HEX value (I suggest you use globals).Scroll Through Events for a Chosen Day
Here we need to add globals from the Events blueprint, just like in the Calendar blueprint. First a blank text global for the chosen date, a global that calculates the number of events on that date and another global for a chosen event. Then we also need globals for events' info.
To hold the chosen date, add a text global:
gv(date)
To calculate the number of events on the chosen date, add a text global:
gv(events)
$ci(ecount, gv(date)) + ci(acount, gv(date))$
To hold the index number of the chosen event, add a text global:
gv(event)
To pick the chosen date you could simply use gv(daydate), but then that date will remain set until you pick another one, even when the day changes (displayed events in agenda will be from past days). So I suggest you go one step further and make it reset every time you tap on today's group. For that add a text global:
gv(touchday)
$if(df(D, gv(daydate)) = df(D), "$dp()$", gv(daydate))$
Their code has pretty much the same structure, so just like for the calendar, this example will contain only the title of the event.
gv(title)
$ci(title, gv(event), gv(date))$
Adding Touch Actions
Make sure the base of the Day group has the same index as the other data and add a touch action to it:
Action = Toggle Globlal Switch
Switch = gv(date)
Text = $gv(touchday)$
Add another touch action to reset gv(event) to 0 every time you switch dates:
Action = Toggle Global Switch
Switch = gv(event)
Text = 0
NOTE: The touch area has to have the same index as the day number, events indicators and forecast info.
Making the Event Group
Like in the Events blueprint add two buttons and a stack of data.
The index of the objects in the stack doesn't matter here, but it is suggested that it has the same structure as the agenda.
Add a text item in the stack and make it show $gv(title)$.
Add touch actions to the buttons that will switch between previous and next events:
Action = Toggle Global Switch
Switch = gv(event)
Text Text =
Previous:
$if(gv(event) > 0, gv(event)-1, 0)$
Next:
$if(gv(event)+1 >= gv(events), gv(events)-1, gv(event)+1)$
List All Events for a Chosen Day
This part is the same as before with a few key differences.
Global Formulas
The Event global is not blank:
gv(event)
$si(mindex, 2)$
This is now the index for events (like in the agenda).We also need another global from Agenda blueprint:
HideEvnt
$if(si(mindex) < gv(events), ALWAYS, REMOVE)$
There is NO touch action to reset gv(event) to 0 on day groups!
Making the Event Group
Like in the Agenda blueprint add a stack of multiple event groups.
Apply HideEvnt as the visibility formula for each group.
Every event group contains more groups, each holding a piece of event's information.
Add a text item in its own group inside the Event stack group and make it show $gv(title)$.
Do the same for all other agenda globals.
NOTE: Keep the index of the objects in the stack the same.
Add a Forecast
Well, all you have to do is copy the forecast blueprint. (You can even use gv(interval) and gv(offset), if you adjust the index accordingly, but I'd advise against it for most use cases.)
Global Formulas
To get the weather condition icon for each day, create a global text:
gv(wicon)
$wf(icon, gv(index)) + ai(isday)$
Returns the equivalent of $wi(icon)+ai(isday)$. Change based on the weather icon pack.To get the average temperature for each day, create a global text:
gv(temp)
$wf(temp, gv(index))$
To get the maximum temperature for each day, create a global text:
gv(tempmax)
$wf(max, gv(index))$
To get the minimum temperature for each day, create a global text:
gv(tempmin)
$wf(min, gv(index))$
Adding to the Day Group's Contents
If you used the stack group to create the series of days in step one, simply add more text objects and an icon, linking them to the globals above.
Copyright (c) 2021 Erik Bucik
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kustom formatted version