Skip to content

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

Merged
merged 12 commits into from
Mar 10, 2021
Merged

POC for dark mode support #1147

merged 12 commits into from
Mar 10, 2021

Conversation

ethanshar
Copy link
Collaborator

@ethanshar ethanshar commented Jan 23, 2021

Description

Add new Colors api for loading schemes for dark mode
for example:

Colors.loadSchemes({light: {...}, dark: {...}})

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.

@ethanshar ethanshar marked this pull request as ready for review January 29, 2021 16:06
@AbdeenM
Copy link

AbdeenM commented Feb 22, 2021

Hello All,

Was wondering if someone can review and approve, in need of using loadSchemes on our application.

Cheers!

// const props = this.getThemeProps();
const allColorsKeys: Array<keyof typeof Colors> = _.keys(Colors);
const scheme = Appearance.getColorScheme();
const schemeColors = Colors.schemes[scheme!];
Copy link
Collaborator

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)?

Copy link
Collaborator Author

@ethanshar ethanshar Mar 9, 2021

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ethanshar ethanshar requested a review from M-i-k-e-l March 9, 2021 11:52
// const props = this.getThemeProps();
const allColorsKeys: Array<keyof typeof Colors> = _.keys(Colors);
const scheme = Appearance.getColorScheme();
const schemeColors = Colors.schemes[scheme!];
Copy link
Collaborator

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.

@ethanshar ethanshar requested a review from M-i-k-e-l March 10, 2021 09:19
@M-i-k-e-l M-i-k-e-l merged commit 4d7eaba into master Mar 10, 2021
@ethanshar ethanshar deleted the feat/darkMode branch July 26, 2021 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants