Skip to content

Commit

Permalink
replace all references to 10.14 (facebook#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored Jan 25, 2022
1 parent 5ad4444 commit 643b056
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 62 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
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
2 changes: 1 addition & 1 deletion React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Pod::Spec.new do |s|
end

s.subspec "Hermes" do |ss|
ss.platforms = { :osx => "10.15" }
ss.platforms = { :osx => "10.15", :ios => "11.0" }
ss.source_files = "ReactCommon/hermes/executor/*.{cpp,h}",
"ReactCommon/hermes/inspector/*.{cpp,h}",
"ReactCommon/hermes/inspector/chrome/*.{cpp,h}",
Expand Down
10 changes: 4 additions & 6 deletions React/Base/macOS/RCTDynamicColor.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
- (NSColor *)effectiveColor
{
NSColor *effectiveColor = _aquaColor;
if (@available(macOS 10.14, *)) {
NSAppearance *appearance = [NSAppearance currentAppearance] ?: [NSApp effectiveAppearance];
NSAppearance *appearance = [NSAppearance currentAppearance] ?: [NSApp effectiveAppearance];

NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];

if (_darkAquaColor != nil && [appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
effectiveColor = _darkAquaColor;
}
if (_darkAquaColor != nil && [appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
effectiveColor = _darkAquaColor;
}
return effectiveColor;
}
Expand Down
41 changes: 18 additions & 23 deletions React/CoreModules/RCTAppearance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,24 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride)
#else // [TODO(macOS GH#774)
NSString *RCTColorSchemePreference(NSAppearance *appearance)
{
if (@available(macOS 10.14, *)) {
static NSDictionary *appearances;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
appearances = @{
NSAppearanceNameAqua: RCTAppearanceColorSchemeLight,
NSAppearanceNameDarkAqua: RCTAppearanceColorSchemeDark
};
});

if (!sAppearancePreferenceEnabled) {
// Return the default if the app doesn't allow different color schemes.
return RCTAppearanceColorSchemeLight;
}

appearance = appearance ?: [NSAppearance currentAppearance];
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
static NSDictionary *appearances;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
appearances = @{
NSAppearanceNameAqua: RCTAppearanceColorSchemeLight,
NSAppearanceNameDarkAqua: RCTAppearanceColorSchemeDark
};
});

if (!sAppearancePreferenceEnabled) {
// Return the default if the app doesn't allow different color schemes.
return RCTAppearanceColorSchemeLight;
}

// Default to light on older OS version - same behavior as Android.
return RCTAppearanceColorSchemeLight;
appearance = appearance ?: [NSAppearance currentAppearance];
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
}
#endif // ]TODO(macOS GH#774)

Expand Down Expand Up @@ -165,7 +160,7 @@ - (void)appearanceChanged:(NSNotification *)notification

- (void)startObserving
{
if (@available(macOS 10.14, iOS 13.0, *)) { // TODO(macOS GH#774)
if (@available(iOS 13.0, *)) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appearanceChanged:)
name:RCTUserInterfaceStyleDidChangeNotification
Expand All @@ -175,7 +170,7 @@ - (void)startObserving

- (void)stopObserving
{
if (@available(macOS 10.14, iOS 13.0, *)) { // TODO(macOS GH#774)
if (@available(iOS 13.0, *)) {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
}
Expand Down
38 changes: 15 additions & 23 deletions packages/rn-tester/RNTesterUnitTests/RCTConvert_NSColorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@ - (void)testAlternatingColorEven
{
id json = RCTJSONParse(@"{ \"semantic\": \"alternatingContentBackgroundColorEven\" }", nil);
NSColor *value = [RCTConvert UIColor:json];
if (@available(macOS 10.14, *)) {
XCTAssertEqualObjects(value, [NSColor alternatingContentBackgroundColors][0]);
}
XCTAssertEqualObjects(value, [NSColor alternatingContentBackgroundColors][0]);
}

- (void)testAlternatingColorOdd
{
id json = RCTJSONParse(@"{ \"semantic\": \"alternatingContentBackgroundColorOdd\" }", nil);
NSColor *value = [RCTConvert UIColor:json];
if (@available(macOS 10.14, *)) {
XCTAssertEqualObjects(value, [NSColor alternatingContentBackgroundColors][1]);
}
XCTAssertEqualObjects(value, [NSColor alternatingContentBackgroundColors][1]);
}

- (void)testAlternatingColorFallbackEven
Expand Down Expand Up @@ -99,14 +95,12 @@ - (void)testDynamicColor
XCTAssertEqual(b, 0);
XCTAssertEqual(a, 0);

if (@available(macOS 10.14, *)) {
[NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
[value getRed:&r green:&g blue:&b alpha:&a];
XCTAssertEqual(r, 1);
XCTAssertEqual(g, 1);
XCTAssertEqual(b, 1);
XCTAssertEqual(a, 0);
}
[NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
[value getRed:&r green:&g blue:&b alpha:&a];
XCTAssertEqual(r, 1);
XCTAssertEqual(g, 1);
XCTAssertEqual(b, 1);
XCTAssertEqual(a, 0);

[NSAppearance setCurrentAppearance:nil];
}
Expand All @@ -127,15 +121,13 @@ - (void)testCompositeDynamicColor
XCTAssertEqual(b1, b2);
XCTAssertEqual(a1, a2);

if (@available(macOS 10.14, *)) {
[NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
[[value colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r1 green:&g1 blue:&b1 alpha:&a1];
[[[NSColor systemBlueColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r2 green:&g2 blue:&b2 alpha:&a2];
XCTAssertEqual(r1, r2);
XCTAssertEqual(g1, g2);
XCTAssertEqual(b1, b2);
XCTAssertEqual(a1, a2);
}
[NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]];
[[value colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r1 green:&g1 blue:&b1 alpha:&a1];
[[[NSColor systemBlueColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r2 green:&g2 blue:&b2 alpha:&a2];
XCTAssertEqual(r1, r2);
XCTAssertEqual(g1, g2);
XCTAssertEqual(b1, b2);
XCTAssertEqual(a1, a2);

[NSAppearance setCurrentAppearance:nil];
}
Expand Down

0 comments on commit 643b056

Please sign in to comment.