wix / react-native-ui-lib

UI Components Library for React Native
https://wix.github.io/react-native-ui-lib/
MIT License
6.44k stars 706 forks source link

Scheme color change when app back from background [iOS] #2552

Closed tdvuanh closed 1 year ago

tdvuanh commented 1 year ago

Description

Hello there, we are using Colors.setScheme to enable dark mode on our application. Unfortunately, when we set Colors.setSchema('default'), the colors of the text component will change from the color of the light scheme to the dark scheme every time we put the app in the background and bring it to the foreground again. If we set Colors.setScheme('light') or `Colors.setScheme('dark'), everything is fine.

This issue happens on both the simulator and the real device also.

Steps to reproduce

Environment

Affected platforms

lidord-wix commented 1 year ago

Can you please try to add the following line somewhere at the beginning of your app (before you initially import ui-lib)?

require('react-native-ui-lib/config').setConfig({appScheme: 'default'});
janoslc commented 1 year ago

Hey @lidord-wix and @tdvuanh!

I can confirm the current situation. I already have this line (you mentioned) added in my project but still, the problem is present when putting the app in the background and focus again.

tdvuanh commented 1 year ago

we found this issue belong the lib. Just now just use pacth-package to fix the problem.

lidord-wix commented 1 year ago

@tdvuanh can you please elaborate on your fix?

tdvuanh commented 1 year ago

UI lib use Appearance of react-native to get Color scheme, but since iOS 13, that API return wrong colorScheme. So we decided don't use Appearance instead use colorScheme which returned by Scheme.getSchemaType(). Here is the patch, fix in react-native-ui-lib/src/commons/asBaseComponent.js

Ảnh màn hình 2023-05-25 lúc 14 40 42