diff --git a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js index 9bc01fcd3af2..6cb4a94567d2 100644 --- a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js +++ b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js @@ -14,11 +14,14 @@ import type {ColorValue} from 'react-native'; import RNTesterText from '../../components/RNTesterText'; import React from 'react'; import { + Appearance, + Button, DynamicColorIOS, Platform, PlatformColor, StyleSheet, View, + useColorScheme, } from 'react-native'; function PlatformColorsExample() { @@ -315,6 +318,48 @@ function VariantColorsExample() { ); } +function ReactsToAppearanceChangesExample() { + const theme = useColorScheme(); + const key = Platform.select({ + android: theme ?? '', + default: undefined, + }); + + return ( + // using a key here forces the component to unmount and remount + // which is necessary to trigger the appearance change + + + + {Platform.select({ + ios: "DynamicColorIOS({light: 'red', dark: 'blue'})", + android: "PlatformColor('?attr/colorAccent')", + default: 'Unexpected Platform.OS: ' + Platform.OS, + })} + + + + +