-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for RN0.63 PlatformColor #6113
Comments
Actually PlatformColor will expose |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Not stale.. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Not stale |
@jfrolich Hi there ✋, currently the recommended approach is to call Hmm reading through the PR that implements the PlatformColor, it does not seem like it's solving the problem that RNN is currently having. I guess the more ideal way would be declaring the light and dark theme color for the navigation element and on the native side listen to the theme change and adjust the color based on the user input (don't quote me on this 😅): setDefaultOptions({
topBar: {
background: {
light: 'black', // light theme, set it to black color.
dark: 'white', // dark theme, set it to white color.
}
},
bottomTabs: {
backgroundColor: {
light: 'black', // light theme, set it to black color.
dark: 'white', // dark theme, set it to white color.
}
}
}) |
@jinshin1013: A better approach is with a |
@jfrolich Are you saying setDefaultOptions({
topBar: {
background: {
color: IOSDynamicColor({ light: 'black', dark: 'white' })
}
},
bottomTabs: {
backgroundColor: IOSDynamicColor({ light: 'black', dark: 'white' })
}
})
If so, that's a great news! That means the RNN wouldn't have to listen to the theme change and apply the colors.
setRoot({ ... }) // Start the app. |
Yes. You can define platform colors on the native side with a light and dark appearance. |
Btw for now you should have a look at |
We use this technique quite heavily at https://familyfive.app, with a custom hook, having been featured by Apple quite heavily for our dark mode. And it works quite well! (With a few annoying edge cases). |
@jfrolich The app looks fantastic! Yeah we also looked into using |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Not stale |
PR at #6477 |
See https://reactnative.dev/docs/platformcolor for an intro to PlatformColor Internally react-native uses ColorPropConverter to convert the color on Android. Since it was added in RN63, this PR adds a new build flavor. ColorPropConverter expects a Context object to resolve named colors from resources. Thus, context is now drilled down into the parser. ColorPropConverter expects the color to be of type ReadableMap. Since we use JSONObject internally, I added methods to JSONParser to convert those back into the react-native Map format. Related to #6113 Co-authored-by: Guy Carmeli <guyca@users.noreply.github.com>
Currently there is a problem with implementing dark mode with RNN, as the API is imperative we need to update the UI with
mergeoptions
when the mode changes from light to dark (and the other way around). This is especially tricky when multiple screens are active (like in a stack). Also sometimes it plainly doesn't work (probably unrelated bugs inmergeOptions
). React-Native is going to implement colors that are resolved at runtime (and are a primitive on iOS). These colors automatically update based on the light/dark theme. This would also solve the problem with RNN. We can imperatively set colors, and and they are automatically updated to the right theme on an operating system level.Explanation about the new feature here: facebook/react-native-website#1813.
The text was updated successfully, but these errors were encountered: