react-native-macos 0.81.4 → 0.81.5
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/Core/ReactNativeVersion.js +1 -1
- package/Libraries/LinkingIOS/RCTLinkingManager.mm +119 -0
- package/Libraries/LinkingIOS/React-RCTLinking.podspec +0 -4
- package/React/Base/RCTRootView.m +7 -0
- package/React/Base/RCTUIKit.h +18 -7
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +9 -0
- package/React/Base/macOS/RCTUIKit.m +65 -8
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h +6 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +77 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +4 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +69 -3
- package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +306 -8
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +6 -0
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +26 -18
- package/React/Modules/RCTUIManager.mm +1 -1
- package/React/Views/RCTCursor.m +0 -1
- package/React/Views/RCTView.m +1 -2
- package/React/Views/ScrollView/RCTScrollView.m +25 -0
- package/React/Views/UIView+React.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +10 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +72 -6
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.mm +18 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.mm +144 -3
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.h +2 -2
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +3 -3
- package/local-cli/generate-macos.js +0 -3
- package/local-cli/generator-common/index.js +5 -5
- package/local-cli/generator-macos/index.js +7 -22
- package/package.json +2 -2
- package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +0 -123
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
#import "RCTLinkingPlugins.h"
|
|
16
16
|
|
|
17
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
18
|
+
|
|
17
19
|
static NSString *const kOpenURLNotification = @"RCTOpenURLNotification";
|
|
18
20
|
|
|
19
21
|
static void postNotificationWithURL(NSURL *URL, id sender)
|
|
@@ -22,6 +24,24 @@ static void postNotificationWithURL(NSURL *URL, id sender)
|
|
|
22
24
|
[[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification object:sender userInfo:payload];
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
#else // [macOS
|
|
28
|
+
|
|
29
|
+
NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
|
30
|
+
|
|
31
|
+
static NSString *initialURL = nil;
|
|
32
|
+
static BOOL moduleInitalized = NO;
|
|
33
|
+
static BOOL alwaysForegroundLastWindow = YES;
|
|
34
|
+
|
|
35
|
+
static void postNotificationWithURL(NSString *url, id sender)
|
|
36
|
+
{
|
|
37
|
+
NSDictionary<NSString *, id> *payload = @{@"url": url};
|
|
38
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
|
|
39
|
+
object:sender
|
|
40
|
+
userInfo:payload];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#endif // macOS]
|
|
44
|
+
|
|
25
45
|
@interface RCTLinkingManager () <NativeLinkingManagerSpec>
|
|
26
46
|
@end
|
|
27
47
|
|
|
@@ -34,6 +54,8 @@ RCT_EXPORT_MODULE()
|
|
|
34
54
|
return dispatch_get_main_queue();
|
|
35
55
|
}
|
|
36
56
|
|
|
57
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
58
|
+
|
|
37
59
|
- (void)startObserving
|
|
38
60
|
{
|
|
39
61
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
@@ -47,11 +69,33 @@ RCT_EXPORT_MODULE()
|
|
|
47
69
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
48
70
|
}
|
|
49
71
|
|
|
72
|
+
#else // [macOS
|
|
73
|
+
|
|
74
|
+
- (void)startObserving
|
|
75
|
+
{
|
|
76
|
+
moduleInitalized = YES;
|
|
77
|
+
|
|
78
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
79
|
+
selector:@selector(handleOpenURLNotification:)
|
|
80
|
+
name:RCTOpenURLNotification
|
|
81
|
+
object:nil];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (void)stopObserving
|
|
85
|
+
{
|
|
86
|
+
moduleInitalized = NO;
|
|
87
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#endif // macOS]
|
|
91
|
+
|
|
50
92
|
- (NSArray<NSString *> *)supportedEvents
|
|
51
93
|
{
|
|
52
94
|
return @[ @"url" ];
|
|
53
95
|
}
|
|
54
96
|
|
|
97
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
98
|
+
|
|
55
99
|
+ (BOOL)application:(UIApplication *)app
|
|
56
100
|
openURL:(NSURL *)URL
|
|
57
101
|
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
|
|
@@ -87,6 +131,43 @@ RCT_EXPORT_MODULE()
|
|
|
87
131
|
[self sendEventWithName:@"url" body:notification.userInfo];
|
|
88
132
|
}
|
|
89
133
|
|
|
134
|
+
#else // [macOS
|
|
135
|
+
|
|
136
|
+
+ (void)setAlwaysForegroundLastWindow:(BOOL)alwaysForeground
|
|
137
|
+
{
|
|
138
|
+
alwaysForegroundLastWindow = alwaysForeground;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
+ (void)getUrlEventHandler:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
|
142
|
+
{
|
|
143
|
+
// extract url value from the event
|
|
144
|
+
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
|
145
|
+
|
|
146
|
+
// If the application was launched via URL, this handler will be called before
|
|
147
|
+
// the module is initialized by the bridge. Store the initial URL, because we are not listening to the notification yet.
|
|
148
|
+
if (!moduleInitalized && initialURL == nil) {
|
|
149
|
+
initialURL = url;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
postNotificationWithURL(url, self);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)handleOpenURLNotification:(NSNotification *)notification
|
|
156
|
+
{
|
|
157
|
+
// Activate app, because [NSApp mainWindow] returns nil when the app is hidden and another app is maximized
|
|
158
|
+
[NSApp activateIgnoringOtherApps:YES];
|
|
159
|
+
// foreground top level window
|
|
160
|
+
if (alwaysForegroundLastWindow) {
|
|
161
|
+
NSWindow *lastWindow = [[NSApp windows] lastObject];
|
|
162
|
+
[lastWindow makeKeyAndOrderFront:nil];
|
|
163
|
+
}
|
|
164
|
+
[self sendEventWithName:@"url" body:notification.userInfo];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#endif // macOS]
|
|
168
|
+
|
|
169
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
170
|
+
|
|
90
171
|
RCT_EXPORT_METHOD(openURL
|
|
91
172
|
: (NSURL *)URL resolve
|
|
92
173
|
: (RCTPromiseResolveBlock)resolve reject
|
|
@@ -184,6 +265,44 @@ RCT_EXPORT_METHOD(openSettings : (RCTPromiseResolveBlock)resolve reject : (__unu
|
|
|
184
265
|
}];
|
|
185
266
|
}
|
|
186
267
|
|
|
268
|
+
#else // [macOS
|
|
269
|
+
|
|
270
|
+
RCT_EXPORT_METHOD(openURL:(NSURL *)URL
|
|
271
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
272
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
273
|
+
{
|
|
274
|
+
BOOL result = [[NSWorkspace sharedWorkspace] openURL:URL];
|
|
275
|
+
if (result) {
|
|
276
|
+
resolve(@YES);
|
|
277
|
+
} else {
|
|
278
|
+
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
|
|
283
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
284
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
285
|
+
{
|
|
286
|
+
resolve(@YES);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
|
|
290
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
291
|
+
{
|
|
292
|
+
resolve(RCTNullIfNil(initialURL));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
RCT_EXPORT_METHOD(openSettings:(RCTPromiseResolveBlock)resolve
|
|
296
|
+
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
297
|
+
{
|
|
298
|
+
// macOS doesn't have a direct equivalent of UIApplicationOpenSettingsURLString
|
|
299
|
+
// Open System Preferences instead
|
|
300
|
+
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:"]];
|
|
301
|
+
resolve(nil);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
#endif // macOS]
|
|
305
|
+
|
|
187
306
|
RCT_EXPORT_METHOD(sendIntent
|
|
188
307
|
: (NSString *)action extras
|
|
189
308
|
: (NSArray *_Nullable)extras resolve
|
|
@@ -32,10 +32,6 @@ Pod::Spec.new do |s|
|
|
|
32
32
|
s.compiler_flags = '-Wno-nullability-completeness'
|
|
33
33
|
s.source = source
|
|
34
34
|
s.source_files = podspec_sources("*.{m,mm}", "")
|
|
35
|
-
# [macOS
|
|
36
|
-
s.osx.exclude_files = "RCTLinkingManager.mm"
|
|
37
|
-
s.osx.source_files = "macos/RCTLinkingManager.mm"
|
|
38
|
-
# macOS]
|
|
39
35
|
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
|
|
40
36
|
s.header_dir = "RCTLinking"
|
|
41
37
|
s.pod_target_xcconfig = {
|
package/React/Base/RCTRootView.m
CHANGED
|
@@ -206,6 +206,13 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
|
|
|
206
206
|
#endif // macOS]
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
#if TARGET_OS_OSX // [macOS
|
|
210
|
+
- (void)viewDidEndLiveResize {
|
|
211
|
+
[super viewDidEndLiveResize];
|
|
212
|
+
[self setNeedsLayout];
|
|
213
|
+
}
|
|
214
|
+
#endif // macOS]
|
|
215
|
+
|
|
209
216
|
- (void)setLoadingView:(RCTUIView *)loadingView // [macOS]
|
|
210
217
|
{
|
|
211
218
|
_loadingView = loadingView;
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -64,9 +64,9 @@ UIKIT_STATIC_INLINE void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath
|
|
|
64
64
|
#define RCTUIImage UIImage
|
|
65
65
|
#define RCTUIPanGestureRecognizer UIPanGestureRecognizer
|
|
66
66
|
|
|
67
|
-
UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
|
|
67
|
+
UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, RCTPlatformView *fromView, __unused UIEvent *__nullable event)
|
|
68
68
|
{
|
|
69
|
-
return [view hitTest:point withEvent:event];
|
|
69
|
+
return [view hitTest:[view convertPoint:point fromView:fromView] withEvent:event];
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
|
|
@@ -98,6 +98,7 @@ UIKIT_STATIC_INLINE CGRect CGRectValue(NSValue *value)
|
|
|
98
98
|
// semantically equivalent types
|
|
99
99
|
//
|
|
100
100
|
|
|
101
|
+
#define RCTPlatformColor UIColor
|
|
101
102
|
#define RCTUIColor UIColor
|
|
102
103
|
|
|
103
104
|
// [macOS RCTUIAccessibilityTraits - typedef to UIAccessibilityTraits on iOS
|
|
@@ -376,8 +377,15 @@ NS_INLINE NSAccessibilityRole RCTAccessibilityRoleFromTraits(RCTUIAccessibilityT
|
|
|
376
377
|
// macOS]
|
|
377
378
|
|
|
378
379
|
// UIColor.h/NSColor.h
|
|
380
|
+
#define RCTPlatformColor NSColor
|
|
379
381
|
#define RCTUIColor NSColor
|
|
380
382
|
|
|
383
|
+
@interface NSColor (RCTAppearanceResolving)
|
|
384
|
+
/// Resolve a dynamic/semantic NSColor for a specific appearance, analogous to
|
|
385
|
+
/// UIColor's -resolvedColorWithTraitCollection: on iOS.
|
|
386
|
+
- (NSColor *)resolvedColorWithAppearance:(NSAppearance *)appearance;
|
|
387
|
+
@end
|
|
388
|
+
|
|
381
389
|
// UIFont.h/NSFont.h
|
|
382
390
|
// Both NSFont and UIFont are toll-free bridged to CTFontRef so we'll assume they're semantically equivalent
|
|
383
391
|
@compatibility_alias UIFont NSFont;
|
|
@@ -514,6 +522,7 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
|
|
|
514
522
|
|
|
515
523
|
@property (nonatomic, copy) NSColor *backgroundColor;
|
|
516
524
|
@property (nonatomic) CGAffineTransform transform;
|
|
525
|
+
@property (nonatomic) CATransform3D transform3D;
|
|
517
526
|
|
|
518
527
|
/**
|
|
519
528
|
* Specifies whether the view should receive the mouse down event when the
|
|
@@ -533,12 +542,10 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
|
|
|
533
542
|
*/
|
|
534
543
|
@property (nonatomic, assign) BOOL enableFocusRing;
|
|
535
544
|
|
|
536
|
-
// [macOS
|
|
537
545
|
/**
|
|
538
546
|
* iOS compatibility shim. On macOS, this forwards to accessibilityChildren.
|
|
539
547
|
*/
|
|
540
548
|
@property (nonatomic, copy) NSArray *accessibilityElements;
|
|
541
|
-
// macOS]
|
|
542
549
|
|
|
543
550
|
@end
|
|
544
551
|
|
|
@@ -585,11 +592,15 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
|
|
|
585
592
|
@end
|
|
586
593
|
|
|
587
594
|
|
|
588
|
-
|
|
595
|
+
// Use CALayer coordinate conversion which correctly accounts for layer.transform.
|
|
596
|
+
// NSView's convertPoint:fromView: does not account for layer transforms on macOS.
|
|
597
|
+
// IMPORTANT -- NSView's hitTest: expects a point in the superview's coordinate space,
|
|
598
|
+
// so we convert from fromView → superview using CALayer, which handles layer transforms correctly.
|
|
599
|
+
// This allows hit testing to work correctly between nested RCTUIViews and plain NSViews.
|
|
600
|
+
NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, RCTPlatformView *fromView, __unused UIEvent *__nullable event)
|
|
589
601
|
{
|
|
590
|
-
// [macOS IMPORTANT -- point is in local coordinate space, but OSX expects super coordinate space for hitTest:
|
|
591
602
|
NSView *superview = [view superview];
|
|
592
|
-
NSPoint pointInSuperview = superview != nil ? [
|
|
603
|
+
NSPoint pointInSuperview = superview != nil ? [superview.layer convertPoint:point fromLayer:fromView.layer] : point;
|
|
593
604
|
return [view hitTest:pointInSuperview];
|
|
594
605
|
}
|
|
595
606
|
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -144,6 +144,15 @@ RCT_NOT_IMPLEMENTED(-(nullable instancetype)initWithCoder : (NSCoder *)coder)
|
|
|
144
144
|
_autoHideDisabled = disabled;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
#pragma mark - NSView
|
|
148
|
+
|
|
149
|
+
#if TARGET_OS_OSX // [macOS
|
|
150
|
+
- (void)viewDidEndLiveResize {
|
|
151
|
+
[super viewDidEndLiveResize];
|
|
152
|
+
[self setNeedsLayout];
|
|
153
|
+
}
|
|
154
|
+
#endif // macOS]
|
|
155
|
+
|
|
147
156
|
#pragma mark - isActivityIndicatorViewVisible
|
|
148
157
|
|
|
149
158
|
- (void)setIsActivityIndicatorViewVisible:(BOOL)visible
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#if TARGET_OS_OSX
|
|
11
11
|
|
|
12
|
+
#import <QuartzCore/QuartzCore.h>
|
|
12
13
|
#import <React/RCTUIKit.h>
|
|
13
14
|
|
|
14
15
|
#import <React/RCTAssert.h>
|
|
@@ -165,6 +166,8 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath)
|
|
|
165
166
|
BOOL _userInteractionEnabled;
|
|
166
167
|
BOOL _mouseDownCanMoveWindow;
|
|
167
168
|
BOOL _respondsToDisplayLayer;
|
|
169
|
+
CATransform3D _transform3D;
|
|
170
|
+
BOOL _hasCustomTransform3D;
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
+ (NSSet<NSString *> *)keyPathsForValuesAffectingValueForKey:(NSString *)key
|
|
@@ -195,6 +198,8 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
195
198
|
self->_enableFocusRing = YES;
|
|
196
199
|
self->_mouseDownCanMoveWindow = YES;
|
|
197
200
|
self->_respondsToDisplayLayer = [self respondsToSelector:@selector(displayLayer:)];
|
|
201
|
+
self->_transform3D = CATransform3DIdentity;
|
|
202
|
+
self->_hasCustomTransform3D = NO;
|
|
198
203
|
}
|
|
199
204
|
return self;
|
|
200
205
|
}
|
|
@@ -271,20 +276,46 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
271
276
|
|
|
272
277
|
- (void)setTransform:(CGAffineTransform)transform
|
|
273
278
|
{
|
|
274
|
-
self.
|
|
279
|
+
self.transform3D = CATransform3DMakeAffineTransform(transform);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
- (CATransform3D)transform3D
|
|
283
|
+
{
|
|
284
|
+
return _transform3D;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
- (void)setTransform3D:(CATransform3D)transform3D
|
|
288
|
+
{
|
|
289
|
+
// On macOS, layer.anchorPoint defaults to {0, 0} instead of {0.5, 0.5} on iOS.
|
|
290
|
+
// Compensate so transforms are applied from the view's center as expected.
|
|
291
|
+
CGPoint anchorPoint = self.layer.anchorPoint;
|
|
292
|
+
if (CGPointEqualToPoint(anchorPoint, CGPointZero) && !CATransform3DEqualToTransform(transform3D, CATransform3DIdentity)) {
|
|
293
|
+
CATransform3D originAdjust = CATransform3DTranslate(CATransform3DIdentity, self.frame.size.width / 2, self.frame.size.height / 2, 0);
|
|
294
|
+
transform3D = CATransform3DConcat(CATransform3DConcat(CATransform3DInvert(originAdjust), transform3D), originAdjust);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
_transform3D = transform3D;
|
|
298
|
+
_hasCustomTransform3D = !CATransform3DEqualToTransform(transform3D, CATransform3DIdentity);
|
|
299
|
+
self.layer.transform = transform3D;
|
|
275
300
|
}
|
|
276
301
|
|
|
277
302
|
- (NSView *)hitTest:(NSPoint)point
|
|
278
303
|
{
|
|
279
|
-
//
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
304
|
+
// NSView's hitTest: receives a point in superview coordinates. Convert to local
|
|
305
|
+
// coordinates using CALayer, which correctly accounts for layer.transform.
|
|
306
|
+
// NSView's convertPoint:fromView: does NOT account for layer transforms.
|
|
307
|
+
CGPoint localPoint;
|
|
308
|
+
if (self.layer.superlayer) {
|
|
309
|
+
localPoint = [self.layer convertPoint:point fromLayer:self.layer.superlayer];
|
|
310
|
+
} else {
|
|
311
|
+
localPoint = point;
|
|
312
|
+
}
|
|
313
|
+
return [self hitTest:localPoint withEvent:nil];
|
|
283
314
|
}
|
|
284
315
|
|
|
285
316
|
- (BOOL)wantsUpdateLayer
|
|
286
317
|
{
|
|
287
|
-
return
|
|
318
|
+
return _respondsToDisplayLayer || _hasCustomTransform3D;
|
|
288
319
|
}
|
|
289
320
|
|
|
290
321
|
- (void)updateLayer
|
|
@@ -297,8 +328,13 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
297
328
|
[layer setBackgroundColor:[_backgroundColor CGColor]];
|
|
298
329
|
}
|
|
299
330
|
|
|
300
|
-
//
|
|
301
|
-
//
|
|
331
|
+
// On macOS, AppKit's layer-backed view system resets layer.transform to identity
|
|
332
|
+
// during its layout/display cycle because NSView has no built-in transform property
|
|
333
|
+
// (unlike UIView on iOS). We must re-apply the stored transform after each cycle.
|
|
334
|
+
if (_hasCustomTransform3D && !CATransform3DEqualToTransform(layer.transform, _transform3D)) {
|
|
335
|
+
layer.transform = _transform3D;
|
|
336
|
+
}
|
|
337
|
+
|
|
302
338
|
if (_respondsToDisplayLayer) {
|
|
303
339
|
[(id<CALayerDelegate>)self displayLayer:layer];
|
|
304
340
|
}
|
|
@@ -905,4 +941,25 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
905
941
|
|
|
906
942
|
@end
|
|
907
943
|
|
|
944
|
+
// NSColor (RCTAppearanceResolving)
|
|
945
|
+
|
|
946
|
+
@implementation NSColor (RCTAppearanceResolving)
|
|
947
|
+
|
|
948
|
+
- (NSColor *)resolvedColorWithAppearance:(NSAppearance *)appearance
|
|
949
|
+
{
|
|
950
|
+
__block NSColor *resolved = self;
|
|
951
|
+
[appearance performAsCurrentDrawingAppearance:^{
|
|
952
|
+
CGColorRef cgColor = self.CGColor;
|
|
953
|
+
if (cgColor) {
|
|
954
|
+
NSColor *fromCG = [NSColor colorWithCGColor:cgColor];
|
|
955
|
+
if (fromCG) {
|
|
956
|
+
resolved = fromCG;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}];
|
|
960
|
+
return resolved;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
@end
|
|
964
|
+
|
|
908
965
|
#endif
|
|
@@ -52,6 +52,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
52
52
|
@property (nonatomic, assign) BOOL snapToEnd;
|
|
53
53
|
@property (nonatomic, copy) NSArray<NSNumber *> *snapToOffsets;
|
|
54
54
|
|
|
55
|
+
#if TARGET_OS_OSX // [macOS
|
|
56
|
+
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
|
|
57
|
+
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated;
|
|
58
|
+
- (void)flashScrollIndicators;
|
|
59
|
+
#endif // macOS]
|
|
60
|
+
|
|
55
61
|
/*
|
|
56
62
|
* Makes `setContentOffset:` method no-op when given `block` is executed.
|
|
57
63
|
* The block is being executed synchronously.
|
|
@@ -41,7 +41,16 @@
|
|
|
41
41
|
// because this attribute affects a position of vertical scrollbar; we don't want this
|
|
42
42
|
// scrollbar flip because we also flip it with whole `UIScrollView` flip.
|
|
43
43
|
self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
|
|
44
|
-
#
|
|
44
|
+
#else // [macOS
|
|
45
|
+
// Similar to iOS's contentInsetAdjustmentBehavior fix
|
|
46
|
+
// For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root,
|
|
47
|
+
// NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar.
|
|
48
|
+
// However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues
|
|
49
|
+
self.automaticallyAdjustsContentInsets = NO;
|
|
50
|
+
self.hasHorizontalScroller = YES;
|
|
51
|
+
self.hasVerticalScroller = YES;
|
|
52
|
+
self.autohidesScrollers = YES;
|
|
53
|
+
#endif // macOS]
|
|
45
54
|
|
|
46
55
|
__weak __typeof(self) weakSelf = self;
|
|
47
56
|
_delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) {
|
|
@@ -98,16 +107,83 @@
|
|
|
98
107
|
if (_isSetContentOffsetDisabled) {
|
|
99
108
|
return;
|
|
100
109
|
}
|
|
110
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
101
111
|
super.contentOffset = CGPointMake(
|
|
102
112
|
RCTSanitizeNaNValue(contentOffset.x, @"scrollView.contentOffset.x"),
|
|
103
113
|
RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y"));
|
|
114
|
+
#else // [macOS
|
|
115
|
+
if (!NSEqualPoints(contentOffset, self.documentVisibleRect.origin)) {
|
|
116
|
+
[self.contentView scrollToPoint:contentOffset];
|
|
117
|
+
[self reflectScrolledClipView:self.contentView];
|
|
118
|
+
}
|
|
119
|
+
#endif // macOS]
|
|
104
120
|
}
|
|
105
121
|
|
|
106
122
|
- (void)setFrame:(CGRect)frame
|
|
107
123
|
{
|
|
124
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
108
125
|
[super setFrame:frame];
|
|
109
126
|
[self centerContentIfNeeded];
|
|
127
|
+
#else // [macOS
|
|
128
|
+
// Preserving and revalidating `contentOffset`.
|
|
129
|
+
CGPoint originalOffset = self.contentOffset;
|
|
130
|
+
|
|
131
|
+
[super setFrame:frame];
|
|
132
|
+
|
|
133
|
+
UIEdgeInsets contentInset = self.contentInset;
|
|
134
|
+
CGSize contentSize = self.contentSize;
|
|
135
|
+
|
|
136
|
+
// If contentSize has not been measured yet we can't check bounds.
|
|
137
|
+
if (CGSizeEqualToSize(contentSize, CGSizeZero)) {
|
|
138
|
+
self.contentOffset = originalOffset;
|
|
139
|
+
} else {
|
|
140
|
+
CGSize boundsSize = self.bounds.size;
|
|
141
|
+
CGFloat xMaxOffset = contentSize.width - boundsSize.width + contentInset.right;
|
|
142
|
+
CGFloat yMaxOffset = contentSize.height - boundsSize.height + contentInset.bottom;
|
|
143
|
+
// Make sure offset doesn't exceed bounds. This can happen on screen rotation.
|
|
144
|
+
if ((originalOffset.x >= -contentInset.left) && (originalOffset.x <= xMaxOffset) &&
|
|
145
|
+
(originalOffset.y >= -contentInset.top) && (originalOffset.y <= yMaxOffset)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
self.contentOffset = CGPointMake(
|
|
149
|
+
MAX(-contentInset.left, MIN(xMaxOffset, originalOffset.x)),
|
|
150
|
+
MAX(-contentInset.top, MIN(yMaxOffset, originalOffset.y)));
|
|
151
|
+
}
|
|
152
|
+
#endif // macOS]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#if TARGET_OS_OSX // [macOS
|
|
156
|
+
- (NSSize)contentSize
|
|
157
|
+
{
|
|
158
|
+
if (!self.documentView) {
|
|
159
|
+
return [super contentSize];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return self.documentView.frame.size;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
|
|
166
|
+
{
|
|
167
|
+
if (animated) {
|
|
168
|
+
[NSAnimationContext beginGrouping];
|
|
169
|
+
[[NSAnimationContext currentContext] setDuration:0.3];
|
|
170
|
+
[[self.contentView animator] setBoundsOrigin:contentOffset];
|
|
171
|
+
[NSAnimationContext endGrouping];
|
|
172
|
+
} else {
|
|
173
|
+
self.contentOffset = contentOffset;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated
|
|
178
|
+
{
|
|
179
|
+
[self magnifyToFitRect:rect];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
- (void)flashScrollIndicators
|
|
183
|
+
{
|
|
184
|
+
[self flashScrollers];
|
|
110
185
|
}
|
|
186
|
+
#endif // macOS]
|
|
111
187
|
|
|
112
188
|
- (void)didAddSubview:(RCTPlatformView *)subview // [macOS]
|
|
113
189
|
{
|
|
@@ -54,6 +54,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
54
54
|
@property (nonatomic, strong, readonly)
|
|
55
55
|
RCTGenericDelegateSplitter<id<RCTUIScrollViewDelegate>> *scrollViewDelegateSplitter;
|
|
56
56
|
|
|
57
|
+
#if TARGET_OS_OSX // [macOS
|
|
58
|
+
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
|
59
|
+
#endif // macOS]
|
|
60
|
+
|
|
57
61
|
@end
|
|
58
62
|
|
|
59
63
|
/*
|