react-native-macos 0.66.12 → 0.66.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/AddressSanitizerCrash/RCTAddressSanitizerCrash.js +25 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageView.mm +2 -8
- package/Libraries/StyleSheet/PlatformColorValueTypes.macos.js +16 -1
- package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.js +2 -0
- package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js +8 -1
- package/README.md +1 -1
- package/React/Base/RCTConvert.m +22 -5
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/RCTAddressSanitizerCrashManager.h +12 -0
- package/React/CoreModules/RCTAddressSanitizerCrashManager.mm +18 -0
- package/React/CoreModules/RCTAppearance.mm +22 -23
- package/React/CoreModules/RCTDevLoadingView.mm +15 -10
- package/React/Views/RCTSwitch.h +1 -1
- package/React/Views/RCTSwitch.m +0 -15
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/React/Base/macOS/RCTDynamicColor.h +0 -28
- package/React/Base/macOS/RCTDynamicColor.m +0 -219
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @flow
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
|
|
13
|
+
import type {ViewProps} from '../Components/View/ViewPropTypes';
|
|
14
|
+
|
|
15
|
+
const {requireNativeComponent} = require('react-native');
|
|
16
|
+
|
|
17
|
+
type NativeProps = $ReadOnly<{|
|
|
18
|
+
...ViewProps,
|
|
19
|
+
|}>;
|
|
20
|
+
|
|
21
|
+
const RCTAddressSanitizerCrash: HostComponent<NativeProps> = requireNativeComponent<NativeProps>(
|
|
22
|
+
'RCTAddressSanitizerCrash',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
module.exports = RCTAddressSanitizerCrash;
|
|
@@ -649,18 +649,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
649
649
|
|
|
650
650
|
- (NSColor *)tintColor
|
|
651
651
|
{
|
|
652
|
-
|
|
653
|
-
if (@available(macOS 10.14, *)) {
|
|
654
|
-
tintColor = _imageView.contentTintColor;
|
|
655
|
-
}
|
|
656
|
-
return tintColor;
|
|
652
|
+
return _imageView.contentTintColor;
|
|
657
653
|
}
|
|
658
654
|
|
|
659
655
|
- (void)setTintColor:(NSColor *)tintColor
|
|
660
656
|
{
|
|
661
|
-
|
|
662
|
-
_imageView.contentTintColor = tintColor;
|
|
663
|
-
}
|
|
657
|
+
_imageView.contentTintColor = tintColor;
|
|
664
658
|
}
|
|
665
659
|
#endif // ]TODO(macOS GH#774)
|
|
666
660
|
|
|
@@ -18,6 +18,8 @@ export opaque type NativeColorValue = {
|
|
|
18
18
|
dynamic?: {
|
|
19
19
|
light: ?(ColorValue | ProcessedColorValue),
|
|
20
20
|
dark: ?(ColorValue | ProcessedColorValue),
|
|
21
|
+
highContrastLight?: ?(ColorValue | ProcessedColorValue),
|
|
22
|
+
highContrastDark?: ?(ColorValue | ProcessedColorValue),
|
|
21
23
|
},
|
|
22
24
|
colorWithSystemEffect?: {
|
|
23
25
|
baseColor: ?(ColorValue | ProcessedColorValue),
|
|
@@ -51,12 +53,21 @@ export const ColorWithSystemEffectMacOSPrivate = (
|
|
|
51
53
|
export type DynamicColorMacOSTuplePrivate = {
|
|
52
54
|
light: ColorValue,
|
|
53
55
|
dark: ColorValue,
|
|
56
|
+
highContrastLight?: ColorValue,
|
|
57
|
+
highContrastDark?: ColorValue,
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
export const DynamicColorMacOSPrivate = (
|
|
57
61
|
tuple: DynamicColorMacOSTuplePrivate,
|
|
58
62
|
): ColorValue => {
|
|
59
|
-
return {
|
|
63
|
+
return {
|
|
64
|
+
dynamic: {
|
|
65
|
+
light: tuple.light,
|
|
66
|
+
dark: tuple.dark,
|
|
67
|
+
highContrastLight: tuple.highContrastLight,
|
|
68
|
+
highContrastDark: tuple.highContrastDark,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
60
71
|
};
|
|
61
72
|
|
|
62
73
|
export const normalizeColorObject = (
|
|
@@ -74,6 +85,8 @@ export const normalizeColorObject = (
|
|
|
74
85
|
dynamic: {
|
|
75
86
|
light: normalizeColor(dynamic.light),
|
|
76
87
|
dark: normalizeColor(dynamic.dark),
|
|
88
|
+
highContrastLight: normalizeColor(dynamic.highContrastLight),
|
|
89
|
+
highContrastDark: normalizeColor(dynamic.highContrastDark),
|
|
77
90
|
},
|
|
78
91
|
};
|
|
79
92
|
return dynamicColor;
|
|
@@ -104,6 +117,8 @@ export const processColorObject = (
|
|
|
104
117
|
dynamic: {
|
|
105
118
|
light: processColor(dynamic.light),
|
|
106
119
|
dark: processColor(dynamic.dark),
|
|
120
|
+
highContrastLight: processColor(dynamic.highContrastLight),
|
|
121
|
+
highContrastDark: processColor(dynamic.highContrastDark),
|
|
107
122
|
},
|
|
108
123
|
};
|
|
109
124
|
return dynamicColor;
|
|
@@ -19,12 +19,19 @@ import {
|
|
|
19
19
|
export type DynamicColorMacOSTuple = {
|
|
20
20
|
light: ColorValue,
|
|
21
21
|
dark: ColorValue,
|
|
22
|
+
highContrastLight?: ColorValue,
|
|
23
|
+
highContrastDark?: ColorValue,
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export const DynamicColorMacOS = (
|
|
25
27
|
tuple: DynamicColorMacOSTuple,
|
|
26
28
|
): ColorValue => {
|
|
27
|
-
return DynamicColorMacOSPrivate({
|
|
29
|
+
return DynamicColorMacOSPrivate({
|
|
30
|
+
light: tuple.light,
|
|
31
|
+
dark: tuple.dark,
|
|
32
|
+
highContrastLight: tuple.highContrastLight,
|
|
33
|
+
highContrastDark: tuple.highContrastDark,
|
|
34
|
+
});
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
export type SystemEffectMacOS =
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ You can read more about the macOS implementation on our website - [React Native
|
|
|
62
62
|
|
|
63
63
|
## Requirements
|
|
64
64
|
|
|
65
|
-
You can run React Native for macOS apps on Mac devices with versions
|
|
65
|
+
You can run React Native for macOS apps on Mac devices with versions Catalina (10.15) or newer.
|
|
66
66
|
|
|
67
67
|
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.
|
|
68
68
|
|
package/React/Base/RCTConvert.m
CHANGED
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
#import "RCTParserUtils.h"
|
|
17
17
|
#import "RCTUtils.h"
|
|
18
18
|
|
|
19
|
-
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
20
|
-
#import "RCTDynamicColor.h"
|
|
21
|
-
#endif // ]TODO(macOS GH#774)
|
|
22
|
-
|
|
23
19
|
@implementation RCTConvert
|
|
24
20
|
|
|
25
21
|
RCT_CONVERTER(id, id, self)
|
|
@@ -1043,7 +1039,28 @@ static NSColor *RCTColorWithSystemEffect(NSColor* color, NSString *systemEffectS
|
|
|
1043
1039
|
RCTUIColor *highContrastDarkColor = [RCTConvert UIColor:highContrastDark]; // TODO(macOS GH#750)
|
|
1044
1040
|
if (lightColor != nil && darkColor != nil) {
|
|
1045
1041
|
#if TARGET_OS_OSX
|
|
1046
|
-
|
|
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
|
+
}];
|
|
1047
1064
|
return color;
|
|
1048
1065
|
#else
|
|
1049
1066
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* This source code is licensed under the MIT license found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#import <React/RCTUIKit.h>
|
|
8
|
+
#import <React/RCTBridge.h>
|
|
9
|
+
|
|
10
|
+
@interface RCTAddressSanitizerCrashManager : NSObject <RCTBridgeModule>
|
|
11
|
+
|
|
12
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTAddressSanitizerCrashManager.mm
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#import "RCTAddressSanitizerCrashManager.h"
|
|
7
|
+
|
|
8
|
+
@implementation RCTAddressSanitizerCrashManager
|
|
9
|
+
|
|
10
|
+
RCT_EXPORT_MODULE(ASANCrash)
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_METHOD(invokeMemoryCrash) {
|
|
13
|
+
char *s = (char*)malloc(100);
|
|
14
|
+
free(s);
|
|
15
|
+
strcpy(s, "Hello world!"); // AddressSanitizer: heap-use-after-free
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@end
|
|
@@ -66,29 +66,28 @@ NSString *RCTColorSchemePreference(UITraitCollection *traitCollection)
|
|
|
66
66
|
#else // [TODO(macOS GH#774)
|
|
67
67
|
NSString *RCTColorSchemePreference(NSAppearance *appearance)
|
|
68
68
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if
|
|
81
|
-
|
|
82
|
-
return RCTAppearanceColorSchemeLight;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
appearance = appearance ?: [NSAppearance currentAppearance];
|
|
86
|
-
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
87
|
-
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
|
|
69
|
+
static NSDictionary *appearances;
|
|
70
|
+
static dispatch_once_t onceToken;
|
|
71
|
+
|
|
72
|
+
dispatch_once(&onceToken, ^{
|
|
73
|
+
appearances = @{
|
|
74
|
+
NSAppearanceNameAqua: RCTAppearanceColorSchemeLight,
|
|
75
|
+
NSAppearanceNameDarkAqua: RCTAppearanceColorSchemeDark
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!sAppearancePreferenceEnabled) {
|
|
80
|
+
// Return the default if the app doesn't allow different color schemes.
|
|
81
|
+
return RCTAppearanceColorSchemeLight;
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
if (@available(macOS 11.0, *)) {
|
|
85
|
+
appearance = appearance ?: [NSAppearance currentDrawingAppearance];
|
|
86
|
+
} else {
|
|
87
|
+
appearance = appearance ?: [NSAppearance currentAppearance];
|
|
88
|
+
}
|
|
89
|
+
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
90
|
+
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
|
|
92
91
|
}
|
|
93
92
|
#endif // ]TODO(macOS GH#774)
|
|
94
93
|
|
|
@@ -165,7 +164,7 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
|
|
|
165
164
|
|
|
166
165
|
- (void)startObserving
|
|
167
166
|
{
|
|
168
|
-
if (@available(
|
|
167
|
+
if (@available(iOS 13.0, *)) {
|
|
169
168
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
170
169
|
selector:@selector(appearanceChanged:)
|
|
171
170
|
name:RCTUserInterfaceStyleDidChangeNotification
|
|
@@ -175,7 +174,7 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
|
|
|
175
174
|
|
|
176
175
|
- (void)stopObserving
|
|
177
176
|
{
|
|
178
|
-
if (@available(
|
|
177
|
+
if (@available(iOS 13.0, *)) {
|
|
179
178
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
180
179
|
}
|
|
181
180
|
}
|
|
@@ -266,16 +266,21 @@ RCT_EXPORT_METHOD(hide)
|
|
|
266
266
|
|
|
267
267
|
- (void)showOfflineMessage
|
|
268
268
|
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
269
|
+
// [TODO(macOS GH#774) - isDarkModeEnabled should only be run on the main thread
|
|
270
|
+
__weak __typeof(self) weakSelf = self;
|
|
271
|
+
RCTExecuteOnMainQueue(^{
|
|
272
|
+
RCTUIColor *color = [RCTUIColor whiteColor]; // TODO(macOS GH#774)
|
|
273
|
+
RCTUIColor *backgroundColor = [RCTUIColor blackColor]; // TODO(macOS GH#774)
|
|
274
|
+
|
|
275
|
+
if ([weakSelf isDarkModeEnabled]) {
|
|
276
|
+
color = [RCTUIColor blackColor]; // TODO(macOS GH#774)
|
|
277
|
+
backgroundColor = [RCTUIColor whiteColor]; // TODO(macOS GH#774)
|
|
278
|
+
}
|
|
276
279
|
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
NSString *message = [NSString stringWithFormat:@"Connect to %@ to develop JavaScript.", RCT_PACKAGER_NAME];
|
|
281
|
+
[weakSelf showMessage:message color:color backgroundColor:backgroundColor];
|
|
282
|
+
});
|
|
283
|
+
// ]TODO(macOS GH#774)
|
|
279
284
|
}
|
|
280
285
|
|
|
281
286
|
- (BOOL)isDarkModeEnabled
|
|
@@ -361,4 +366,4 @@ RCT_EXPORT_METHOD(hide)
|
|
|
361
366
|
Class RCTDevLoadingViewCls(void)
|
|
362
367
|
{
|
|
363
368
|
return RCTDevLoadingView.class;
|
|
364
|
-
}
|
|
369
|
+
}
|
package/React/Views/RCTSwitch.h
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
13
13
|
@interface RCTSwitch : UISwitch
|
|
14
14
|
#else // [TODO(macOS GH#774)
|
|
15
|
-
@interface RCTSwitch :
|
|
15
|
+
@interface RCTSwitch : NSSwitch
|
|
16
16
|
#endif // ]TODO(macOS GH#774)
|
|
17
17
|
|
|
18
18
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
package/React/Views/RCTSwitch.m
CHANGED
|
@@ -7,25 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
#import "RCTSwitch.h"
|
|
9
9
|
|
|
10
|
-
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
11
|
-
#import <QuartzCore/QuartzCore.h>
|
|
12
|
-
#endif // ]TODO(macOS GH#774)
|
|
13
|
-
|
|
14
10
|
#import "UIView+React.h"
|
|
15
11
|
|
|
16
12
|
@implementation RCTSwitch
|
|
17
13
|
|
|
18
|
-
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
19
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
20
|
-
{
|
|
21
|
-
if ((self = [super initWithFrame:frame])) {
|
|
22
|
-
self.buttonType = NSButtonTypeSwitch;
|
|
23
|
-
self.title = @""; // default is "Button"
|
|
24
|
-
}
|
|
25
|
-
return self;
|
|
26
|
-
}
|
|
27
|
-
#endif
|
|
28
|
-
|
|
29
14
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
30
15
|
- (void)setOn:(BOOL)on animated:(BOOL)animated
|
|
31
16
|
{
|
package/package.json
CHANGED
package/template/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// TODO(macOS GH#774)
|
|
9
|
-
|
|
10
|
-
#include <AppKit/AppKit.h>
|
|
11
|
-
|
|
12
|
-
/** A dynamic, theme aware subclass of NSColor.
|
|
13
|
-
* It is a tuple that contains two NSColors for light and dark
|
|
14
|
-
* theme appearances. Like a semantic NSColor or an
|
|
15
|
-
* asset catalog named NSColor, the effective color values
|
|
16
|
-
* returned by the various methods and properties vary
|
|
17
|
-
* depending on the current [NSAppearance currentAppearance].
|
|
18
|
-
*/
|
|
19
|
-
@interface RCTDynamicColor : NSColor
|
|
20
|
-
|
|
21
|
-
/** Inits a RCTDynamicColor with a pair of NSColors
|
|
22
|
-
* @param aquaColor the color to use when the current appearance is not dark
|
|
23
|
-
* @param darkAquaColor the color to use when the current appearance is dark
|
|
24
|
-
*/
|
|
25
|
-
- (instancetype)initWithAquaColor:(NSColor *)aquaColor
|
|
26
|
-
darkAquaColor:(nullable NSColor *)darkAquaColor;
|
|
27
|
-
|
|
28
|
-
@end
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// TODO(macOS GH#774)
|
|
9
|
-
|
|
10
|
-
#import "RCTDynamicColor.h"
|
|
11
|
-
|
|
12
|
-
#define RCT_FORWARD_PROPERTY( PROP, TYPE ) \
|
|
13
|
-
- (TYPE)PROP { return [[self effectiveColor] PROP]; }
|
|
14
|
-
|
|
15
|
-
static NSString *const RCTAquaColor = @"aquaColor";
|
|
16
|
-
static NSString *const RCTDarkAquaColor = @"darkAquaColor";
|
|
17
|
-
|
|
18
|
-
@implementation RCTDynamicColor
|
|
19
|
-
{
|
|
20
|
-
NSColor *_aquaColor;
|
|
21
|
-
NSColor *_darkAquaColor;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
- (instancetype)initWithAquaColor:(NSColor *)aquaColor
|
|
25
|
-
darkAquaColor:(NSColor *)darkAquaColor
|
|
26
|
-
{
|
|
27
|
-
self = [super init];
|
|
28
|
-
if (self) {
|
|
29
|
-
_aquaColor = [aquaColor copy];
|
|
30
|
-
_darkAquaColor = [darkAquaColor copy];
|
|
31
|
-
}
|
|
32
|
-
return self;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
+ (BOOL)supportsSecureCoding
|
|
36
|
-
{
|
|
37
|
-
return YES;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
- (instancetype)initWithCoder:(NSCoder *)coder
|
|
41
|
-
{
|
|
42
|
-
self = [super initWithCoder:coder];
|
|
43
|
-
if (self) {
|
|
44
|
-
_aquaColor = [coder decodeObjectOfClass:[NSColor class] forKey:RCTAquaColor];
|
|
45
|
-
_darkAquaColor = [coder decodeObjectOfClass:[NSColor class] forKey:RCTDarkAquaColor];
|
|
46
|
-
}
|
|
47
|
-
return self;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
51
|
-
{
|
|
52
|
-
[super encodeWithCoder:aCoder];
|
|
53
|
-
[aCoder encodeObject:_aquaColor forKey:RCTAquaColor];
|
|
54
|
-
if (_darkAquaColor) {
|
|
55
|
-
[aCoder encodeObject:_darkAquaColor forKey:RCTDarkAquaColor];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
- (NSColor *)effectiveColor
|
|
60
|
-
{
|
|
61
|
-
NSColor *effectiveColor = _aquaColor;
|
|
62
|
-
if (@available(macOS 10.14, *)) {
|
|
63
|
-
NSAppearance *appearance = [NSAppearance currentAppearance] ?: [NSApp effectiveAppearance];
|
|
64
|
-
|
|
65
|
-
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
66
|
-
|
|
67
|
-
if (_darkAquaColor != nil && [appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
|
|
68
|
-
effectiveColor = _darkAquaColor;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return effectiveColor;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
RCT_FORWARD_PROPERTY(colorSpace, NSColorSpace *)
|
|
75
|
-
- (NSColor *)colorUsingColorSpace:(NSColorSpace *)space
|
|
76
|
-
{
|
|
77
|
-
return [[self effectiveColor] colorUsingColorSpace:space];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
RCT_FORWARD_PROPERTY(colorSpaceName, NSColorSpaceName)
|
|
81
|
-
- (NSColor *)colorUsingColorSpaceName:(NSColorSpaceName)name
|
|
82
|
-
{
|
|
83
|
-
return [[self effectiveColor] colorUsingColorSpaceName:name];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
RCT_FORWARD_PROPERTY(numberOfComponents, NSInteger)
|
|
87
|
-
- (void)getComponents:(CGFloat *)components
|
|
88
|
-
{
|
|
89
|
-
return [[self effectiveColor] getComponents:components];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#pragma mark - RGB colorspace
|
|
93
|
-
|
|
94
|
-
RCT_FORWARD_PROPERTY(redComponent, CGFloat)
|
|
95
|
-
RCT_FORWARD_PROPERTY(greenComponent, CGFloat)
|
|
96
|
-
RCT_FORWARD_PROPERTY(blueComponent, CGFloat)
|
|
97
|
-
|
|
98
|
-
- (void)getRed:(nullable CGFloat *)red green:(nullable CGFloat *)green blue:(nullable CGFloat *)blue alpha:(nullable CGFloat *)alpha
|
|
99
|
-
{
|
|
100
|
-
return [[self effectiveColor] getRed:red green:green blue:blue alpha:alpha];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
#pragma mark - HSB colorspace
|
|
104
|
-
|
|
105
|
-
RCT_FORWARD_PROPERTY(hueComponent, CGFloat)
|
|
106
|
-
RCT_FORWARD_PROPERTY(saturationComponent, CGFloat)
|
|
107
|
-
RCT_FORWARD_PROPERTY(brightnessComponent, CGFloat)
|
|
108
|
-
|
|
109
|
-
- (void)getHue:(nullable CGFloat *)hue saturation:(nullable CGFloat *)saturation brightness:(nullable CGFloat *)brightness alpha:(nullable CGFloat *)alpha
|
|
110
|
-
{
|
|
111
|
-
return [[self effectiveColor] getHue:hue saturation:saturation brightness:brightness alpha:alpha];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
#pragma mark - Gray colorspace
|
|
115
|
-
|
|
116
|
-
RCT_FORWARD_PROPERTY(whiteComponent, CGFloat)
|
|
117
|
-
|
|
118
|
-
- (void)getWhite:(CGFloat *)white alpha:(CGFloat *)alpha
|
|
119
|
-
{
|
|
120
|
-
return [[self effectiveColor] getWhite:white alpha:alpha];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
#pragma mark - CMYK colorspace
|
|
124
|
-
|
|
125
|
-
RCT_FORWARD_PROPERTY(cyanComponent, CGFloat)
|
|
126
|
-
RCT_FORWARD_PROPERTY(magentaComponent, CGFloat)
|
|
127
|
-
RCT_FORWARD_PROPERTY(yellowComponent, CGFloat)
|
|
128
|
-
RCT_FORWARD_PROPERTY(blackComponent, CGFloat)
|
|
129
|
-
|
|
130
|
-
- (void)getCyan:(nullable CGFloat *)cyan magenta:(nullable CGFloat *)magenta yellow:(nullable CGFloat *)yellow black:(nullable CGFloat *)black alpha:(nullable CGFloat *)alpha
|
|
131
|
-
{
|
|
132
|
-
return [[self effectiveColor] getCyan:cyan magenta:magenta yellow:yellow black:black alpha:alpha];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
#pragma mark - Others
|
|
136
|
-
|
|
137
|
-
RCT_FORWARD_PROPERTY(alphaComponent, CGFloat)
|
|
138
|
-
RCT_FORWARD_PROPERTY(CGColor, CGColorRef)
|
|
139
|
-
RCT_FORWARD_PROPERTY(catalogNameComponent, NSColorListName)
|
|
140
|
-
RCT_FORWARD_PROPERTY(colorNameComponent, NSColorName)
|
|
141
|
-
RCT_FORWARD_PROPERTY(localizedCatalogNameComponent, NSColorListName)
|
|
142
|
-
RCT_FORWARD_PROPERTY(localizedColorNameComponent, NSString *)
|
|
143
|
-
|
|
144
|
-
- (void)setStroke
|
|
145
|
-
{
|
|
146
|
-
[[self effectiveColor] setStroke];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
- (void)setFill
|
|
150
|
-
{
|
|
151
|
-
[[self effectiveColor] setFill];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
- (void)set
|
|
155
|
-
{
|
|
156
|
-
[[self effectiveColor] set];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
- (nullable NSColor *)highlightWithLevel:(CGFloat)val
|
|
160
|
-
{
|
|
161
|
-
return [[self effectiveColor] highlightWithLevel:val];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
- (NSColor *)shadowWithLevel:(CGFloat)val
|
|
165
|
-
{
|
|
166
|
-
return [[self effectiveColor] shadowWithLevel:val];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
- (NSColor *)colorWithAlphaComponent:(CGFloat)alpha
|
|
170
|
-
{
|
|
171
|
-
return [[self effectiveColor] colorWithAlphaComponent:alpha];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
- (nullable NSColor *)blendedColorWithFraction:(CGFloat)fraction ofColor:(NSColor *)color
|
|
175
|
-
{
|
|
176
|
-
return [[self effectiveColor] blendedColorWithFraction:fraction ofColor:color];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
- (NSColor *)colorWithSystemEffect:(NSColorSystemEffect)systemEffect NS_AVAILABLE_MAC(10_14)
|
|
180
|
-
{
|
|
181
|
-
NSColor *aquaColorWithSystemEffect = [_aquaColor colorWithSystemEffect:systemEffect];
|
|
182
|
-
NSColor *darkAquaColorWithSystemEffect = [_darkAquaColor colorWithSystemEffect:systemEffect];
|
|
183
|
-
return [[RCTDynamicColor alloc] initWithAquaColor:aquaColorWithSystemEffect darkAquaColor:darkAquaColorWithSystemEffect];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
- (NSUInteger)hash
|
|
187
|
-
{
|
|
188
|
-
const NSUInteger prime = 31;
|
|
189
|
-
NSUInteger result = 1;
|
|
190
|
-
result = prime * result + [_aquaColor hash];
|
|
191
|
-
result = prime * result + [_darkAquaColor hash];
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
- (BOOL)isEqual:(id)other {
|
|
196
|
-
if (other == self) {
|
|
197
|
-
return YES;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return other != nil && [other isKindOfClass:[self class]] && [self isEqualToDynamicColor:other];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
- (BOOL)isEqualToDynamicColor:(RCTDynamicColor *)other {
|
|
204
|
-
if (self == other) {
|
|
205
|
-
return YES;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if ([_aquaColor isNotEqualTo:other->_aquaColor]) {
|
|
209
|
-
return NO;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if ([_darkAquaColor isNotEqualTo:other->_darkAquaColor]) {
|
|
213
|
-
return NO;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return YES;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
@end
|