Skip to content

[0.66] Backport a few of 10.15+ changes to 0.66 stable #1030

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 5 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 2 additions & 8 deletions Libraries/Image/RCTImageView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -649,18 +649,12 @@ - (RCTPlatformView *)reactAccessibilityElement

- (NSColor *)tintColor
{
NSColor *tintColor = nil;
if (@available(macOS 10.14, *)) {
tintColor = _imageView.contentTintColor;
}
return tintColor;
return _imageView.contentTintColor;
}

- (void)setTintColor:(NSColor *)tintColor
{
if (@available(macOS 10.14, *)) {
_imageView.contentTintColor = tintColor;
}
_imageView.contentTintColor = tintColor;
}
#endif // ]TODO(macOS GH#774)

Expand Down
17 changes: 16 additions & 1 deletion Libraries/StyleSheet/PlatformColorValueTypes.macos.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export opaque type NativeColorValue = {
dynamic?: {
light: ?(ColorValue | ProcessedColorValue),
dark: ?(ColorValue | ProcessedColorValue),
highContrastLight?: ?(ColorValue | ProcessedColorValue),
highContrastDark?: ?(ColorValue | ProcessedColorValue),
},
colorWithSystemEffect?: {
baseColor: ?(ColorValue | ProcessedColorValue),
Expand Down Expand Up @@ -51,12 +53,21 @@ export const ColorWithSystemEffectMacOSPrivate = (
export type DynamicColorMacOSTuplePrivate = {
light: ColorValue,
dark: ColorValue,
highContrastLight?: ColorValue,
highContrastDark?: ColorValue,
};

export const DynamicColorMacOSPrivate = (
tuple: DynamicColorMacOSTuplePrivate,
): 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 @@ -74,6 +85,8 @@ export const normalizeColorObject = (
dynamic: {
light: normalizeColor(dynamic.light),
dark: normalizeColor(dynamic.dark),
highContrastLight: normalizeColor(dynamic.highContrastLight),
highContrastDark: normalizeColor(dynamic.highContrastDark),
},
};
return dynamicColor;
Expand Down Expand Up @@ -104,6 +117,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
2 changes: 2 additions & 0 deletions Libraries/StyleSheet/PlatformColorValueTypesMacOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import type {ColorValue} from './StyleSheet';
export type DynamicColorMacOSTuple = {
light: ColorValue,
dark: ColorValue,
highContrastLight?: ColorValue,
highContrastDark?: ColorValue,
};

export const DynamicColorMacOS = (
Expand Down
9 changes: 8 additions & 1 deletion Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ import {
export type DynamicColorMacOSTuple = {
light: ColorValue,
dark: ColorValue,
highContrastLight?: ColorValue,
highContrastDark?: ColorValue,
};

export const DynamicColorMacOS = (
tuple: DynamicColorMacOSTuple,
): ColorValue => {
return DynamicColorMacOSPrivate({light: tuple.light, dark: tuple.dark});
return DynamicColorMacOSPrivate({
light: tuple.light,
dark: tuple.dark,
highContrastLight: tuple.highContrastLight,
highContrastDark: tuple.highContrastDark,
});
};

export type SystemEffectMacOS =
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ You can read more about the macOS implementation on our website - [React Native

## Requirements

You can run React Native for macOS apps on Mac devices with versions Mojave (10.14) or newer.
You can run React Native for macOS apps on Mac devices with versions Catalina (10.15) or newer.

For a full and detailed list of the system requirements and how to set up your development platform, see our [System Requirements](https://microsoft.github.io/react-native-windows/docs/rnm-dependencies) documentation on our website.

Expand Down
27 changes: 22 additions & 5 deletions React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#import "RCTParserUtils.h"
#import "RCTUtils.h"

#if TARGET_OS_OSX // [TODO(macOS GH#774)
#import "RCTDynamicColor.h"
#endif // ]TODO(macOS GH#774)

@implementation RCTConvert

RCT_CONVERTER(id, id, self)
Expand Down Expand Up @@ -1043,7 +1039,28 @@ + (RCTUIColor *)UIColor:(id)json // TODO(macOS GH#750)
RCTUIColor *highContrastDarkColor = [RCTConvert UIColor:highContrastDark]; // TODO(macOS GH#750)
if (lightColor != nil && darkColor != nil) {
#if TARGET_OS_OSX
RCTDynamicColor *color = [[RCTDynamicColor alloc] initWithAquaColor:lightColor darkAquaColor:darkColor];
NSColor *color = [NSColor colorWithName:nil dynamicProvider:^NSColor * _Nonnull(NSAppearance * _Nonnull appearance) {
NSMutableArray<NSAppearanceName> *appearances = [NSMutableArray arrayWithArray:@[NSAppearanceNameAqua,NSAppearanceNameDarkAqua]];
if (highContrastLightColor != nil) {
[appearances addObject:NSAppearanceNameAccessibilityHighContrastAqua];
}
if (highContrastDarkColor != nil) {
[appearances addObject:NSAppearanceNameAccessibilityHighContrastDarkAqua];
}
NSAppearanceName bestMatchingAppearance = [appearance bestMatchFromAppearancesWithNames:appearances];
if (bestMatchingAppearance == NSAppearanceNameAqua) {
return lightColor;
} else if (bestMatchingAppearance == NSAppearanceNameDarkAqua) {
return darkColor;
} else if (bestMatchingAppearance == NSAppearanceNameAccessibilityHighContrastAqua) {
return highContrastLightColor;
} else if (bestMatchingAppearance == NSAppearanceNameAccessibilityHighContrastDarkAqua) {
return highContrastDarkColor;
} else {
RCTLogConvertError(json, @"an NSColorColor. Could not resolve current appearance. Defaulting to light.");
return lightColor;
}
}];
return color;
#else
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
Expand Down
28 changes: 0 additions & 28 deletions React/Base/macOS/RCTDynamicColor.h

This file was deleted.

219 changes: 0 additions & 219 deletions React/Base/macOS/RCTDynamicColor.m

This file was deleted.

Loading