Skip to content
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

feat: handle theme change based on preferences #2016

Merged
merged 3 commits into from
Jun 29, 2020
Merged

Conversation

troZee
Copy link
Member

@troZee troZee commented Jun 26, 2020

Motivation

Closes #1597

Android 10 and iOS 13 added support for dark theme. User (like me ;p) can set dark theme as default theme. Application should adapt to this theme automatically, hence I would like to have automatically theme changing in my app, so I don't need to care about user preferences.

TODO

  • Add an example, which demonstrates this api

Screenshots

Simulator Screen Shot - iPhone X - 2020-06-27 at 16 00 29

Simulator Screen Shot - iPhone X - 2020-06-27 at 15 59 25

Test plan

@callstack-bot
Copy link

callstack-bot commented Jun 26, 2020

Hey @troZee, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here

.

src/core/Provider.tsx Outdated Show resolved Hide resolved
} else {
const theme =
this.state.colorScheme === 'light' ? DefaultTheme : DarkTheme;
return Object.assign(theme as ReactNativePaper.Theme, {
Copy link
Member

Choose a reason for hiding this comment

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

Probably not from your change, but Object.assign incorrect here since:

  1. It'll mutate our theme
  2. Adding animation property will override anything else defined in this property. We don't have anything else right now, but might have in future.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's my change. This PR fixes the issues you mentioned @satya164

@troZee troZee force-pushed the feat/dark-light-theme branch 3 times, most recently from 36791a5 to de8c2ec Compare June 27, 2020 13:57
@troZee troZee marked this pull request as ready for review June 27, 2020 14:01
@troZee
Copy link
Member Author

troZee commented Jun 27, 2020

Simulator Screen Shot - iPhone X - 2020-06-27 at 16 00 29

Simulator Screen Shot - iPhone X - 2020-06-27 at 15 59 25

@matkoson
Copy link
Contributor

@troZee I opened a PR to fix theme merging, beyond that lgtm. Animation scale adjustment works fine.

src/core/Provider.tsx Outdated Show resolved Hide resolved
@troZee troZee force-pushed the feat/dark-light-theme branch from a627ee3 to 58ab6a0 Compare June 29, 2020 12:30
@troZee troZee requested review from satya164 and matkoson June 29, 2020 12:31
@Trancever Trancever merged commit 7d4e006 into 4.0 Jun 29, 2020
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.

5 participants