Files
DroidDeck/docs/compose-previews.md
JRAlmonte 1a7a116939 feat(ui): add frosted launcher wallpaper and cards (#3559)
Add opt-in frosted wallpaper and cards with separate transparency settings. Keep dialogs solid and fall back to the standard palette when blur or readable contrast is unavailable.
2026-12-02 15:48:36 -05:00

2.1 KiB

Compose previews

Previews show production composables with sample data, without a device, the Linux runtime or a network. Use them in two ways:

  • Android Studio: select the debug build variant and open app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt in Split or Design view.

  • Rendered to PNG files, with no Studio or device needed (also how an agent can look at a UI change):

    ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'
    

    Each preview is drawn with Robolectric's native graphics at handheld (960x540 dp at xhdpi, the Duo's top screen, 1920x1080 px) and portrait (540x960 dp) sizes, into app/build/preview-renders/{handheld,portrait}/<case>.png. The test fails if a preview throws, or draws a single flat colour.

Files

File What
app/src/debug/.../ui/PreviewSupport.kt PreviewHost (the production theme), @DroidDeckPreviews (the two sizes), sample FrontEndState, no-op FrontEndActions and DrawerActions, sample games
app/src/debug/.../ui/LauncherPreviews.kt The previews, and previewCases, the list the render test draws
app/src/testDebug/.../ui/PreviewRenderTest.kt The render test

Previews cover the launcher on each tab (Steam, Library, Library with no games, Stores, Downloads, Settings, Settings with no runtime), the in-game menu's pages (Controller, Display, HUD, Session, and the Desktop menu), and the frosted background: the Steam and Library tabs, Settings with frosted cards and with both transparencies at 100 %, and a settings step opened over frosted page text.

Adding one

Write the preview in LauncherPreviews.kt (or a new file beside it) with @DroidDeckPreviews, wrapping the content in PreviewHost. Add a PreviewCase to previewCases so it is rendered and checked too. The launcher opens on a tab via sampleState(navigate = "<tab key>").

Everything here is in the debug source sets, so none of it ships in release builds. Sample art is left out, so cards use their fallback gradients. Previews check layout and look; they do not exercise launching, input or the runtime.