diff --git a/Libraries/Image/RCTImageView.mm b/Libraries/Image/RCTImageView.mm index 68818b3a427df3..ae44c0ac9daf88 100644 --- a/Libraries/Image/RCTImageView.mm +++ b/Libraries/Image/RCTImageView.mm @@ -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) diff --git a/README.md b/README.md index 27945d13bbe998..849329aabd7b61 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/React-Core.podspec b/React-Core.podspec index be9f7f2fb90548..82b4110009605c 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -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}", diff --git a/React/Base/macOS/RCTDynamicColor.m b/React/Base/macOS/RCTDynamicColor.m index 3315979c300701..fbc93d1e07af2c 100644 --- a/React/Base/macOS/RCTDynamicColor.m +++ b/React/Base/macOS/RCTDynamicColor.m @@ -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; } diff --git a/React/CoreModules/RCTAppearance.mm b/React/CoreModules/RCTAppearance.mm index b0da18b72db345..26133e1b6a60f9 100644 --- a/React/CoreModules/RCTAppearance.mm +++ b/React/CoreModules/RCTAppearance.mm @@ -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) @@ -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 @@ -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]; } } diff --git a/packages/rn-tester/RNTesterUnitTests/RCTConvert_NSColorTests.m b/packages/rn-tester/RNTesterUnitTests/RCTConvert_NSColorTests.m index 64a1b20ebe08a4..9d38caf000dec3 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTConvert_NSColorTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTConvert_NSColorTests.m @@ -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 @@ -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]; } @@ -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]; }