File tree Expand file tree Collapse file tree
ReactAndroid/src/main/java/com/facebook/react/modules/appearance
src/private/specs_DEPRECATED/modules
rn-tester/js/examples/Appearance Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ import {NativeEventSubscription} from '../EventEmitter/RCTNativeAppEventEmitter'
1111
1212type ColorSchemeName = 'light' | 'dark' ;
1313
14- type ColorSchemeOverride = ColorSchemeName | 'unspecified' ;
14+ type ColorSchemeOverride =
15+ | ColorSchemeName
16+ | 'auto'
17+ /** @deprecated Use 'auto' instead */
18+ | 'unspecified' ;
1519
1620export namespace Appearance {
1721 type AppearancePreferences = {
@@ -36,8 +40,8 @@ export namespace Appearance {
3640
3741 /**
3842 * Force the application to always adopt a light or dark interface style. Pass
39- * `'unspecified '` to reset and follow the system default (removes any
40- * override). This does not affect the system UI, only the application.
43+ * `'auto '` to reset and follow the system default (removes any override).
44+ * This does not affect the system UI, only the application.
4145 */
4246 export function setColorScheme ( scheme : ColorSchemeOverride ) : void ;
4347
Original file line number Diff line number Diff line change @@ -107,8 +107,8 @@ export function getColorScheme(): ColorSchemeName | null {
107107
108108/**
109109 * Force the application to always adopt a light or dark interface style. Pass
110- * `'unspecified '` to reset and follow the system default (removes any
111- * override). This does not affect the system UI, only the application.
110+ * `'auto '` to reset and follow the system default (removes any override).
111+ * This does not affect the system UI, only the application.
112112 */
113113export function setColorScheme ( colorScheme : ColorSchemeOverride ) : void {
114114 const state = getState ( ) ;
@@ -117,7 +117,7 @@ export function setColorScheme(colorScheme: ColorSchemeOverride): void {
117117 NativeAppearance . setColorScheme ( colorScheme ) ;
118118 state . appearance = {
119119 colorScheme :
120- colorScheme === 'unspecified'
120+ colorScheme === 'auto' || colorScheme === ' unspecified'
121121 ? NativeAppearance . getColorScheme ( )
122122 : colorScheme ,
123123 } ;
Original file line number Diff line number Diff line change @@ -494,6 +494,7 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
494494RCT_ENUM_CONVERTER (
495495 UIUserInterfaceStyle,
496496 (@{
497+ @" auto" : @(UIUserInterfaceStyleUnspecified),
497498 @" unspecified" : @(UIUserInterfaceStyleUnspecified),
498499 @" light" : @(UIUserInterfaceStyleLight),
499500 @" dark" : @(UIUserInterfaceStyleDark),
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ constructor(
8787 when (style) {
8888 " dark" -> AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_YES )
8989 " light" -> AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_NO )
90+ " auto" ,
9091 " unspecified" ->
9192 AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_FOLLOW_SYSTEM )
9293 }
Original file line number Diff line number Diff line change 44 * This source code is licensed under the MIT license found in the
55 * LICENSE file in the root directory of this source tree.
66 *
7- * @generated SignedSource<<04955f1605996352fa3f3a3fc86ba937 >>
7+ * @generated SignedSource<<eeffa8d1c270f98debd70024251b4a1a >>
88 *
99 * This file was generated by scripts/js-api/build-types/index.js.
1010 */
@@ -1859,7 +1859,7 @@ declare namespace CodegenTypes {
18591859}
18601860declare type ColorListenerCallback = ( value : ColorValue ) => unknown
18611861declare type ColorSchemeName = "dark" | "light"
1862- declare type ColorSchemeOverride = "dark" | "light" | "unspecified"
1862+ declare type ColorSchemeOverride = "auto" | " dark" | "light" | "unspecified"
18631863declare type ColorValue = ____ColorValue_Internal
18641864declare type ComponentProvider = ( ) => React . ComponentType < any >
18651865declare type ComponentProviderInstrumentationHook = (
@@ -6073,7 +6073,7 @@ export {
60736073 AppState , // 12012be5
60746074 AppStateEvent , // 80f034c3
60756075 AppStateStatus , // 447e5ef2
6076- Appearance , // 0e9bf4fe
6076+ Appearance , // 83e9641a
60776077 AutoCapitalize , // c0e857a0
60786078 BackHandler , // f139fc69
60796079 BackPressEventName , // 4620fb76
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod
1414
1515export type ColorSchemeName = 'light' | 'dark' ;
1616
17- export type ColorSchemeOverride = 'light' | 'dark' | 'unspecified' ;
17+ export type ColorSchemeOverride = 'light' | 'dark' | 'auto' | ' unspecified';
1818
1919export type AppearancePreferences = {
2020 colorScheme : ColorSchemeName ,
Original file line number Diff line number Diff line change @@ -136,8 +136,8 @@ const ColorShowcase = (props: {themeName: string}) => (
136136
137137const ToggleNativeAppearance = ( ) => {
138138 const [ nativeColorScheme , setNativeColorScheme ] = useState <
139- ColorSchemeName | 'unspecified ' ,
140- > ( 'unspecified ' ) ;
139+ ColorSchemeName | 'auto ' ,
140+ > ( 'auto ' ) ;
141141 const colorScheme = useColorScheme ( ) ;
142142
143143 useEffect ( ( ) => {
@@ -156,10 +156,7 @@ const ToggleNativeAppearance = () => {
156156 title = "Set to dark"
157157 onPress = { ( ) => setNativeColorScheme ( 'dark' ) }
158158 />
159- < Button
160- title = "Unset"
161- onPress = { ( ) => setNativeColorScheme ( 'unspecified' ) }
162- />
159+ < Button title = "Auto" onPress = { ( ) => setNativeColorScheme ( 'auto' ) } />
163160 </ View >
164161 ) ;
165162} ;
You can’t perform that action at this time.
0 commit comments