Sign in to Reactiive

Use your Google or Apple account.
Signing in subscribes you to the newsletter: new content and the occasional promotion. Unsubscribe at any time.
Skip to content

React Native Theme Canvas Animation 🎨

Wednesday, February 1, 2023
enzomanuelmangano
demos
theme-canvas-animation
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A theme switcher with circular reveal animations using Skia canvas.

What's This About?

This component creates an interactive theme switching interface with circular reveal animations. It features multiple selectable theme squares arranged in a pattern, with smooth transitions between themes using circular clipping paths. The implementation includes custom font rendering, precise positioning calculations, and responsive layout handling, making it perfect for creative theme switching interfaces.

Technical Implementation

The component uses:
Skia canvas
Circular animations
Theme management
Custom fonts
Gesture handling

Usage

// Basic usage <ThemeCanvasAnimation />; // Theme configuration const colors = [ { background: '#F7FFF7', text: '#373737' }, { background: '#4ECDC4', text: '#2C2C2C' }, { background: '#1A535C', text: '#E8E8E8' }, { background: '#EE6C4D', text: '#D4D2D2' }, { background: '#F38D68', text: '#2C2C2C' }, { background: '#902D41', text: '#DEDEDE' }, ]; // Square coordinates calculation const coordinates = useDerivedValue(() => { const squares = [ { offsetX: -1, offsetY: 0 }, { offsetX: 0, offsetY: 0 }, { offsetX: 1, offsetY: 0 }, { offsetX: 0, offsetY: 1 }, { offsetX: -1, offsetY: 1 }, { offsetX: 1, offsetY: 1 }, ]; return squares.map(({ offsetX, offsetY }) => ({ cx: canvasWidth / 2 - SQUARE_SIZE / 2 + offsetX * SQUARE_SIZE * 2, cy: canvasHeight / 2 - SQUARE_SIZE / 2 + offsetY * SQUARE_SIZE * 2, })); }, [canvasWidth, canvasHeight]); // Theme transition const onSelectSquare = (index: number) => { radius.value = withTiming(canvasHeight, { duration: 500, }); previousSelectedIndex.value = selectedIndex.value; selectedIndex.value = index; };

Unlock the beauty of React Native animations

Learn Reanimated, Gesture Handler & Skia with Reanimate.dev

Feedback on Theme Canvas Animation

Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback