-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
DynamicColorsIOS page #1851
Merged
Merged
DynamicColorsIOS page #1851
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1c9b7a5
Adding DynamicColorsIOS and referencing it and PlatformColors from Co…
rachelnabors 29bfadd
Adding DynamicColorsIOS and referencing it and PlatformColors from Co…
rachelnabors 09390df
Making sure the new page is actually in there.
rachelnabors eb02ec5
Moving note for iOS devs into devNotes section
rachelnabors 23079dc
small tweaks, remove duplicated section
Simek 03ba1ec
formatting, typo fix
Simek acc6d8c
update the iOS color reference list link
Simek f517f6a
typo fix
Simek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
id: dynamiccolorios | ||
title: DynamicColorIOS | ||
--- | ||
|
||
The `DynamicColorIOS` function is a platform color type specific to iOS. | ||
|
||
```jsx | ||
DynamicColorIOS({light: color, dark: color}); | ||
``` | ||
|
||
`DynamicColorIOS` takes a single argument as an object with two keys: `dark` and `light`. These correspond to the colors you want to use for "light mode" and "dark mode" on iOS. | ||
|
||
> In the future, more keys might become available for different user preferences, like high contrast. | ||
|
||
At runtime, the system will choose which of the two colors to display depending on the current system appearance settings. Dynamic colors are useful for branding colors or other app specific colors that still respond automatically to system setting changes. | ||
|
||
<div class="toggler"> | ||
<span>Developer Notes</span> | ||
<span role="tablist" class="toggle-devNotes"> | ||
<button role="tab" class="button-webNote" onclick="displayTabs('devNotes', 'webNote')">Web</button> | ||
<button role="tab" class="button-iosNote" onclick="displayTabs('devNotes', 'iosNote')">iOS</button> | ||
</span> | ||
</div> | ||
|
||
<block class="webNote devNotes" /> | ||
|
||
> If you’re familiar with `@media (prefers-color-scheme: dark)` in CSS, this is similar! Only instead of defining all the colors in a media query, you define which color to use under what circumstances right there where you're using it. Neat! | ||
|
||
<block class="iosNote devNotes" /> | ||
|
||
> The `DynamicColorIOS` function is similar to the iOS native methods [`UIColor colorWithDynamicProvider:`](https://developer.apple.com/documentation/uikit/uicolor/3238040-colorwithdynamicprovider) | ||
|
||
<block class="endBlock devNotes" /> | ||
|
||
## Example | ||
|
||
```jsx | ||
import { DynamicColorIOS } from 'react-native'; | ||
|
||
const customDynamicTextColor = DynamicColorIOS({ | ||
dark: 'lightskyblue', | ||
light: 'midnightblue', | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@Esemesek With facebook/react-native@25793ea landed, I think it would be preferable to link to the old link instead, which is a guide that describes the color system much more extensive and agnostic of APIs.
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.
@alloy Thank you for the comment. There is already a PR for that #1865.