From e2271c11da7f31e9f5df46a187baf167c488d2ea Mon Sep 17 00:00:00 2001 From: huymobile Date: Sat, 3 Oct 2026 01:59:32 +0700 Subject: [PATCH] fix: keep navigation theme type when adapting a single theme The light-only and dark-only overloads of adaptNavigationTheme returned the narrow NavigationTheme type, dropping `fonts` and custom colors from the input theme even though they are preserved at runtime. This made the result unassignable to React Navigation's Theme. Return the input theme type, as the overload for both themes already does. Fixes #4751 Co-Authored-By: Claude Opus 5.5 --- src/core/__tests__/theming.test.tsx | 20 ++++++++++++++++++++ src/theme/provider.tsx | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/core/__tests__/theming.test.tsx b/src/core/__tests__/theming.test.tsx index cb61aef20d..3ae5d44691 100644 --- a/src/core/__tests__/theming.test.tsx +++ b/src/core/__tests__/theming.test.tsx @@ -264,6 +264,26 @@ describe('adaptNavigationTheme', () => { }); }); + it('should keep fonts and custom colors when adapting a single theme', () => { + const { LightTheme: navLight } = adaptNavigationTheme({ + reactNavigationLight: { + ...NavigationThemeWithFonts, + colors: NavigationCustomLightTheme.colors, + }, + }); + const { DarkTheme: navDark } = adaptNavigationTheme({ + reactNavigationDark: { ...NavigationThemeWithFonts, dark: true }, + }); + + expect(navLight.colors.secondary).toBe('rgb(150,45,85)'); + expect(navLight.fonts.regular.fontFamily).toBe( + LightTheme.fonts.bodyMedium.fontFamily + ); + expect(navDark.fonts.regular.fontFamily).toBe( + DarkTheme.fonts.bodyMedium.fontFamily + ); + }); + it('should not expect fonts on theme without fonts', () => { const { LightTheme: navLight, DarkTheme: navDark } = adaptNavigationTheme({ reactNavigationLight: NavigationLightTheme, diff --git a/src/theme/provider.tsx b/src/theme/provider.tsx index 8f7e77681e..2c1f8ca9f9 100644 --- a/src/theme/provider.tsx +++ b/src/theme/provider.tsx @@ -75,14 +75,14 @@ export function adaptNavigationTheme(themes: { reactNavigationLight: T; materialLight?: Theme; }): { - LightTheme: NavigationTheme; + LightTheme: T; }; // eslint-disable-next-line no-redeclare export function adaptNavigationTheme(themes: { reactNavigationDark: T; materialDark?: Theme; }): { - DarkTheme: NavigationTheme; + DarkTheme: T; }; // eslint-disable-next-line no-redeclare export function adaptNavigationTheme<