-
Notifications
You must be signed in to change notification settings - Fork 734
POC for dark mode support #1147
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
Conversation
Hello All, Was wondering if someone can review and approve, in need of using loadSchemes on our application. Cheers! |
src/commons/modifiers.ts
Outdated
// const props = this.getThemeProps(); | ||
const allColorsKeys: Array<keyof typeof Colors> = _.keys(Colors); | ||
const scheme = Appearance.getColorScheme(); | ||
const schemeColors = Colors.schemes[scheme!]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you know scheme
in not null
or undefined
(here and below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a default to light
but i'm pretty it has to return some value and the issue is with the typings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why but this is the definition in react-native:
type ColorSchemeName = 'light' | 'dark' | null | undefined;
Actually it's more weird because the original code does not have them (does not seem to have changed in the last two years)...
BTW, you can now remove the !
since it has no purpose now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/commons/modifiers.ts
Outdated
// const props = this.getThemeProps(); | ||
const allColorsKeys: Array<keyof typeof Colors> = _.keys(Colors); | ||
const scheme = Appearance.getColorScheme(); | ||
const schemeColors = Colors.schemes[scheme!]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why but this is the definition in react-native:
type ColorSchemeName = 'light' | 'dark' | null | undefined;
Actually it's more weird because the original code does not have them (does not seem to have changed in the last two years)...
BTW, you can now remove the !
since it has no purpose now.
Co-authored-by: Miki Leib <[email protected]>
Description
Add new Colors api for loading schemes for dark mode
for example:
Also added a listener in our asBaseComponent that for appearance change so our components can react to dark mode change
Changelog
Support dark mode using
Colors.loadSchemes
method.