Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
63ddb1d
Pin hermes-engine to 0.8.x for RN 0.65
Huxpro Apr 29, 2021
325aa5f
[AppContainer] Add back legacy rootTag childContex for 0.65
nadiia May 7, 2021
6d31b71
Merge pull request #31492 from nadiia/0.65-stable-roottag-context
elicwhite May 7, 2021
f31c610
Bump Flipper-Folly to 2.5.3 and RCT-Folly to 2021.04.26.00
Apr 29, 2021
c00197e
Bump Hermes npm to 0.8.0
Huxpro Apr 29, 2021
f0e529c
Reflect Hermes release version from HermesBadge
Huxpro Apr 30, 2021
d3a0d1e
Update validateBaseUrl to use latest regex
FBNeal Apr 29, 2021
7a83631
Implement HeapProfiler.getObjectByHeapObjectId
Apr 30, 2021
867d15a
Fix Hermes build on folly 2021.04.26.00
Apr 30, 2021
c317f55
Refactor UIManagerHelper.getUIManager to return null when there's no …
mdvacca May 6, 2021
3aa8399
Fix Hermes + no Flipper build on Xcode 12.5
May 11, 2021
bff0363
Add onPressIn & onPressOut props to Text (#31288)
adrienharnay May 6, 2021
48b2b79
fix(hermes): fixed hermes build on iOS (#31559)
Titozzz May 20, 2021
f15cd42
Upgrade jsc-android to 250230.2.1 (#31304)
Kudo May 24, 2021
408265d
localeIdentifier missing from flow type of I18nManager (#31589)
acoates-ms May 26, 2021
7599593
Gradle 6.9, Android Gradle Plugin 4.2.1 (#31593)
dulmandakh Jun 1, 2021
a48d998
fix: update to @jest/create-cache-key-function@27 (#30637)
SimenB Jun 2, 2021
bb7541e
Use trovej dependency from Maven Central
May 11, 2021
aa25969
Use Maven Central for fbjni artifact
May 17, 2021
9a923be
remove jcenter (#31609)
dulmandakh Jun 2, 2021
30f356c
find-node.sh supports Homebrew on M1 (#31622)
dulmandakh Jun 2, 2021
79ddbfb
fix(cli + tests): Bump metro to 0.66 + fix test manual script (#31597)
Titozzz Jun 2, 2021
c299694
Custom NSURLSession configuration (#27701)
hakonk Jun 3, 2021
0b36e2b
use maven-publish plugin (#31611)
dulmandakh Jun 3, 2021
37e9f1d
bump buildToolsVersion to 30.0.2 (#31627)
dulmandakh Jun 3, 2021
5c8c5b6
Bump flipper deps to 0.91 to support XCode 12.5 out of the box (#31562)
mweststrate Jun 7, 2021
cae0637
[LOCAL] postfix timestamp to bust yarn cache
tido64 Jun 8, 2021
5f30232
[0.65.0-rc.0] Bump version numbers
tido64 Jun 9, 2021
4b62cbd
Revert "[0.65.0-rc.0] Bump version numbers"
tido64 Jun 9, 2021
f6accd2
[LOCAL] Fix Buck failing to fetch robolectric
tido64 Jun 9, 2021
e324498
[0.65.0-rc.0] Bump version numbers
tido64 Jun 9, 2021
4e9ae4c
Revert "[0.65.0-rc.0] Bump version numbers"
tido64 Jun 9, 2021
5aae7fc
[LOCAL] unbreak publish-npm.js
tido64 Jun 9, 2021
5556968
[0.65.0-rc.0] Bump version numbers
tido64 Jun 9, 2021
a10a201
Revert "Gradle 6.9, Android Gradle Plugin 4.2.1 (#31593)"
kelset Jun 16, 2021
0a15927
Revert "bump buildToolsVersion to 30.0.2 (#31627)"
kelset Jun 16, 2021
39e64c0
Fix font weight numeric values (#29117)
fabOnReact Jun 5, 2021
6b5b72c
Find node on m1 via homebrew node managers (#31678)
danilobuerger Jun 8, 2021
6287c44
Accessible colors for DynamicColorIOS (#31651)
birkir Jun 8, 2021
26bec88
Fix cli bundle platform for Mac Catalyst in `react-native-xcode.sh` (…
robertying Jun 11, 2021
5f1d431
bump fresco to 2.5.0 (#31699)
dulmandakh Jun 11, 2021
d8b115a
Bump Android deps to 0.93 (#31675)
mweststrate Jun 11, 2021
a3c53f5
Workaround failing fmt compilation by locking to v6.2.1
Jun 16, 2021
ca5b943
[LOCAL] lock files update for 065 branch
kelset Jun 17, 2021
0e08b25
[0.65.0-rc.1] Bump version numbers
kelset Jun 17, 2021
be9a669
Revert "Revert "Gradle 6.9, Android Gradle Plugin 4.2.1 (#31593)""
kelset Jun 18, 2021
ba4424f
Revert "Revert "bump buildToolsVersion to 30.0.2 (#31627)""
kelset Jun 18, 2021
121a6a4
Fix Android build sequencing
Jun 17, 2021
db7aa7b
[0.65.0-rc.2] Bump version numbers
kelset Jun 18, 2021
626d25c
Android: upgrading to OkHttp from 4.9.0 to 4.9.1 to fix java.lang.Nul…
gedeagas Jul 8, 2021
49253dc
Fix support for blobs larger than 64 KB on Android (#31789)
tomekzaw Jul 14, 2021
4476fbc
Allow PlatformColor to work with RCTView border colors (#29728)
danilobuerger Jun 23, 2021
e53745e
Bump Flipper + Bump hermes (#31872)
Titozzz Jul 20, 2021
e40f582
fix(deps): bump metro to 0.66.2 + dedup (#31886)
Titozzz Jul 20, 2021
e8d725a
[0.65.0-rc.3] Bump version numbers
kelset Jul 23, 2021
1b8dddc
Allow touches on overflowed children when `overflow: 'visible'`
danielgindi Aug 8, 2019
719f271
Moved `overflow` property declarations to interface
danielgindi May 4, 2020
3920241
Fixed overflow consideration from child
danielgindi Jul 14, 2020
c6c3aa2
Borrowed the RNTest PointerEvents example by @hsource
danielgindi Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accessible colors for DynamicColorIOS (#31651)
Summary:
Allow you to harvest the `UIAccessibilityContrastHigh` trait from iOS to show accessible colors when high contrast mode is enabled.

```jsx
// usage

PlatformColorIOS({
  light: '#eeeeee',
  dark: '#333333',
  highContrastLight: '#ffffff',
  highContrastDark: '#000000',
});

// {
//   "dynamic": {
//     "light": "#eeeeee",
//     "dark": "#333333",
//     "highContrastLight": "#ffffff",
//     "highContrastDark": "#000000",
//   }
// }
```

This is how apple's own dynamic system colors work under the hood (https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/#dynamic-system-colors)

 ---

The react native docs mention that more keys may become available in the future, which this PR is adding:

> In the future, more keys might become available for different user preferences, like high contrast.

https://reactnative.dev/docs/dynamiccolorios

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Added] - High contrast dynamic color options for dark and light mode.

Pull Request resolved: #31651

Test Plan: Added unit tests for `normalizeColor` to pass the high contrast colors downstream to RCTConvert

Reviewed By: lunaleaps

Differential Revision: D28922536

Pulled By: p-sun

fbshipit-source-id: f81417f003c3adefac50e994e62b9be14ffa91a1
  • Loading branch information
birkir authored and kelset committed Jun 16, 2021
commit 6287c447d627f9737f6dd02ab49465ae14df63db
17 changes: 16 additions & 1 deletion Libraries/StyleSheet/PlatformColorValueTypes.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export opaque type NativeColorValue = {
dynamic?: {
light: ?(ColorValue | ProcessedColorValue),
dark: ?(ColorValue | ProcessedColorValue),
highContrastLight?: ?(ColorValue | ProcessedColorValue),
highContrastDark?: ?(ColorValue | ProcessedColorValue),
},
};

Expand All @@ -26,12 +28,21 @@ export const PlatformColor = (...names: Array<string>): ColorValue => {
export type DynamicColorIOSTuplePrivate = {
light: ColorValue,
dark: ColorValue,
highContrastLight?: ColorValue,
highContrastDark?: ColorValue,
};

export const DynamicColorIOSPrivate = (
tuple: DynamicColorIOSTuplePrivate,
): ColorValue => {
return {dynamic: {light: tuple.light, dark: tuple.dark}};
return {
dynamic: {
light: tuple.light,
dark: tuple.dark,
highContrastLight: tuple.highContrastLight,
highContrastDark: tuple.highContrastDark,
},
};
};

export const normalizeColorObject = (
Expand All @@ -49,6 +60,8 @@ export const normalizeColorObject = (
dynamic: {
light: normalizeColor(dynamic.light),
dark: normalizeColor(dynamic.dark),
highContrastLight: normalizeColor(dynamic.highContrastLight),
highContrastDark: normalizeColor(dynamic.highContrastDark),
},
};
return dynamicColor;
Expand All @@ -67,6 +80,8 @@ export const processColorObject = (
dynamic: {
light: processColor(dynamic.light),
dark: processColor(dynamic.dark),
highContrastLight: processColor(dynamic.highContrastLight),
highContrastDark: processColor(dynamic.highContrastDark),
},
};
return dynamicColor;
Expand Down
9 changes: 8 additions & 1 deletion Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ import {DynamicColorIOSPrivate} from './PlatformColorValueTypes';
export type DynamicColorIOSTuple = {
light: ColorValue,
dark: ColorValue,
highContrastLight?: ColorValue,
highContrastDark?: ColorValue,
};

export const DynamicColorIOS = (tuple: DynamicColorIOSTuple): ColorValue => {
return DynamicColorIOSPrivate({light: tuple.light, dark: tuple.dark});
return DynamicColorIOSPrivate({
light: tuple.light,
dark: tuple.dark,
highContrastLight: tuple.highContrastLight,
highContrastDark: tuple.highContrastDark,
});
};
2 changes: 2 additions & 0 deletions Libraries/StyleSheet/PlatformColorValueTypesIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type {ColorValue} from './StyleSheet';
export type DynamicColorIOSTuple = {
light: ColorValue,
dark: ColorValue,
highContrastLight?: ColorValue,
highContrastDark?: ColorValue,
};

export const DynamicColorIOS = (tuple: DynamicColorIOSTuple): ColorValue => {
Expand Down
19 changes: 19 additions & 0 deletions Libraries/StyleSheet/__tests__/normalizeColor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ describe('iOS', () => {
expect(normalizedColor).toEqual(expectedColor);
});

it('should normalize iOS Dynamic colors with accessible colors', () => {
const color = DynamicColorIOS({
light: 'black',
dark: 'white',
highContrastLight: 'red',
highContrastDark: 'blue',
});
const normalizedColor = normalizeColor(color);
const expectedColor = {
dynamic: {
light: 'black',
dark: 'white',
highContrastLight: 'red',
highContrastDark: 'blue',
},
};
expect(normalizedColor).toEqual(expectedColor);
});

it('should normalize iOS Dynamic colors with PlatformColor colors', () => {
const color = DynamicColorIOS({
light: PlatformColor('systemBlackColor'),
Expand Down
24 changes: 20 additions & 4 deletions React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -879,13 +879,29 @@ + (UIColor *)UIColor:(id)json
UIColor *lightColor = [RCTConvert UIColor:light];
id dark = [appearances objectForKey:@"dark"];
UIColor *darkColor = [RCTConvert UIColor:dark];
id highContrastLight = [appearances objectForKey:@"highContrastLight"];
UIColor *highContrastLightColor = [RCTConvert UIColor:highContrastLight];
id highContrastDark = [appearances objectForKey:@"highContrastDark"];
UIColor *highContrastDarkColor = [RCTConvert UIColor:highContrastDark];
if (lightColor != nil && darkColor != nil) {
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if (@available(iOS 13.0, *)) {
UIColor *color =
[UIColor colorWithDynamicProvider:^UIColor *_Nonnull(UITraitCollection *_Nonnull collection) {
return collection.userInterfaceStyle == UIUserInterfaceStyleDark ? darkColor : lightColor;
}];
UIColor *color = [UIColor colorWithDynamicProvider:^UIColor *_Nonnull(
UITraitCollection *_Nonnull collection) {
if (collection.userInterfaceStyle == UIUserInterfaceStyleDark) {
if (collection.accessibilityContrast == UIAccessibilityContrastHigh && highContrastDarkColor != nil) {
return highContrastDarkColor;
} else {
return darkColor;
}
} else {
if (collection.accessibilityContrast == UIAccessibilityContrastHigh && highContrastLightColor != nil) {
return highContrastLightColor;
} else {
return lightColor;
}
}
}];
return color;
} else {
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ module.exports = {
const properties = args[0].properties;
if (
!(
properties.length === 2 &&
properties[0].type === 'Property' &&
properties[0].key.name === 'light' &&
properties[1].type === 'Property' &&
Expand Down