Slide 108
Slide 108 text
import { useDarkMode, DynamicValue } from 'react-native-dynamic';
export const colors = {
text: new DynamicValue('#000000', '#eaeaea'),
subtitle: new DynamicValue('#999999', '#878889'),
lightBackground: new DynamicValue('#fffff', '#282a2e'),
background: new DynamicValue('#f9f9f9', '#1e2023'),
border: new DynamicValue('#e8e8e8', '#414141'),
// ....
};
export type IThemeColors = keyof typeof colors;
export function useColor(color: IThemeColors, withTheme: boolean =
true) {
const value = colors[color];
const isDark = useDarkMode();
return withTheme && isDark ? value.dark : value.light;
}