|
7 | 7 |
|
8 | 8 | #import "PlatformColorParser.h" |
9 | 9 |
|
| 10 | +#import <React/RCTUIKit.h> // [macOS] |
10 | 11 | #import <react/renderer/core/RawValue.h> |
11 | 12 | #import <react/renderer/graphics/HostPlatformColor.h> |
12 | 13 | #import <react/renderer/graphics/RCTPlatformColorUtils.h> |
|
18 | 19 |
|
19 | 20 | NS_ASSUME_NONNULL_BEGIN |
20 | 21 |
|
| 22 | +#if TARGET_OS_OSX // [macOS |
| 23 | +// Forward declaration for ColorWithSystemEffect helper |
| 24 | +RCTUIColor *_Nullable UIColorFromColorWithSystemEffect( |
| 25 | + RCTUIColor *baseColor, |
| 26 | + const std::string &systemEffectString); |
| 27 | +#endif // macOS] |
| 28 | + |
21 | 29 | namespace facebook::react { |
22 | 30 |
|
23 | 31 | inline facebook::react::SharedColor RCTPlatformColorComponentsFromDynamicItems( |
@@ -63,6 +71,27 @@ SharedColor parsePlatformColor(const ContextContainer &contextContainer, int32_t |
63 | 71 | auto dynamicItems = (std::unordered_map<std::string, RawValue>)items.at("dynamic"); |
64 | 72 | return RCTPlatformColorComponentsFromDynamicItems(contextContainer, surfaceId, dynamicItems); |
65 | 73 | } |
| 74 | +#if TARGET_OS_OSX // [macOS |
| 75 | + else if ( |
| 76 | + items.find("colorWithSystemEffect") != items.end() && |
| 77 | + items.at("colorWithSystemEffect").hasType<std::unordered_map<std::string, RawValue>>()) { |
| 78 | + auto colorWithSystemEffectItems = (std::unordered_map<std::string, RawValue>)items.at("colorWithSystemEffect"); |
| 79 | + if (colorWithSystemEffectItems.find("baseColor") != colorWithSystemEffectItems.end() && |
| 80 | + colorWithSystemEffectItems.find("systemEffect") != colorWithSystemEffectItems.end() && |
| 81 | + colorWithSystemEffectItems.at("systemEffect").hasType<std::string>()) { |
| 82 | + SharedColor baseColorShared{}; |
| 83 | + fromRawValue(contextContainer, surfaceId, colorWithSystemEffectItems.at("baseColor"), baseColorShared); |
| 84 | + if (baseColorShared) { |
| 85 | + RCTUIColor *baseColor = RCTPlatformColorFromColor(*baseColorShared); |
| 86 | + std::string systemEffect = (std::string)colorWithSystemEffectItems.at("systemEffect"); |
| 87 | + RCTUIColor *colorWithEffect = UIColorFromColorWithSystemEffect(baseColor, systemEffect); |
| 88 | + if (colorWithEffect != nil) { |
| 89 | + return SharedColor(Color(wrapManagedObject(colorWithEffect))); |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | +#endif // macOS] |
66 | 95 | } |
67 | 96 |
|
68 | 97 | return clearColor(); |
|
0 commit comments