my fork of the bluesky client
1import {useMemo} from 'react'
2import {TextStyle, ViewStyle} from 'react-native'
3
4import {PaletteColor, PaletteColorName, useTheme} from '../ThemeContext'
5
6export interface UsePaletteValue {
7 colors: PaletteColor
8 view: ViewStyle
9 viewLight: ViewStyle
10 btn: ViewStyle
11 border: ViewStyle
12 borderDark: ViewStyle
13 text: TextStyle
14 textLight: TextStyle
15 textInverted: TextStyle
16 link: TextStyle
17 icon: TextStyle
18}
19export function usePalette(color: PaletteColorName): UsePaletteValue {
20 const theme = useTheme()
21 return useMemo(() => {
22 const palette = theme.palette[color]
23 return {
24 colors: palette,
25 view: {
26 backgroundColor: palette.background,
27 },
28 viewLight: {
29 backgroundColor: palette.backgroundLight,
30 },
31 btn: {
32 backgroundColor: palette.backgroundLight,
33 },
34 border: {
35 borderColor: palette.border,
36 },
37 borderDark: {
38 borderColor: palette.borderDark,
39 },
40 text: {
41 color: palette.text,
42 },
43 textLight: {
44 color: palette.textLight,
45 },
46 textInverted: {
47 color: palette.textInverted,
48 },
49 link: {
50 color: palette.link,
51 },
52 icon: {
53 color: palette.icon,
54 },
55 }
56 }, [theme, color])
57}