Telegram Switch Theme with Skia and Reanimated ๐
Tuesday, September 12, 2023
demos
telegram-theme-switch
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A Telegram-style theme switching system with bottom tab navigation.
What's This About?
This component creates a theme switching system similar to Telegram's interface, featuring a bottom tab navigation and smooth theme transitions. It includes a provider-based theme management system, customizable color palettes for light and dark themes, and integration with React Navigation. The implementation is perfect for applications requiring sophisticated theme switching capabilities with bottom tab navigation.
Technical Implementation
The component uses:
Theme management
Navigation system
Color palettes
Provider pattern
Safe area handling
Usage
// Basic usage
<TelegramThemeSwitch />
// Full implementation with provider
<SwitchThemeProvider>
<NavigationContainer theme={selectedTheme}>
<SafeAreaProvider>
<TelegramThemeSwitch />
</SafeAreaProvider>
</NavigationContainer>
</SwitchThemeProvider>
// Theme configuration
const LightTheme = {
colors: {
background: LightPalette.background,
text: LightPalette.text,
border: LightPalette.text,
card: LightPalette.card
}
};
const DarkTheme = {
colors: {
background: DarkPalette.background,
text: DarkPalette.text,
border: DarkPalette.text,
card: DarkPalette.card
}
};
// Theme hook usage
const { theme } = useSwitchTheme();
const selectedTheme = theme === 'light' ?
LightTheme :
DarkTheme;
// Navigation setup
<BottomTab.Navigator
initialRouteName="Search"
tabBar={(props) => (
<BottomTabBar {...props} />
)}
>
{screens.map(screen => (
<BottomTab.Screen
key={screen}
name={screen}
component={ScreenMap[screen]}
/>
))}
</BottomTab.Navigator>
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Telegram Theme Switch
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback