MCPcopy Create free account
hub / github.com/callstack/react-native-paper / DynamicColorTheme

Function DynamicColorTheme

docs/src/components/DynamicColorTheme.tsx:318–411  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316};
317
318const DynamicColorTheme = () => {
319 const [isDark, setIsDark] = useState(false);
320
321 const [primary, setPrimary] = useState<string>(defaultColor);
322 const [secondary, setSecondary] = useState<string | undefined>();
323 const [tertiary, setTertiary] = useState<string | undefined>();
324 const [customColors, setCustomColors] = useState<CustomColorEntry[]>([]);
325
326 const darkMode = isDark ? 'dark' : 'light';
327 const baseTheme = hexThemeFromColor(primary);
328 const themes = prepareThemes({
329 primary,
330 secondary,
331 tertiary,
332 custom: customColors.map(({ name, hex }) => [name, hex]),
333 });
334
335 return (
336 <div>
337 <table className="color-picker">
338 <tbody>
339 <BaseColor color={primary} setColor={setPrimary} />
340 <AdditionalColor
341 color={secondary}
342 setColor={setSecondary}
343 base={baseTheme.secondary}
344 >
345 Secondary
346 </AdditionalColor>
347 <AdditionalColor
348 color={tertiary}
349 setColor={setTertiary}
350 base={baseTheme.tertiary}
351 >
352 Tertiary
353 </AdditionalColor>
354
355 <CustomColors
356 customColors={customColors}
357 setCustomColors={setCustomColors}
358 />
359 </tbody>
360 </table>
361
362 <div
363 className="color-picker-preview"
364 style={{
365 //@ts-ignore
366 background: themes[darkMode].background,
367 //@ts-ignore
368 color: themes[darkMode].onBackground,
369 //@ts-ignore
370 borderColor: themes[darkMode].outlineVariant,
371 }}
372 >
373 <div className="color-picker-preview-header">
374 <h3>Preview</h3>
375 <div>

Callers

nothing calls this directly

Calls 4

hexThemeFromColorFunction · 0.90
prepareThemesFunction · 0.90
getPreviewColorsFunction · 0.90
getMatchingColorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…