From e0adc0e3f3410de9e3a58474ffaeaddeaa7b3f3a Mon Sep 17 00:00:00 2001 From: Hubert Bieszczad Date: Fri, 23 Jan 2026 15:15:11 +0100 Subject: [PATCH 1/2] fix: support both new and old ColorSchemeName in RN --- .../uniwind/src/core/config/config.common.ts | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/uniwind/src/core/config/config.common.ts b/packages/uniwind/src/core/config/config.common.ts index 7eb30d60..7c013cf6 100644 --- a/packages/uniwind/src/core/config/config.common.ts +++ b/packages/uniwind/src/core/config/config.common.ts @@ -4,6 +4,8 @@ import { UniwindListener } from '../listener' import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types' const SYSTEM_THEME = 'system' as const +const RN_VERSION = Platform.constants.reactNativeVersion.minor +const UNSPECIFIED_THEME = RN_VERSION >= 0.82 ? 'unspecified' : undefined export class UniwindConfigBuilder { protected themes = ['light', 'dark'] @@ -12,7 +14,10 @@ export class UniwindConfigBuilder { constructor() { Appearance.addChangeListener(event => { - const colorScheme = event.colorScheme ?? ColorScheme.Light + // @ts-expect-error RN >0.82 - breaking change + const colorScheme = event.colorScheme === 'unspecified' + ? ColorScheme.Light + : event.colorScheme ?? ColorScheme.Light const prevTheme = this.#currentTheme if (this.#hasAdaptiveThemes && prevTheme !== colorScheme) { @@ -32,7 +37,14 @@ export class UniwindConfigBuilder { } private get colorScheme() { - return Appearance.getColorScheme() ?? ColorScheme.Light + const colorScheme = Appearance.getColorScheme() + + // @ts-expect-error RN >0.82 - breaking change + if (colorScheme === 'unspecified') { + return ColorScheme.Light + } + + return colorScheme ?? ColorScheme.Light } // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents @@ -47,7 +59,8 @@ export class UniwindConfigBuilder { this.#currentTheme = this.colorScheme if (Platform.OS !== 'web') { - Appearance.setColorScheme(undefined) + // @ts-expect-error RN >0.82 - breaking change + Appearance.setColorScheme(UNSPECIFIED_THEME) } return @@ -61,7 +74,12 @@ export class UniwindConfigBuilder { this.#currentTheme = theme if (Platform.OS !== 'web') { - Appearance.setColorScheme(isAdaptiveTheme ? this.#currentTheme as ColorScheme : undefined) + Appearance.setColorScheme( + // @ts-expect-error RN >0.82 - breaking change + isAdaptiveTheme + ? this.#currentTheme as ColorScheme + : UNSPECIFIED_THEME, + ) } } finally { if (prevTheme !== this.#currentTheme) { From 73cb69e269017d9eaced6d2729e8edf924cba80b Mon Sep 17 00:00:00 2001 From: Hubert Bieszczad Date: Fri, 23 Jan 2026 17:07:01 +0100 Subject: [PATCH 2/2] chore: 82 version --- packages/uniwind/src/core/config/config.common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/uniwind/src/core/config/config.common.ts b/packages/uniwind/src/core/config/config.common.ts index 7c013cf6..7fce1f34 100644 --- a/packages/uniwind/src/core/config/config.common.ts +++ b/packages/uniwind/src/core/config/config.common.ts @@ -5,7 +5,7 @@ import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types' const SYSTEM_THEME = 'system' as const const RN_VERSION = Platform.constants.reactNativeVersion.minor -const UNSPECIFIED_THEME = RN_VERSION >= 0.82 ? 'unspecified' : undefined +const UNSPECIFIED_THEME = RN_VERSION >= 82 ? 'unspecified' : undefined export class UniwindConfigBuilder { protected themes = ['light', 'dark']