Skip to content

Commit 7b6aa55

Browse files
Saadnajmipull[bot]ryanlntnntremganandraj
authored
[0.66] Backport a few of 10.15+ changes to 0.66 stable (#1030)
* RCTSwitch: Use NSSwitch instead of NSButton (#924) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * [pull] master from microsoft:master (#11) * Deprecated api (#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (#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 (#855) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * 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 <[email protected]> * Grammar fixes. (#856) Updates simple grammar issues. Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Saad Najmi <[email protected]> Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]> * Use NSSwitch * remove change from my fork Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]> * DynamicColorMacOS fixes (#1028) * Use initWithDynamicProvider + Add HC Support * Update log error * replace all references to 10.14 (#938) * Replace currentAppearance with currentDrawingAppearance on macOS 11+ (#1029) * Manually cherry-pick #1012 Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]>
1 parent 2291936 commit 7b6aa55

File tree

14 files changed

+125
-335
lines changed

14 files changed

+125
-335
lines changed

Libraries/Image/RCTImageView.mm

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -649,18 +649,12 @@ - (RCTPlatformView *)reactAccessibilityElement
649649

650650
- (NSColor *)tintColor
651651
{
652-
NSColor *tintColor = nil;
653-
if (@available(macOS 10.14, *)) {
654-
tintColor = _imageView.contentTintColor;
655-
}
656-
return tintColor;
652+
return _imageView.contentTintColor;
657653
}
658654

659655
- (void)setTintColor:(NSColor *)tintColor
660656
{
661-
if (@available(macOS 10.14, *)) {
662-
_imageView.contentTintColor = tintColor;
663-
}
657+
_imageView.contentTintColor = tintColor;
664658
}
665659
#endif // ]TODO(macOS GH#774)
666660

Libraries/StyleSheet/PlatformColorValueTypes.macos.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export opaque type NativeColorValue = {
1818
dynamic?: {
1919
light: ?(ColorValue | ProcessedColorValue),
2020
dark: ?(ColorValue | ProcessedColorValue),
21+
highContrastLight?: ?(ColorValue | ProcessedColorValue),
22+
highContrastDark?: ?(ColorValue | ProcessedColorValue),
2123
},
2224
colorWithSystemEffect?: {
2325
baseColor: ?(ColorValue | ProcessedColorValue),
@@ -51,12 +53,21 @@ export const ColorWithSystemEffectMacOSPrivate = (
5153
export type DynamicColorMacOSTuplePrivate = {
5254
light: ColorValue,
5355
dark: ColorValue,
56+
highContrastLight?: ColorValue,
57+
highContrastDark?: ColorValue,
5458
};
5559

5660
export const DynamicColorMacOSPrivate = (
5761
tuple: DynamicColorMacOSTuplePrivate,
5862
): ColorValue => {
59-
return {dynamic: {light: tuple.light, dark: tuple.dark}};
63+
return {
64+
dynamic: {
65+
light: tuple.light,
66+
dark: tuple.dark,
67+
highContrastLight: tuple.highContrastLight,
68+
highContrastDark: tuple.highContrastDark,
69+
},
70+
};
6071
};
6172

6273
export const normalizeColorObject = (
@@ -74,6 +85,8 @@ export const normalizeColorObject = (
7485
dynamic: {
7586
light: normalizeColor(dynamic.light),
7687
dark: normalizeColor(dynamic.dark),
88+
highContrastLight: normalizeColor(dynamic.highContrastLight),
89+
highContrastDark: normalizeColor(dynamic.highContrastDark),
7790
},
7891
};
7992
return dynamicColor;
@@ -104,6 +117,8 @@ export const processColorObject = (
104117
dynamic: {
105118
light: processColor(dynamic.light),
106119
dark: processColor(dynamic.dark),
120+
highContrastLight: processColor(dynamic.highContrastLight),
121+
highContrastDark: processColor(dynamic.highContrastDark),
107122
},
108123
};
109124
return dynamicColor;

Libraries/StyleSheet/PlatformColorValueTypesMacOS.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import type {ColorValue} from './StyleSheet';
1515
export type DynamicColorMacOSTuple = {
1616
light: ColorValue,
1717
dark: ColorValue,
18+
highContrastLight?: ColorValue,
19+
highContrastDark?: ColorValue,
1820
};
1921

2022
export const DynamicColorMacOS = (

Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ import {
1919
export type DynamicColorMacOSTuple = {
2020
light: ColorValue,
2121
dark: ColorValue,
22+
highContrastLight?: ColorValue,
23+
highContrastDark?: ColorValue,
2224
};
2325

2426
export const DynamicColorMacOS = (
2527
tuple: DynamicColorMacOSTuple,
2628
): ColorValue => {
27-
return DynamicColorMacOSPrivate({light: tuple.light, dark: tuple.dark});
29+
return DynamicColorMacOSPrivate({
30+
light: tuple.light,
31+
dark: tuple.dark,
32+
highContrastLight: tuple.highContrastLight,
33+
highContrastDark: tuple.highContrastDark,
34+
});
2835
};
2936

3037
export type SystemEffectMacOS =

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ You can read more about the macOS implementation on our website - [React Native
6262

6363
## Requirements
6464

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

6767
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.
6868

React/Base/RCTConvert.m

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#import "RCTParserUtils.h"
1717
#import "RCTUtils.h"
1818

19-
#if TARGET_OS_OSX // [TODO(macOS GH#774)
20-
#import "RCTDynamicColor.h"
21-
#endif // ]TODO(macOS GH#774)
22-
2319
@implementation RCTConvert
2420

2521
RCT_CONVERTER(id, id, self)
@@ -1043,7 +1039,28 @@ + (RCTUIColor *)UIColor:(id)json // TODO(macOS GH#750)
10431039
RCTUIColor *highContrastDarkColor = [RCTConvert UIColor:highContrastDark]; // TODO(macOS GH#750)
10441040
if (lightColor != nil && darkColor != nil) {
10451041
#if TARGET_OS_OSX
1046-
RCTDynamicColor *color = [[RCTDynamicColor alloc] initWithAquaColor:lightColor darkAquaColor:darkColor];
1042+
NSColor *color = [NSColor colorWithName:nil dynamicProvider:^NSColor * _Nonnull(NSAppearance * _Nonnull appearance) {
1043+
NSMutableArray<NSAppearanceName> *appearances = [NSMutableArray arrayWithArray:@[NSAppearanceNameAqua,NSAppearanceNameDarkAqua]];
1044+
if (highContrastLightColor != nil) {
1045+
[appearances addObject:NSAppearanceNameAccessibilityHighContrastAqua];
1046+
}
1047+
if (highContrastDarkColor != nil) {
1048+
[appearances addObject:NSAppearanceNameAccessibilityHighContrastDarkAqua];
1049+
}
1050+
NSAppearanceName bestMatchingAppearance = [appearance bestMatchFromAppearancesWithNames:appearances];
1051+
if (bestMatchingAppearance == NSAppearanceNameAqua) {
1052+
return lightColor;
1053+
} else if (bestMatchingAppearance == NSAppearanceNameDarkAqua) {
1054+
return darkColor;
1055+
} else if (bestMatchingAppearance == NSAppearanceNameAccessibilityHighContrastAqua) {
1056+
return highContrastLightColor;
1057+
} else if (bestMatchingAppearance == NSAppearanceNameAccessibilityHighContrastDarkAqua) {
1058+
return highContrastDarkColor;
1059+
} else {
1060+
RCTLogConvertError(json, @"an NSColorColor. Could not resolve current appearance. Defaulting to light.");
1061+
return lightColor;
1062+
}
1063+
}];
10471064
return color;
10481065
#else
10491066
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000

React/Base/macOS/RCTDynamicColor.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

React/Base/macOS/RCTDynamicColor.m

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)