From efa9711e35f528245cdfb6c7028129c97ae10192 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 20 Aug 2024 10:44:41 -0700 Subject: [PATCH] Fixes Appearance user interface style when app run from background (#46021) Summary: Fixes https://github.com/facebook/react-native/issues/46015. ## Changelog: [IOS] [FIXED] - Fixes Appearance user interface style when app run from background Pull Request resolved: https://github.com/facebook/react-native/pull/46021 Test Plan: Demo in https://github.com/facebook/react-native/issues/46015. Reviewed By: christophpurrer Differential Revision: D61536857 Pulled By: cipolleschi fbshipit-source-id: ee06cb25b5fc4fa72d646efe212738e54b9ef858 --- packages/react-native/React/CoreModules/RCTAppearance.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/React/CoreModules/RCTAppearance.mm b/packages/react-native/React/CoreModules/RCTAppearance.mm index 457a1d8b966..b5bcc313a82 100644 --- a/packages/react-native/React/CoreModules/RCTAppearance.mm +++ b/packages/react-native/React/CoreModules/RCTAppearance.mm @@ -70,8 +70,13 @@ NSString *RCTColorSchemePreference(UITraitCollection *traitCollection) return appearances[@(traitCollection.userInterfaceStyle)]; } + if (!traitCollection) { + traitCollection = [UITraitCollection currentTraitCollection]; + } + UIUserInterfaceStyle systemStyle = sUseKeyWindowForSystemStyle ? RCTKeyWindow().traitCollection.userInterfaceStyle : traitCollection.userInterfaceStyle; + return appearances[@(systemStyle)] ?: RCTAppearanceColorSchemeLight; }