diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts
index b45a6624e6..c2cf43177b 100644
--- a/apps/mobile/app.config.ts
+++ b/apps/mobile/app.config.ts
@@ -41,12 +41,12 @@ const config: ExpoConfig = {
[
'expo-splash-screen',
{
- backgroundColor: '#FFFFFF',
- image: './assets/images/icon.png',
+ backgroundColor: '#5521FF',
+ image: './assets/images/splash-logo.png',
imageWidth: 120,
dark: {
- backgroundColor: '#15121D',
- image: './assets/images/icon.png',
+ backgroundColor: '#5521FF',
+ image: './assets/images/splash-logo.png',
},
},
],
diff --git a/apps/mobile/assets/images/splash-logo.png b/apps/mobile/assets/images/splash-logo.png
new file mode 100644
index 0000000000..e52841fc3a
Binary files /dev/null and b/apps/mobile/assets/images/splash-logo.png differ
diff --git a/apps/mobile/src/components/pixel-dismiss.test.ts b/apps/mobile/src/components/pixel-dismiss.test.ts
new file mode 100644
index 0000000000..8d84baa2c3
--- /dev/null
+++ b/apps/mobile/src/components/pixel-dismiss.test.ts
@@ -0,0 +1,15 @@
+import { rippleDelay } from '@/components/pixel-dismiss';
+
+describe('rippleDelay', () => {
+ it('starts at the centre and grows with the distance from it', () => {
+ const delays = Array.from({ length: 4 }, (_, row) =>
+ Array.from({ length: 4 }, (_, column) => rippleDelay(row, column, 4, 4, 300)),
+ );
+ expect(delays).toEqual([
+ [225, 168, 168, 225],
+ [168, 75, 75, 168],
+ [168, 75, 75, 168],
+ [225, 168, 168, 225],
+ ]);
+ });
+});
diff --git a/apps/mobile/src/components/pixel-dismiss.tsx b/apps/mobile/src/components/pixel-dismiss.tsx
new file mode 100644
index 0000000000..fb47f3fddf
--- /dev/null
+++ b/apps/mobile/src/components/pixel-dismiss.tsx
@@ -0,0 +1,71 @@
+import { useMemo } from 'react';
+import { StyleSheet, useWindowDimensions, View } from 'react-native';
+import { EaseView } from 'react-native-ease';
+
+const COLUMNS = 10;
+/** Neighbouring pixels overlap so no hairline of the content shows between them before they move. */
+const OVERLAP = 1;
+const PIXEL_MS = 160;
+const SPREAD_MS = 300;
+const VANISHED = { scale: 0, rotate: 45 };
+const COVERING = { scale: 1, rotate: 0 };
+
+/** Longest time from `dismissed` until the last pixel is gone, not counting `delay`. */
+export const PIXEL_DISMISS_MS = SPREAD_MS + PIXEL_MS;
+
+/**
+ * Delay before the pixel at `row`, `column` starts to vanish. It grows with the distance from the centre of the grid
+ * to the pixel's centre, scaled so the grid's outer corners would be at `spreadMs`.
+ */
+export function rippleDelay(row: number, column: number, rows: number, columns: number, spreadMs: number) {
+ const distance = Math.hypot(column + 0.5 - columns / 2, row + 0.5 - rows / 2);
+ const maxDistance = Math.hypot(columns / 2, rows / 2);
+ return Math.round((distance / maxDistance) * spreadMs);
+}
+
+/**
+ * Covers the screen with square pixels of `color`. When `dismissed` turns true, the pixels shrink and turn away,
+ * rippling outward from the centre after `delay` ms. Each pixel is an `EaseView`, so the whole ripple runs on native
+ * animations from a single render.
+ */
+export function PixelDismiss({ color, dismissed, delay }: { color: string; dismissed: boolean; delay: number }) {
+ const { width, height } = useWindowDimensions();
+ const grid = useMemo(() => pixelGrid(width, height), [width, height]);
+
+ return (
+
+
+ {grid.pixels.map(({ key, left, top, rippleMs }) => (
+
+ ))}
+
+
+ );
+}
+
+function pixelGrid(width: number, height: number) {
+ const size = width / COLUMNS;
+ const rows = 2 * Math.ceil(height / 2 / size);
+ const pixels = [];
+ for (let row = 0; row < rows; row++) {
+ for (let column = 0; column < COLUMNS; column++) {
+ pixels.push({
+ key: `${row}:${column}`,
+ left: column * size,
+ top: row * size,
+ rippleMs: rippleDelay(row, column, rows, COLUMNS, SPREAD_MS),
+ });
+ }
+ }
+ return { pixelSize: size + OVERLAP, height: rows * size, pixels };
+}
+
+const styles = StyleSheet.create({
+ center: { ...StyleSheet.absoluteFill, alignItems: 'center', justifyContent: 'center' },
+ pixel: { position: 'absolute' },
+});
diff --git a/apps/mobile/src/components/splash-overlay.tsx b/apps/mobile/src/components/splash-overlay.tsx
index aa9d7ddc35..cf131b9cb8 100644
--- a/apps/mobile/src/components/splash-overlay.tsx
+++ b/apps/mobile/src/components/splash-overlay.tsx
@@ -1,40 +1,26 @@
import { Image } from 'expo-image';
import * as SplashScreen from 'expo-splash-screen';
-import { useEffect, useMemo, useState, type ReactNode } from 'react';
-import { Appearance, StyleSheet, useWindowDimensions, View } from 'react-native';
+import { useEffect, useState, type ReactNode } from 'react';
+import { View } from 'react-native';
import { EaseView } from 'react-native-ease';
import { useReducedMotion } from 'react-native-reanimated';
+import { StyleSheet } from 'react-native-unistyles';
+import { PIXEL_DISMISS_MS, PixelDismiss } from '@/components/pixel-dismiss';
import { colors } from '@/design/tokens';
-const ICON = require('@/assets/images/icon.png');
+const LOGO = require('@/assets/images/splash-logo.png');
-/** `imageWidth` of the `expo-splash-screen` config in app.config.ts. */
-const ICON_SIZE = 120;
-/**
- * icon.png draws a 96 pt purple square with a 22 pt radius. The flood starts 1 pt inside it so the icon hides it
- * completely on the first frame.
- */
-const FLOOD_SIZE = 94;
-const FLOOD_RADIUS = 21;
-/**
- * icon.png's white letter circle is 66 pt wide. Android clips without anti-aliasing, so the clip keeps a purple margin
- * and its edge falls on purple.
- */
-const LETTERS_CLIP = 72;
-const COLUMNS = 10;
+/** `backgroundColor` and `imageWidth` of the `expo-splash-screen` config in app.config.ts. */
+const SPLASH_COLOR = colors.light.brand;
+const LOGO_SIZE = 120;
-const FLOOD_MS = 350;
-/** Core Animation replaces a 0 duration with its 0.25 s default. */
-const CUT_MS = 1;
-const RIPPLE_DELAY_MS = 100;
-const RIPPLE_SPREAD_MS = 300;
-const PIXEL_MS = 160;
-const RIPPLE_END_MS = FLOOD_MS + RIPPLE_DELAY_MS + RIPPLE_SPREAD_MS + PIXEL_MS;
-const POP_MS = 90;
-const SHRINK_MS = 130;
-const SETTLE_DELAY_MS = FLOOD_MS + 50;
-const SETTLE_MS = 600;
+const LOGO_POP_SCALE = 1.2;
+const LOGO_POP_MS = 90;
+const LOGO_SHRINK_MS = 130;
+const PIXELS_DELAY_MS = 100;
+const APP_START_SCALE = 0.98;
+const APP_SETTLE_MS = 600;
const CROSSFADE_MS = 250;
/** The native animations start once this render reaches the UI thread, after the unmount timer starts. */
const UNMOUNT_SLACK_MS = 50;
@@ -44,17 +30,14 @@ let played = false;
/**
* Wraps the app, draws the native splash over it, and hides the native splash once this frame is on screen. Then it
- * plays the dismiss once per app process: the icon's purple square floods the screen, the letters pop and shrink, and
- * the purple breaks into pixels that vanish outward from the logo while the app settles into place. Reduce Motion gets
- * a crossfade.
+ * plays the dismiss once per app process: the logo pops and shrinks, and the purple breaks into pixels that vanish
+ * outward from it while the app settles into place. Reduce Motion gets a crossfade.
*/
export function SplashOverlay({ children }: { children: ReactNode }) {
const [visible, setVisible] = useState(!played);
- const [scheme] = useState<'light' | 'dark'>(() => (Appearance.getColorScheme() === 'dark' ? 'dark' : 'light'));
- const reduceMotion = useReducedMotion();
const [displayed, setDisplayed] = useState(false);
const [replayed] = useState(played);
- const { width, height } = useWindowDimensions();
+ const reduceMotion = useReducedMotion();
useEffect(() => {
if (!visible) return;
@@ -66,127 +49,64 @@ export function SplashOverlay({ children }: { children: ReactNode }) {
SplashScreen.hide();
const timeout = setTimeout(
() => setVisible(false),
- (reduceMotion ? CROSSFADE_MS : RIPPLE_END_MS) + UNMOUNT_SLACK_MS,
+ (reduceMotion ? CROSSFADE_MS : PIXELS_DELAY_MS + PIXEL_DISMISS_MS) + UNMOUNT_SLACK_MS,
);
return () => clearTimeout(timeout);
}, [visible, displayed, reduceMotion]);
const started = replayed || displayed;
- const grid = useMemo(() => pixelGrid(width, height), [width, height]);
- const ripple = started && !reduceMotion;
- const floodScale = (Math.max(width, height) + 4 * grid.size) / FLOOD_SIZE;
+ const dismissed = started && !reduceMotion;
return (
- <>
+
{children}
{visible && (
- {!reduceMotion && (
-
- {grid.cells.map((cell) => (
-
- ))}
-
+ {reduceMotion ? (
+
+ ) : (
+
)}
-
-
- setDisplayed(true)} />
-
-
-
+ setDisplayed(true)} />
)}
- >
+
);
}
-function pixelGrid(width: number, height: number) {
- const size = width / COLUMNS;
- const rows = (Math.ceil(height / 2 / size) + 1) * 2;
- const gridHeight = rows * size;
- const maxDistance = Math.hypot(width / 2, gridHeight / 2);
- const cells = [];
- for (let row = 0; row < rows; row++) {
- for (let column = 0; column < COLUMNS; column++) {
- const left = column * size;
- const top = row * size;
- const distance = Math.hypot(left + size / 2 - width / 2, top + size / 2 - gridHeight / 2);
- const delay = Math.round(FLOOD_MS + RIPPLE_DELAY_MS + (distance / maxDistance) * RIPPLE_SPREAD_MS);
- cells.push({ key: `${row}:${column}`, left, top, delay });
- }
- }
- return { size, width, height: gridHeight, cells };
-}
-
-const styles = StyleSheet.create({
+const styles = StyleSheet.create((theme) => ({
+ backdrop: { flex: 1, backgroundColor: theme.colors.background },
app: { flex: 1 },
- center: { alignItems: 'center', justifyContent: 'center' },
- grid: { position: 'absolute' },
- icon: { width: ICON_SIZE, height: ICON_SIZE },
- flood: { position: 'absolute', width: FLOOD_SIZE, height: FLOOD_SIZE, backgroundColor: colors.light.brand },
- pixel: { position: 'absolute', backgroundColor: colors.light.brand },
- letters: { position: 'absolute', width: LETTERS_CLIP, height: LETTERS_CLIP },
- lettersClip: { width: LETTERS_CLIP, height: LETTERS_CLIP, borderRadius: LETTERS_CLIP / 2, overflow: 'hidden' },
- lettersIcon: {
- width: ICON_SIZE,
- height: ICON_SIZE,
- marginLeft: (LETTERS_CLIP - ICON_SIZE) / 2,
- marginTop: (LETTERS_CLIP - ICON_SIZE) / 2,
- },
-});
+ overlay: { ...StyleSheet.absoluteFill, alignItems: 'center', justifyContent: 'center' },
+ fill: { ...StyleSheet.absoluteFill, backgroundColor: SPLASH_COLOR },
+ logo: { width: LOGO_SIZE, height: LOGO_SIZE },
+}));