Skip to content

Commit

Permalink
[0.66] Backport a few of 10.15+ changes to 0.66 stable (facebook#1030)
Browse files Browse the repository at this point in the history
* RCTSwitch: Use NSSwitch instead of NSButton (facebook#924)

* add pull yml

* match handleOpenURLNotification event payload with iOS (facebook#755) (facebook#2)

Co-authored-by: Ryan Linton <ryanlntn@gmail.com>

* [pull] master from microsoft:master (facebook#11)

* Deprecated api (facebook#853)

* Remove deprecated/unused context param
* Update a few Mac deprecated APIs

* Packing RN dependencies, hermes and ignoring javadoc failure,  (facebook#852)

* Ignore javadoc failure

* Bringing few more changes from 0.63-stable

* Fixing a patch in engine selection

* Fixing a patch in nuget spec

* Fixing the output directory of nuget pack

* Packaging dependencies in the nuget

* Fix onMouseEnter/onMouseLeave callbacks not firing on Pressable (facebook#855)

* add pull yml

* match handleOpenURLNotification event payload with iOS (facebook#755) (facebook#2)

Co-authored-by: Ryan Linton <ryanlntn@gmail.com>

* fix mouse evetns on pressable

* delete extra yml from this branch

* Add macOS tags

* reorder props to have onMouseEnter/onMouseLeave always be before onPress

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
Co-authored-by: Ryan Linton <ryanlntn@gmail.com>

* Grammar fixes. (facebook#856)

Updates simple grammar issues.

Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com>
Co-authored-by: Anandraj <anandrag@microsoft.com>
Co-authored-by: Saad Najmi <saadnajmi2@gmail.com>
Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
Co-authored-by: Ryan Linton <ryanlntn@gmail.com>
Co-authored-by: Muhammad Hamza Zaman <mh.zaman.4069@gmail.com>

* Use NSSwitch

* remove change from my fork

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
Co-authored-by: Ryan Linton <ryanlntn@gmail.com>
Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com>
Co-authored-by: Anandraj <anandrag@microsoft.com>
Co-authored-by: Muhammad Hamza Zaman <mh.zaman.4069@gmail.com>

* DynamicColorMacOS fixes (facebook#1028)

* Use initWithDynamicProvider + Add HC Support

* Update log error

* replace all references to 10.14 (facebook#938)

* Replace currentAppearance with currentDrawingAppearance on macOS 11+ (facebook#1029)

* Manually cherry-pick facebook#1012

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
Co-authored-by: Ryan Linton <ryanlntn@gmail.com>
Co-authored-by: Nick Trescases <42704557+ntre@users.noreply.github.com>
Co-authored-by: Anandraj <anandrag@microsoft.com>
Co-authored-by: Muhammad Hamza Zaman <mh.zaman.4069@gmail.com>
  • Loading branch information
6 people authored Feb 19, 2022
1 parent 2291936 commit 7b6aa55
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 335 deletions.
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

0 comments on commit 7b6aa55

Please sign in to comment.