mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at remove-scenes 74 lines 1.6 kB view raw
1import React, {createContext, useContext, useMemo} from 'react' 2import {TextStyle, useColorScheme, ViewStyle} from 'react-native' 3import {darkTheme, defaultTheme} from './themes' 4 5export type ColorScheme = 'light' | 'dark' 6 7export type PaletteColorName = 8 | 'default' 9 | 'primary' 10 | 'secondary' 11 | 'inverted' 12 | 'error' 13export type PaletteColor = { 14 background: string 15 backgroundLight: string 16 text: string 17 textLight: string 18 textInverted: string 19 link: string 20 border: string 21 icon: string 22 [k: string]: string 23} 24export type Palette = Record<PaletteColorName, PaletteColor> 25 26export type ShapeName = 'button' | 'bigButton' | 'smallButton' 27export type Shapes = Record<ShapeName, ViewStyle> 28 29export type TypographyVariant = 30 | 'h1' 31 | 'h2' 32 | 'h3' 33 | 'h4' 34 | 'h5' 35 | 'h6' 36 | 'subtitle1' 37 | 'subtitle2' 38 | 'body1' 39 | 'body2' 40 | 'button' 41 | 'caption' 42 | 'overline1' 43 | 'overline2' 44 | 'mono1' 45export type Typography = Record<TypographyVariant, TextStyle> 46 47export interface Theme { 48 colorScheme: ColorScheme 49 palette: Palette 50 shapes: Shapes 51 typography: Typography 52} 53 54export interface ThemeProviderProps { 55 theme?: ColorScheme 56} 57 58export const ThemeContext = createContext<Theme>(defaultTheme) 59 60export const useTheme = () => useContext(ThemeContext) 61 62export const ThemeProvider: React.FC<ThemeProviderProps> = ({ 63 theme, 64 children, 65}) => { 66 const colorScheme = useColorScheme() 67 68 const value = useMemo( 69 () => ((theme || colorScheme) === 'dark' ? darkTheme : defaultTheme), 70 [colorScheme, theme], 71 ) 72 73 return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider> 74}