Working-tree content. Subject to change and not yet released. Commit: e3d4530507.
Styling & theming
The app uses react-native-unistyles v3 for styles. Tokens (colors, spacing, fonts, breakpoints) live under src/core/theme/. The root unistyles.ts is the orchestration file that pulls those tokens in and calls StyleSheet.configure.
File layout
The split is intentional: tokens are values (live in src/core/theme/), and registration is a side effect (lives at root).
Setup chain
index.ts imports ./unistyles before expo-router/entry, so themes are registered before any screen mounts.
Theme shape
Using styles in a component
Variants
Use variants for prop-driven styling — variants compose into runtime styles without rerenders.
Gradients
Linear gradients are first-class theme tokens — defined once in
src/core/theme/gradients.ts and accessed as
theme.gradients.<name> from any StyleSheet.create((theme) => ...) block,
or applied to text via the <TextOutline gradient="...">
component.
Each gradient is a LinearGradientToken:
Adding a new gradient:
-
Add the entry under the same key in both
lightGradientsanddarkGradientsingradients.ts. Thesatisfies Record<keyof typeof lightGradients, LinearGradientToken>annotation ondarkGradientsenforces key parity at compile time. -
Pick light/dark color stops independently — gradients flip with the active theme just like
theme.colors.*. -
Reference it from a component:
Button fills accept the same token shape via
gradientFillon<PrimaryButton>, the app's one pill button — the gold monetisation CTA is itsvariant="premium"(subtitle,icon,contentLayout="spaceBetween",labelGradient,height,fullWidth/align; it starts atflex-startunless told otherwise). Its fills and content live beside it inPrimaryButtonFace.tsxandPrimaryButtonContent.tsx.gradientLight(Play),gradientLearnandpremiumare one view with no canvas: the pill wears its paint itself (playPillPaint,learnPillPaint;nativeLinearPaintfor the gold and the Shop's price fill), plus its ring and glow. A fill whose axis no CSS keyword can say stays a gradient view. Learn's design radials lean, which a CSS radial cannot: its four ellipses are upright ones fitted to them (colours and stops untouched; RMSE 1.8 of 255).gradientFilloverrides the variant's preset sweep (variant chrome — ring, glow, radius — is unchanged;gradientLight/gradientLearnpaint their own fill in place of an override).Its press, and the sparkles the call-to-action variants throw, are the app's button press.
One flat pill. Every variant is fully round with a 0.5pt ring, and the
Pressableitself carries the glow, ring, press and disabled dimming — no wrapper, glow or ring view. It must not clip (overflow: "hidden"cuts its own shadow): fills round themselves and the shine clips itself (ButtonShineclipRadius). Solid pills take a layer shadow; the see-throughgradientLearntakes aboxShadow. The white-50% ring is drawn by whatever paints on top (resolvePillRingHost: the native gradient view, or the pill itself). No part of a button draws on a Skia canvas: the old fills were removed after the native ones measured lighter on device (mounting 60 pills, DEV 2026-11: worst UI frame 141 → 35 ms for Play, 128 → 41 ms for Learn; some of the 60 were off screen, and scrolling was not measured).outlineDarkis two views: a blue pill under a native radial (uprightRadial,experimental_backgroundImageas a plain inline style) and a dark face inset 0.5pt:Or read the raw token from a stylesheet for a custom Skia surface:
TextOutline renders gradient text with
expo-linear-gradient + @react-native-masked-view/masked-view (no Skia
canvas). Outline and drop-shadow are layered RN <Text> duplicates behind the
fill.
GradientPill also accepts an optional
locations prop (0..1 stop positions) when used directly for low-level
expo-linear-gradient fills.
The angle convention for { angle: number } is screen-space: 0° runs
top → bottom, 90° runs left → right, 180° runs bottom → top, 270°
runs right → left. Negative or out-of-range angles are normalized into
[0, 360).
Theme switching at runtime
If you want OS-driven theming, replace initialTheme: 'dark' in StyleSheet.configure with adaptiveThemes: true and let Unistyles follow the system appearance.
Breakpoints
Registered with Unistyles:
Phone vs iPad is never a width breakpoint. Size for the device class with IS_TABLET
(@core/device/is-tablet) and scaleTypeForTablet (@core/device/tablet-type-scale):
A width breakpoint cannot tell the two apart: a landscape phone is 568–956 pt wide (md), a
portrait iPad mini 744 pt. The app is requireFullScreen, so an iPad window never shrinks and the
device check always matches the screen. It also reads in module constants and gameplay math, where
a reactive breakpoint cannot.
A stylesheet with breakpoint- or orientation-keyed values takes the runtime — (theme, _rt),
even when it never reads it. Every stylesheet is created when the app starts, and on a width
change Unistyles 3 re-parses a (theme)-only sheet only for the views on screen at that moment.
An iPad that starts upright parses the sheets at md; when the app then turns landscape, a screen
first opened later (the song result) keeps its xs/md values for the whole session. A
(theme, rt) sheet is refreshed on every runtime change, mounted or not.
src/core/theme/__tests__/breakpoint-stylesheets.test.ts fails on a (theme)-only sheet that
holds such a value.
Where to put style code
Common pitfalls
- Never hardcode a hex value. Add it to the theme first.
- Never hardcode
fontFamilystrings ('Nunito_400Regular','System', …). Usetheme.fonts.primary.*/theme.fonts.secondary.*fromsrc/core/theme/fonts.ts(see.cursor/rules/typography-fonts.mdc). - Don't import
StyleSheetfromreact-native— always fromreact-native-unistylesso themes apply. useVariantsrequires the component to actually render. If you build a variant table but never calluseVariants, the variant branch is dead code.- Babel root. If a new top-level folder is added (e.g.
packages/ui), update babel.config.jsautoProcessPathsso its styles get themed.