Skip to content

Time-of-day backgrounds

The start screen and the home screen widget sit on a picture of the time of day. There are six, all drawn the same low-poly way as the fencer avatar: faceted sky, a faceted sun or moon, and three ridges of faceted hills.

Scene Begins Look
Early morning 5:00 a.m. Muted lavender and peach, the sun rising
Morning 7:00 a.m. Bright sky blue, the sun low on the left, clouds
Midday 11:00 a.m. Bright azure, the sun high, clouds
Afternoon 2:00 p.m. Bright blue going golden, the sun on the right
Evening 5:00 p.m. Bright sunset: lilac, pink, and orange, a low sun
Night 8:00 p.m. Muted purple, a soft moon and stars

The hours are fixed clock hours on the phone, the same in every season. They are not worked out from sunrise and sunset where the senior lives.

Reading the text on top

Text sits right on these pictures, so the picture decides the text color, not the phone's appearance setting:

  • Early morning and the four daylight scenes use the light scheme: dark text (#11181C).
  • Night uses the dark scheme: light text (#ECEFF1).

Every facet in a scene has at least 4.5:1 contrast with that scene's text. The drawing script nudges any facet that falls short lighter or darker until it passes. tests/time-of-day.test.ts reads every fill in every SVG and fails the build if one drops below 4.5:1. That is why the night moon is soft rather than bright: a bright moon behind light text could not be read.

On the start screen, ForcedColorScheme (src/features/settings/appearance.tsx) draws the whole screen in the scene's scheme, including the Memories button, the settings menu, and the status bar. A senior who chose Dark under Appearance still sees dark text on the daylight scenes. Text size and font still follow their settings. The loading line and the version number on this screen use the full text color rather than the muted one, because muted text would not reach 4.5:1 on the pictures. The greeting at the top sits on a veil of the scheme's surface color at 92% (veil in src/theme/colors.ts), so it reads at 13:1 and better over every facet; the picture tests check that too.

A golf hole on the ground

The ground under the sky is a golf course, one hole a day, drawn as a transparent overlay on these same canvases so the sky shows through above it. It is drawn twice, by day and by night, to read under each scheme's text. See The golf course.

Where the code is

  • src/features/time-of-day/scenes.json holds each scene's hour, scheme, text color, and drawing palette. The app and the drawing script both read it.
  • src/features/time-of-day/scenes.ts lists the pictures and answers "which scene is it now" (sceneAt), "when does it change next" (nextChange), and "what are the changes over the next few days" (sceneSchedule).
  • src/features/time-of-day/use-time-of-day.ts keeps the start screen current: a timer for the next change while the app is open, and a fresh look each time the app comes back to the front.
  • The start screen is StartScreen in src/features/memories/memories-screen.tsx. The picture is decoration and hidden from screen readers. It covers the window, so on an iPad or in landscape it is cropped, centered, rather than stretched.

On the widget

A widget cannot run code on its own schedule. Instead, the app hands it a timeline: one entry per scene change for the next seven days, each naming that scene's background and text color. iOS switches the picture at each entry while the app is closed (src/features/widget/sync-memories-widget.ts).

The app writes a fresh timeline at launch and every time it comes back from the background. If the app goes unopened for more than a week, the widget keeps the last scene until the app is opened again.

The widget has its content margins turned off (contentMarginsDisabled in app.config.ts) so the picture reaches its edges. That setting is native, so it needs a new build, not an over-the-air update. See Home screen widget.

Changing a picture

Edit the scene's palette or hour in scenes.json, or the drawing in scripts/render-time-of-day.mjs, then run:

cd ~/Documents/GitHub/SilverApp && pnpm backgrounds:render

It needs ImageMagick 7 (brew install imagemagick). For each scene it writes two SVGs and their PNGs into apps/mobile/assets/images/time-of-day/:

  • <id>.png, 1290 by 2796, for the start screen.
  • <id>-widget.png, 640 by 640, for the widget. It stays small because WidgetKit refuses to show an image much larger than the widget itself.

The drawing is seeded by scene name, so running the script again without changes draws the same pictures. Never edit the SVGs or PNGs by hand. Run the tests afterward; the contrast check is the one that matters.

Adding a seventh scene means a new entry in scenes.json, two new require lines in scenes.ts (paths must stay literal), and a new id in TimeOfDayId.