Recipes
Ten things themes actually need, as steps in the editor: a clock, page dots, filter chips, a card that folds open, a search box, a staggered list.
On this page
- A clock that does not jitter
- Fade something out while swiping away
- Page dots
- A colour that follows dark mode
- A row of filter chips
- A card that folds open when tapped
- A search box
- A permission hint that disappears
- A list that arrives one card at a time
- A dock that works on a phone you have never seen
- A section that only exists at night
Each of these is a combination of things described elsewhere. They are here because knowing every part does not always show you the assembly.
They are written as what you do in the editor: which tab, which field, what to type into it. Anything in monospace is typed literally.
A clock that does not jitter#
+ → Text. In Text, set the content to:
$format(time_hour, '00')$:$format(time_minute, '00')$Then, in Position, give it a fixed Width, around 220 for a large clock.
Two details do the work. format(…, '00') keeps the digits two wide; without it 9:07 reads 9:7 and the text changes width every minute. The fixed width keeps whatever sits beside the clock from shifting when the hour rolls from 09 to 10.
Do not mention time_second anywhere in a clock without seconds, not even inside a rounding expression: the name alone makes the element re-evaluate every second forever.
Fade something out while swiping away#
Select the element, Appearance → Opacity → Σ. Under Ready-made, the entry "fade out while swiping pages" inserts:
$clamp(1 - abs(page_position), 0, 1)$page_position is 0 while this page is centred and moves toward ±1 as you swipe off it. This follows the finger exactly and costs nothing beyond the frames the swipe is already drawing. It is the pattern almost every "animation" in a good theme turns out to be.
For a parallax, put this in Position → Translate X instead:
$page_position * -40$Page dots#
There is no dots element. You place one small shape per page and let each read the position.
+ → Shape, set Appearance → Shape to circle and its size to 8. Then, in Background colour → Σ:
$page_index == 0 ? '#FFFFFFFF' : '#55FFFFFF'$Duplicate it for each page, moving each 20 dp along in Position → X and changing the number it compares against. Add Position → Scale with $page_index == 0 ? 1.3 : 1$ and the active dot grows.
To make the change follow the swipe rather than snap halfway, use the fractional position in Opacity instead: $clamp(1 - abs(page_position), 0.3, 1)$.
A colour that follows dark mode#
Any colour field → Σ → Ready-made → "one value in dark mode, another in light":
$dark_mode ? '#FFFFFFFF' : '#FF101014'$Both branches are quoted. An unquoted #FFFFFFFF is read as a variable, found to be nothing, and the element ends up with no colour at all.
The moment a second element needs the same colour, move it to the Variables tab and point both at it; see variables of your own.
A row of filter chips#
The reader's own feeds, as chips that filter the article list. Nothing here is a special feature: a repeater, an action and a filter.
- + → Repeater. In Behavior, set Source to
feed_sourcesand Direction to horizontal. - Inside it, add a Text element. Its content is
$item_name$. - Its Background colour → Σ:
$feed_filter == item_id ? '#FF7A5CFF' : '#22FFFFFF'$ - Its Behavior → Actions → add one: trigger Tap, action Set variable, value
feed_filter=$feed_filter == item_id ? '' : item_id$ - On the article list, Behavior → Filter:
$feed_filter == '' || item_feed_id == feed_filter$ - In Variables, add
feed_filterwith an empty value so the list starts unfiltered.
Step 4 writes the chip's own id, or clears the variable when that chip is already active, so tapping the same chip twice returns to "everything".
A card that folds open when tapped#
One variable holds which card is open; the card reads it in two fields.
On the repeater, Behavior → Row height:
$feed_open == item_link ? 320 : 96$On the card's text, Text → Max lines:
$feed_open == item_link ? 40 : 2$And an action on the card: trigger Tap, action Set variable, value feed_open=$feed_open == item_link ? '' : item_link$
Storing the entry's link rather than a flag means only one card is open at a time, without anything to close the others.
A search box#
+ → Input field. In Behavior, set Write to variable to query, then add an action: trigger Submit, action Open URL, value $default_search_url$.
Submit is the keyboard's enter key, and adding the action is what puts a search key on the keyboard. That is the whole search box. Add + → Icon with search and the same action on Tap if you also want something to press.
default_search_url is the engine the reader chose. Do not put a provider's address into a published theme. Several of the engines on offer were picked precisely because they do not profile the person searching, and hard-coding one quietly overrides that.
A permission hint that disappears#
Build the row, then in Position → Hidden:
$notification_access$and an action: trigger Tap, action Notification access.
The row exists only while the permission is missing and opens the settings screen when tapped. Without something like it, badges are simply absent and look like "no notifications".
The same shape works for a Private Space section, with the extra rule that a space the reader chose to hide while locked must not be visible at all. See work profiles and Private Space.
A list that arrives one card at a time#
On the repeater's card, Animation → add one: trigger Appear, property Translate Y, from 24, to 0, and Delay:
$item_is_new == '1' ? item_index * 40 : 0$Guarding the delay with item_is_new means the stagger runs for entries that were not there before, and everything else simply appears. Otherwise the whole list replays its entrance every time the page is opened, which is charming twice and tiresome afterwards.
Keep the total under a few hundred milliseconds.
A dock that works on a phone you have never seen#
On the background layer, + → App grid. In Behavior, set Mode to manual and Columns to 4; turn labels off.
Fill the slots by long-pressing one and choosing a default app rather than a specific one. the browser, the phone, the camera. A slot filled that way follows whatever the reader has chosen, so the dock works on a device you have never seen. A slot filled with a named app shows a gap for anyone who does not have it.
In Position → Y:
$screen_height - nav_bar_height - 96$measured from the bottom of the actual screen, rather than a number that happened to be right on yours.
A section that only exists at night#
Position → Hidden:
$!(time_hour >= 22 || time_hour < 6)$Hidden, not opacity. A hidden element is not measured, not drawn, and its formulas are not evaluated. An element at zero opacity is all three, and still catches taps, which is how a theme ends up with icons that cannot be tapped.
Documentation for launcher 0.1.0-alpha Android 12 and later last updated