← All Guides
Chaining Flow Actions
While flows can be as simple as a single action, you can create much more powerful widgets by chaining flow actions together.
Variables
Variables are the key to connecting actions together, and connecting widgets to flows. A variable will take the output of one action, and feed it into a following action.
For instance, you could start with the result of 5 + 5
. Then you can use the result (Sum
) as the input of a multiplication problem: Sum * 2
.
The Add action will essentially perform the following algebraic expression: Sum = 5 + 5
. Then, you are able to use Sum in the Multiplication action as a variable.
Any variable in your flow is accessible from a connected widget.
Let’s take a look at how to do this by creating a Step Goal widget.
Step Goal Widget
To create this widget, we will need to get our current step count, as well as a percentage of how close we are to our goal of 10,000 steps.
Let’s get started with the flow.
- In your new flow, find the “Health Data” action and add it. Select “Steps” as the data, and grant Power Widgets access to your step count if needed.
- Try running the flow. You should see your current step count appear. However, we need the step count to be a percentage (that is, a decimal between 0 and 1). To do this, we can divide the step count by our goal, 10,000 steps.
- In the math category, choose the “Divide” action.
- Tap in the dividend field and choose the Steps variable from the bar just above your keyboard. In the divisor field, enter your goal, 10000.
- Now try running your flow. You should see two numbers: your current step count, and the percentage.
The flow is now ready to be used in a widget:
- Create a new widget, and use the template “Ring Graph”. This will get us closest to the desired result. Name your widget, and connect the “Step Goal” flow.
- Tap into the “Percent Filled” field, and select the Quotient variable. This will enter the result of your division into the widget. Tap “Add Widget”.
- We want to display the total step count in the center of the ring graph, not the percentage. Select your widget in the gallery to open the editor.
- Tap on the percentage to open its edit sheet.
- Set the format to “Decimal”.
- Tap on Quotient to remove it.
- Tap in the number field, and select Steps in its place.
- Change the font size to 26.
Now you can see how close you are to your step goal straight from the Home Screen!
Previous
‹ Getting Started with Flows
Next
Secured Data Sources ›