react-native-macos 0.77.5 → 0.77.7
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/Network/RCTDataRequestHandler.mm +17 -3
- package/Libraries/Network/RCTFileRequestHandler.mm +17 -3
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/RCTDevLoadingView.mm +1 -1
- package/React/CoreModules/RCTLogBoxView.mm +4 -1
- package/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +85 -19
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +18 -4
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +1 -4
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +22 -3
- package/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +1 -1
- package/React/Fabric/Surface/RCTFabricSurface.mm +1 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +13 -8
- package/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt +3 -16
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.kt +13 -0
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +0 -3
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/BorderRadiusStyle.kt +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +39 -0
- package/ReactCommon/React-FabricComponents.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/components/modal/CMakeLists.txt +4 -1
- package/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h +3 -2
- package/ReactCommon/react/renderer/components/modal/ModalHostViewState.h +4 -12
- package/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.h +2 -2
- package/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.mm +1 -1
- package/ReactCommon/react/renderer/components/modal/platform/android/JReactModalHostView.h +38 -0
- package/ReactCommon/react/renderer/components/modal/platform/android/ModalHostViewUtils.cpp +18 -0
- package/ReactCommon/react/renderer/components/modal/platform/cxx/ModalHostViewUtils.cpp +17 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollEvent.cpp +33 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollEvent.h +17 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp +3 -2
- package/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h +2 -1
- package/ReactCommon/react/runtime/TimerManager.cpp +6 -4
- package/ReactCommon/react/runtime/TimerManager.h +3 -1
- package/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp +9 -5
- package/package.json +11 -11
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#import <React/RCTDataRequestHandler.h>
|
|
9
9
|
#import <ReactCommon/RCTTurboModule.h>
|
|
10
10
|
|
|
11
|
+
#import <mutex>
|
|
12
|
+
|
|
11
13
|
#import "RCTNetworkPlugins.h"
|
|
12
14
|
|
|
13
15
|
@interface RCTDataRequestHandler () <RCTTurboModule>
|
|
@@ -15,14 +17,22 @@
|
|
|
15
17
|
|
|
16
18
|
@implementation RCTDataRequestHandler {
|
|
17
19
|
NSOperationQueue *_queue;
|
|
20
|
+
std::mutex _operationHandlerMutexLock;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
RCT_EXPORT_MODULE()
|
|
21
24
|
|
|
22
25
|
- (void)invalidate
|
|
23
26
|
{
|
|
24
|
-
|
|
25
|
-
_queue
|
|
27
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
28
|
+
if (_queue) {
|
|
29
|
+
for (NSOperation *operation in _queue.operations) {
|
|
30
|
+
if (!operation.isCancelled && !operation.isFinished) {
|
|
31
|
+
[operation cancel];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_queue = nil;
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
- (BOOL)canHandleRequest:(NSURLRequest *)request
|
|
@@ -32,6 +42,7 @@ RCT_EXPORT_MODULE()
|
|
|
32
42
|
|
|
33
43
|
- (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequestDelegate>)delegate
|
|
34
44
|
{
|
|
45
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
35
46
|
// Lazy setup
|
|
36
47
|
if (!_queue) {
|
|
37
48
|
_queue = [NSOperationQueue new];
|
|
@@ -73,7 +84,10 @@ RCT_EXPORT_MODULE()
|
|
|
73
84
|
|
|
74
85
|
- (void)cancelRequest:(NSOperation *)op
|
|
75
86
|
{
|
|
76
|
-
|
|
87
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
88
|
+
if (!op.isCancelled && !op.isFinished) {
|
|
89
|
+
[op cancel];
|
|
90
|
+
}
|
|
77
91
|
}
|
|
78
92
|
|
|
79
93
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
#import <React/RCTFileRequestHandler.h>
|
|
9
9
|
|
|
10
|
+
#import <mutex>
|
|
11
|
+
|
|
10
12
|
#if !TARGET_OS_OSX // [macOS]
|
|
11
13
|
#import <MobileCoreServices/MobileCoreServices.h>
|
|
12
14
|
#else // [macOS
|
|
@@ -23,14 +25,22 @@
|
|
|
23
25
|
|
|
24
26
|
@implementation RCTFileRequestHandler {
|
|
25
27
|
NSOperationQueue *_fileQueue;
|
|
28
|
+
std::mutex _operationHandlerMutexLock;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
RCT_EXPORT_MODULE()
|
|
29
32
|
|
|
30
33
|
- (void)invalidate
|
|
31
34
|
{
|
|
32
|
-
|
|
33
|
-
_fileQueue
|
|
35
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
36
|
+
if (_fileQueue) {
|
|
37
|
+
for (NSOperation *operation in _fileQueue.operations) {
|
|
38
|
+
if (!operation.isCancelled && !operation.isFinished) {
|
|
39
|
+
[operation cancel];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_fileQueue = nil;
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
- (BOOL)canHandleRequest:(NSURLRequest *)request
|
|
@@ -40,6 +50,7 @@ RCT_EXPORT_MODULE()
|
|
|
40
50
|
|
|
41
51
|
- (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequestDelegate>)delegate
|
|
42
52
|
{
|
|
53
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
43
54
|
// Lazy setup
|
|
44
55
|
if (!_fileQueue) {
|
|
45
56
|
_fileQueue = [NSOperationQueue new];
|
|
@@ -91,7 +102,10 @@ RCT_EXPORT_MODULE()
|
|
|
91
102
|
|
|
92
103
|
- (void)cancelRequest:(NSOperation *)op
|
|
93
104
|
{
|
|
94
|
-
|
|
105
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
106
|
+
if (!op.isCancelled && !op.isFinished) {
|
|
107
|
+
[op cancel];
|
|
108
|
+
}
|
|
95
109
|
}
|
|
96
110
|
|
|
97
111
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -130,7 +130,7 @@ RCT_EXPORT_MODULE()
|
|
|
130
130
|
self->_window.rootViewController = [UIViewController new];
|
|
131
131
|
#else // [macOS
|
|
132
132
|
self->_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 375, 20)
|
|
133
|
-
styleMask:NSWindowStyleMaskBorderless
|
|
133
|
+
styleMask:NSWindowStyleMaskBorderless | NSWindowStyleMaskFullSizeContentView
|
|
134
134
|
backing:NSBackingStoreBuffered
|
|
135
135
|
defer:YES];
|
|
136
136
|
[self->_window setIdentifier:sRCTDevLoadingViewWindowIdentifier];
|
|
@@ -79,7 +79,10 @@
|
|
|
79
79
|
#if !TARGET_OS_OSX // [macOS]
|
|
80
80
|
self = [super initWithWindowScene:window.windowScene];
|
|
81
81
|
#else // [macOS
|
|
82
|
-
self = [super initWithContentRect:NSMakeRect(0, 0, 600, 800)
|
|
82
|
+
self = [super initWithContentRect:NSMakeRect(0, 0, 600, 800)
|
|
83
|
+
styleMask:NSWindowStyleMaskBorderless | NSWindowStyleMaskFullSizeContentView
|
|
84
|
+
backing:NSBackingStoreBuffered
|
|
85
|
+
defer:YES];
|
|
83
86
|
_window = window;
|
|
84
87
|
#endif // macOS]
|
|
85
88
|
|
|
@@ -16,19 +16,17 @@
|
|
|
16
16
|
@end
|
|
17
17
|
|
|
18
18
|
@interface RCTPausedInDebuggerOverlayController ()
|
|
19
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
20
19
|
|
|
21
|
-
@property (nonatomic, strong)
|
|
20
|
+
@property (nonatomic, strong) RCTPlatformWindow *alertWindow; // [macOS]
|
|
22
21
|
|
|
23
|
-
#endif // [macOS];
|
|
24
22
|
@end
|
|
25
23
|
|
|
26
24
|
@implementation RCTPausedInDebuggerViewController
|
|
27
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
28
25
|
- (void)viewDidLoad
|
|
29
26
|
{
|
|
30
27
|
[super viewDidLoad];
|
|
31
28
|
|
|
29
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
32
30
|
UIView *dimmingView = [[UIView alloc] init];
|
|
33
31
|
dimmingView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
34
32
|
dimmingView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
|
|
@@ -39,15 +37,18 @@
|
|
|
39
37
|
[dimmingView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
|
|
40
38
|
[dimmingView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor]
|
|
41
39
|
]];
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
#endif // [macOS]
|
|
41
|
+
|
|
42
|
+
RCTUILabel *messageLabel = [[RCTUILabel alloc] init]; // [macOS]
|
|
44
43
|
messageLabel.text = self.message;
|
|
45
44
|
messageLabel.textAlignment = NSTextAlignmentCenter;
|
|
45
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
46
46
|
messageLabel.numberOfLines = 0;
|
|
47
|
+
#endif // [macOS]
|
|
47
48
|
messageLabel.font = [UIFont boldSystemFontOfSize:16];
|
|
48
|
-
messageLabel.textColor = [
|
|
49
|
+
messageLabel.textColor = [RCTUIColor blackColor]; // [macOS]
|
|
49
50
|
messageLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
|
50
|
-
|
|
51
|
+
RCTUIView *messageContainer = [[RCTUIView alloc] init]; // [macOS]
|
|
51
52
|
[messageContainer addSubview:messageLabel];
|
|
52
53
|
[NSLayoutConstraint activateConstraints:@[
|
|
53
54
|
[messageLabel.topAnchor constraintEqualToAnchor:messageContainer.topAnchor constant:-1],
|
|
@@ -56,20 +57,29 @@
|
|
|
56
57
|
[messageLabel.trailingAnchor constraintEqualToAnchor:messageContainer.trailingAnchor],
|
|
57
58
|
]];
|
|
58
59
|
|
|
60
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
59
61
|
UIButton *resumeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
60
|
-
|
|
62
|
+
UIImage *image = [UIImage systemImageNamed:@"forward.frame.fill"];
|
|
63
|
+
[resumeButton setImage:image forState:UIControlStateNormal];
|
|
64
|
+
[resumeButton setImage:image forState:UIControlStateDisabled];
|
|
61
65
|
resumeButton.tintColor = [UIColor colorWithRed:0.37 green:0.37 blue:0.37 alpha:1];
|
|
62
66
|
|
|
63
|
-
resumeButton.configurationUpdateHandler = ^(UIButton *button) {
|
|
64
|
-
button.imageView.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
67
|
resumeButton.enabled = NO;
|
|
68
|
+
#else // [macOS
|
|
69
|
+
NSButton *resumeButton = [[NSButton alloc] init];
|
|
70
|
+
[resumeButton setImage:[NSImage imageWithSystemSymbolName:@"forward.frame.fill" accessibilityDescription:@"Resume"]];
|
|
71
|
+
resumeButton.bordered = NO;
|
|
72
|
+
resumeButton.target = self;
|
|
73
|
+
resumeButton.action = @selector(handleResume:);
|
|
74
|
+
resumeButton.contentTintColor = [NSColor colorWithRed:0.37 green:0.37 blue:0.37 alpha:1];
|
|
75
|
+
#endif // macOS]
|
|
76
|
+
|
|
68
77
|
[NSLayoutConstraint activateConstraints:@[
|
|
69
78
|
[resumeButton.widthAnchor constraintEqualToConstant:48],
|
|
70
79
|
[resumeButton.heightAnchor constraintEqualToConstant:46],
|
|
71
80
|
]];
|
|
72
81
|
|
|
82
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
73
83
|
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[ messageContainer, resumeButton ]];
|
|
74
84
|
stackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.757 alpha:1];
|
|
75
85
|
stackView.layer.cornerRadius = 12;
|
|
@@ -84,41 +94,75 @@
|
|
|
84
94
|
action:@selector(handleResume:)];
|
|
85
95
|
[stackView addGestureRecognizer:gestureRecognizer];
|
|
86
96
|
stackView.userInteractionEnabled = YES;
|
|
97
|
+
#else // [macOS
|
|
98
|
+
NSStackView *stackView = [NSStackView stackViewWithViews:@[ messageContainer, resumeButton ]];
|
|
99
|
+
stackView.wantsLayer = YES;
|
|
100
|
+
stackView.layer.backgroundColor = [NSColor colorWithRed:1 green:1 blue:0.757 alpha:1].CGColor;
|
|
101
|
+
stackView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
102
|
+
stackView.orientation = NSUserInterfaceLayoutOrientationHorizontal;
|
|
103
|
+
stackView.distribution = NSStackViewDistributionFill;
|
|
104
|
+
stackView.alignment = NSLayoutAttributeCenterY;
|
|
105
|
+
|
|
106
|
+
NSClickGestureRecognizer *gestureRecognizer = [[NSClickGestureRecognizer alloc] initWithTarget:self
|
|
107
|
+
action:@selector(handleResume:)];
|
|
108
|
+
[stackView addGestureRecognizer:gestureRecognizer];
|
|
109
|
+
#endif // macOS]
|
|
87
110
|
|
|
111
|
+
#if !TARGET_OS_OSX
|
|
88
112
|
[self.view addSubview:stackView];
|
|
89
113
|
|
|
90
114
|
[NSLayoutConstraint activateConstraints:@[
|
|
91
115
|
[stackView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor constant:12],
|
|
92
116
|
[stackView.centerXAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.centerXAnchor],
|
|
93
117
|
]];
|
|
118
|
+
#else
|
|
119
|
+
[self setView:stackView];
|
|
120
|
+
#endif
|
|
94
121
|
|
|
122
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
95
123
|
stackView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
|
|
124
|
+
#else // [macOS
|
|
125
|
+
stackView.userInterfaceLayoutDirection = NSUserInterfaceLayoutDirectionLeftToRight;
|
|
126
|
+
#endif // macOS]
|
|
96
127
|
}
|
|
97
128
|
|
|
129
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
98
130
|
- (void)handleResume:(UITapGestureRecognizer *)recognizer
|
|
99
131
|
{
|
|
100
132
|
self.onResume();
|
|
101
133
|
}
|
|
102
|
-
#
|
|
134
|
+
#else // [macOS
|
|
135
|
+
- (void)handleResume:(id)sender
|
|
136
|
+
{
|
|
137
|
+
self.onResume();
|
|
138
|
+
}
|
|
139
|
+
#endif // macOS]
|
|
103
140
|
@end
|
|
104
141
|
|
|
105
142
|
@implementation RCTPausedInDebuggerOverlayController
|
|
106
143
|
|
|
107
|
-
|
|
108
|
-
- (UIWindow *)alertWindow
|
|
144
|
+
- (RCTPlatformWindow *)alertWindow // [macOS]
|
|
109
145
|
{
|
|
110
146
|
if (_alertWindow == nil) {
|
|
147
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
111
148
|
_alertWindow = [[UIWindow alloc] initWithWindowScene:RCTKeyWindow().windowScene];
|
|
112
149
|
|
|
113
150
|
if (_alertWindow) {
|
|
114
151
|
_alertWindow.rootViewController = [UIViewController new];
|
|
115
152
|
_alertWindow.windowLevel = UIWindowLevelAlert + 1;
|
|
116
153
|
}
|
|
154
|
+
#else // [macOS]
|
|
155
|
+
_alertWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
|
|
156
|
+
styleMask:NSWindowStyleMaskBorderless | NSWindowStyleMaskFullSizeContentView
|
|
157
|
+
backing:NSBackingStoreBuffered
|
|
158
|
+
defer:YES];
|
|
159
|
+
_alertWindow.backgroundColor = [NSColor clearColor];
|
|
160
|
+
_alertWindow.opaque = NO;
|
|
161
|
+
#endif // macOS]
|
|
117
162
|
}
|
|
118
163
|
|
|
119
164
|
return _alertWindow;
|
|
120
165
|
}
|
|
121
|
-
#endif // [macOS]
|
|
122
166
|
|
|
123
167
|
- (void)showWithMessage:(NSString *)message onResume:(void (^)(void))onResume
|
|
124
168
|
{
|
|
@@ -129,9 +173,21 @@
|
|
|
129
173
|
view.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
130
174
|
view.message = message;
|
|
131
175
|
view.onResume = onResume;
|
|
176
|
+
|
|
132
177
|
[self.alertWindow makeKeyAndVisible];
|
|
133
178
|
[self.alertWindow.rootViewController presentViewController:view animated:NO completion:nil];
|
|
134
|
-
#
|
|
179
|
+
#else // [macOS]
|
|
180
|
+
view.message = message;
|
|
181
|
+
view.onResume = onResume;
|
|
182
|
+
|
|
183
|
+
self.alertWindow.contentViewController = view;
|
|
184
|
+
NSWindow *parentWindow = RCTKeyWindow();
|
|
185
|
+
if (![[parentWindow sheets] doesContain:self->_alertWindow]) {
|
|
186
|
+
[parentWindow beginSheet:self.alertWindow completionHandler:^(NSModalResponse returnCode) {
|
|
187
|
+
[self->_alertWindow orderOut:self];
|
|
188
|
+
}];
|
|
189
|
+
}
|
|
190
|
+
#endif // macOS]
|
|
135
191
|
}
|
|
136
192
|
|
|
137
193
|
- (void)hide
|
|
@@ -140,9 +196,19 @@
|
|
|
140
196
|
[_alertWindow setHidden:YES];
|
|
141
197
|
|
|
142
198
|
_alertWindow.windowScene = nil;
|
|
199
|
+
#else // [macOS]
|
|
200
|
+
NSWindow *parentWindow = RCTKeyWindow();
|
|
201
|
+
if (parentWindow) {
|
|
202
|
+
for (NSWindow *sheet in [parentWindow sheets]) {
|
|
203
|
+
if (sheet == _alertWindow) {
|
|
204
|
+
[parentWindow endSheet:sheet];
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
#endif // macOS]
|
|
143
210
|
|
|
144
211
|
_alertWindow = nil;
|
|
145
|
-
#endif // macOS]
|
|
146
212
|
}
|
|
147
213
|
|
|
148
214
|
@end
|
|
@@ -174,10 +174,24 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
|
|
|
174
174
|
|
|
175
175
|
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // [macOS]
|
|
176
176
|
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
if (_adapter && index == _adapter.paperView.reactSubviews.count) {
|
|
178
|
+
// This is a new child view that is being added to the end of the children array.
|
|
179
|
+
// After the children is added, we need to call didUpdateReactSubviews to make sure that it is rendered.
|
|
180
|
+
// Without this change, the new child will not be rendered right away because the didUpdateReactSubviews is not
|
|
181
|
+
// called and the `finalizeUpdate` is not invoked.
|
|
182
|
+
if ([childComponentView isKindOfClass:[RCTLegacyViewManagerInteropComponentView class]]) {
|
|
183
|
+
RCTPlatformView *target = ((RCTLegacyViewManagerInteropComponentView *)childComponentView).contentView; // [macOS]
|
|
184
|
+
[_adapter.paperView insertReactSubview:target atIndex:index];
|
|
185
|
+
} else {
|
|
186
|
+
[_adapter.paperView insertReactSubview:childComponentView atIndex:index];
|
|
187
|
+
}
|
|
188
|
+
[_adapter.paperView didUpdateReactSubviews];
|
|
189
|
+
} else {
|
|
190
|
+
[_viewsToBeMounted addObject:@{
|
|
191
|
+
kRCTLegacyInteropChildIndexKey : [NSNumber numberWithInteger:index],
|
|
192
|
+
kRCTLegacyInteropChildComponentKey : childComponentView
|
|
193
|
+
}];
|
|
194
|
+
}
|
|
181
195
|
}
|
|
182
196
|
|
|
183
197
|
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // [macOS]
|
|
@@ -106,7 +106,6 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
|
|
106
106
|
BOOL _shouldAnimatePresentation;
|
|
107
107
|
BOOL _shouldPresent;
|
|
108
108
|
BOOL _isPresented;
|
|
109
|
-
RCTPlatformView *_modalContentsSnapshot; // [macOS]
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
#if !TARGET_OS_OSX // [macOS]
|
|
@@ -144,7 +143,6 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
|
|
144
143
|
animated:(BOOL)animated
|
|
145
144
|
completion:(void (^)(void))completion
|
|
146
145
|
{
|
|
147
|
-
_modalContentsSnapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO];
|
|
148
146
|
[modalViewController dismissViewControllerAnimated:animated completion:completion];
|
|
149
147
|
}
|
|
150
148
|
|
|
@@ -170,8 +168,7 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
|
|
|
170
168
|
_isPresented = NO;
|
|
171
169
|
// To animate dismissal of view controller, snapshot of
|
|
172
170
|
// view hierarchy needs to be added to the UIViewController.
|
|
173
|
-
RCTPlatformView *snapshot =
|
|
174
|
-
|
|
171
|
+
RCTPlatformView *snapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO]; // [macOS]
|
|
175
172
|
if (_shouldPresent) {
|
|
176
173
|
[self.viewController.view addSubview:snapshot];
|
|
177
174
|
}
|
|
@@ -580,6 +580,17 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
580
580
|
return metrics;
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
+
- (ScrollViewEventEmitter::EndDragMetrics)_scrollViewMetricsWithVelocity:(CGPoint)velocity
|
|
584
|
+
andTargetContentOffset:(CGPoint)targetContentOffset
|
|
585
|
+
{
|
|
586
|
+
ScrollViewEventEmitter::EndDragMetrics metrics = [self _scrollViewMetrics];
|
|
587
|
+
metrics.targetContentOffset.x = targetContentOffset.x;
|
|
588
|
+
metrics.targetContentOffset.y = targetContentOffset.y;
|
|
589
|
+
metrics.velocity.x = velocity.x;
|
|
590
|
+
metrics.velocity.y = velocity.y;
|
|
591
|
+
return metrics;
|
|
592
|
+
}
|
|
593
|
+
|
|
583
594
|
- (void)_updateStateWithContentOffset
|
|
584
595
|
{
|
|
585
596
|
if (!_state) {
|
|
@@ -638,6 +649,14 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
638
649
|
targetContentOffset->y = scrollView.contentOffset.y + travel * _endDraggingSensitivityMultiplier;
|
|
639
650
|
}
|
|
640
651
|
}
|
|
652
|
+
|
|
653
|
+
if (!_eventEmitter) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
auto metrics = [self _scrollViewMetricsWithVelocity:velocity andTargetContentOffset:*targetContentOffset];
|
|
658
|
+
|
|
659
|
+
static_cast<const ScrollViewEventEmitter &>(*_eventEmitter).onScrollEndDrag(metrics);
|
|
641
660
|
}
|
|
642
661
|
|
|
643
662
|
- (BOOL)touchesShouldCancelInContentView:(__unused RCTPlatformView *)view // [macOS]
|
|
@@ -709,8 +728,6 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
709
728
|
return;
|
|
710
729
|
}
|
|
711
730
|
|
|
712
|
-
static_cast<const ScrollViewEventEmitter &>(*_eventEmitter).onScrollEndDrag([self _scrollViewMetrics]);
|
|
713
|
-
|
|
714
731
|
[self _updateStateWithContentOffset];
|
|
715
732
|
|
|
716
733
|
if (!decelerate) {
|
|
@@ -815,7 +832,9 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
|
|
815
832
|
return;
|
|
816
833
|
}
|
|
817
834
|
|
|
818
|
-
|
|
835
|
+
auto metrics = [self _scrollViewMetricsWithVelocity:{} andTargetContentOffset:{}];
|
|
836
|
+
static_cast<const ScrollViewEventEmitter &>(*_eventEmitter).onScrollEndDrag(metrics);
|
|
837
|
+
|
|
819
838
|
[self _updateStateWithContentOffset];
|
|
820
839
|
}
|
|
821
840
|
|
|
@@ -65,7 +65,7 @@ using namespace facebook::react;
|
|
|
65
65
|
const auto &newSwitchProps = static_cast<const SwitchProps &>(*props);
|
|
66
66
|
|
|
67
67
|
// `value`
|
|
68
|
-
if (oldSwitchProps.value != newSwitchProps.value) {
|
|
68
|
+
if (!_isInitialValueSet || oldSwitchProps.value != newSwitchProps.value) {
|
|
69
69
|
BOOL shouldAnimate = _isInitialValueSet == YES;
|
|
70
70
|
[_switchView setOn:newSwitchProps.value animated:shouldAnimate];
|
|
71
71
|
}
|
|
@@ -145,6 +145,7 @@ using namespace facebook::react;
|
|
|
145
145
|
|
|
146
146
|
if (!_view) {
|
|
147
147
|
_view = [[RCTSurfaceView alloc] initWithSurface:(RCTSurface *)self];
|
|
148
|
+
[self _updateLayoutContext];
|
|
148
149
|
_touchHandler = [RCTSurfaceTouchHandler new];
|
|
149
150
|
[_touchHandler attachToView:_view];
|
|
150
151
|
}
|
|
@@ -1409,14 +1409,14 @@ public class ReactInstanceManager {
|
|
|
1409
1409
|
new RuntimeException(
|
|
1410
1410
|
"detachRootViewFromInstance called with ReactRootView with invalid id"));
|
|
1411
1411
|
}
|
|
1412
|
-
|
|
1413
|
-
clearReactRoot(reactRoot);
|
|
1414
1412
|
} else {
|
|
1415
1413
|
reactContext
|
|
1416
1414
|
.getCatalystInstance()
|
|
1417
1415
|
.getJSModule(AppRegistry.class)
|
|
1418
1416
|
.unmountApplicationComponentAtRootTag(reactRoot.getRootViewTag());
|
|
1419
1417
|
}
|
|
1418
|
+
|
|
1419
|
+
clearReactRoot(reactRoot);
|
|
1420
1420
|
}
|
|
1421
1421
|
|
|
1422
1422
|
@ThreadConfined(UI)
|
|
@@ -171,7 +171,7 @@ public class FabricUIManager
|
|
|
171
171
|
private final CopyOnWriteArrayList<UIManagerListener> mListeners = new CopyOnWriteArrayList<>();
|
|
172
172
|
|
|
173
173
|
private boolean mMountNotificationScheduled = false;
|
|
174
|
-
private
|
|
174
|
+
private List<Integer> mSurfaceIdsWithPendingMountNotification = new ArrayList<>();
|
|
175
175
|
|
|
176
176
|
@ThreadConfined(UI)
|
|
177
177
|
@NonNull
|
|
@@ -1261,12 +1261,15 @@ public class FabricUIManager
|
|
|
1261
1261
|
|
|
1262
1262
|
// Collect surface IDs for all the mount items
|
|
1263
1263
|
for (MountItem mountItem : mountItems) {
|
|
1264
|
-
if (mountItem != null
|
|
1265
|
-
|
|
1264
|
+
if (mountItem != null
|
|
1265
|
+
&& !mSurfaceIdsWithPendingMountNotification.contains(mountItem.getSurfaceId())) {
|
|
1266
|
+
mSurfaceIdsWithPendingMountNotification.add(mountItem.getSurfaceId());
|
|
1266
1267
|
}
|
|
1267
1268
|
}
|
|
1268
1269
|
|
|
1269
|
-
if (!mMountNotificationScheduled && !
|
|
1270
|
+
if (!mMountNotificationScheduled && !mSurfaceIdsWithPendingMountNotification.isEmpty()) {
|
|
1271
|
+
mMountNotificationScheduled = true;
|
|
1272
|
+
|
|
1270
1273
|
// Notify mount when the effects are visible and prevent mount hooks to
|
|
1271
1274
|
// delay paint.
|
|
1272
1275
|
UiThreadUtil.getUiThreadHandler()
|
|
@@ -1276,17 +1279,19 @@ public class FabricUIManager
|
|
|
1276
1279
|
public void run() {
|
|
1277
1280
|
mMountNotificationScheduled = false;
|
|
1278
1281
|
|
|
1282
|
+
// Create a copy in case mount hooks trigger more mutations
|
|
1283
|
+
final List<Integer> surfaceIdsToReportMount =
|
|
1284
|
+
mSurfaceIdsWithPendingMountNotification;
|
|
1285
|
+
mSurfaceIdsWithPendingMountNotification = new ArrayList<>();
|
|
1286
|
+
|
|
1279
1287
|
final @Nullable FabricUIManagerBinding binding = mBinding;
|
|
1280
1288
|
if (binding == null || mDestroyed) {
|
|
1281
|
-
mMountedSurfaceIds.clear();
|
|
1282
1289
|
return;
|
|
1283
1290
|
}
|
|
1284
1291
|
|
|
1285
|
-
for (int surfaceId :
|
|
1292
|
+
for (int surfaceId : surfaceIdsToReportMount) {
|
|
1286
1293
|
binding.reportMount(surfaceId);
|
|
1287
1294
|
}
|
|
1288
|
-
|
|
1289
|
-
mMountedSurfaceIds.clear();
|
|
1290
1295
|
}
|
|
1291
1296
|
});
|
|
1292
1297
|
}
|
|
@@ -13,8 +13,6 @@ import android.os.Build
|
|
|
13
13
|
import android.view.View
|
|
14
14
|
import android.view.WindowInsetsController
|
|
15
15
|
import android.view.WindowManager
|
|
16
|
-
import androidx.core.view.ViewCompat
|
|
17
|
-
import androidx.core.view.WindowInsetsCompat
|
|
18
16
|
import com.facebook.common.logging.FLog
|
|
19
17
|
import com.facebook.fbreact.specs.NativeStatusBarManagerAndroidSpec
|
|
20
18
|
import com.facebook.react.bridge.GuardedRunnable
|
|
@@ -23,6 +21,7 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
23
21
|
import com.facebook.react.bridge.UiThreadUtil
|
|
24
22
|
import com.facebook.react.common.ReactConstants
|
|
25
23
|
import com.facebook.react.module.annotations.ReactModule
|
|
24
|
+
import com.facebook.react.uimanager.DisplayMetricsHolder.getStatusBarHeightPx
|
|
26
25
|
import com.facebook.react.uimanager.PixelUtil
|
|
27
26
|
import com.facebook.react.views.view.setStatusBarTranslucency
|
|
28
27
|
import com.facebook.react.views.view.setStatusBarVisibility
|
|
@@ -34,29 +33,17 @@ public class StatusBarModule(reactContext: ReactApplicationContext?) :
|
|
|
34
33
|
|
|
35
34
|
@Suppress("DEPRECATION")
|
|
36
35
|
override fun getTypedExportedConstants(): Map<String, Any> {
|
|
36
|
+
val currentActivity = reactApplicationContext.currentActivity
|
|
37
37
|
val statusBarColor =
|
|
38
38
|
currentActivity?.window?.statusBarColor?.let { color ->
|
|
39
39
|
String.format("#%06X", 0xFFFFFF and color)
|
|
40
40
|
} ?: "black"
|
|
41
41
|
return mapOf(
|
|
42
|
-
HEIGHT_KEY to PixelUtil.toDIPFromPixel(getStatusBarHeightPx()),
|
|
42
|
+
HEIGHT_KEY to PixelUtil.toDIPFromPixel(getStatusBarHeightPx(currentActivity).toFloat()),
|
|
43
43
|
DEFAULT_BACKGROUND_COLOR_KEY to statusBarColor,
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
@Suppress("DEPRECATION")
|
|
48
|
-
private fun getStatusBarHeightPx(): Float {
|
|
49
|
-
val windowInsets =
|
|
50
|
-
currentActivity?.window?.decorView?.let(ViewCompat::getRootWindowInsets) ?: return 0f
|
|
51
|
-
return windowInsets
|
|
52
|
-
.getInsets(
|
|
53
|
-
WindowInsetsCompat.Type.statusBars() or
|
|
54
|
-
WindowInsetsCompat.Type.navigationBars() or
|
|
55
|
-
WindowInsetsCompat.Type.displayCutout())
|
|
56
|
-
.top
|
|
57
|
-
.toFloat()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
47
|
@Suppress("DEPRECATION")
|
|
61
48
|
override fun setColor(colorDouble: Double, animated: Boolean) {
|
|
62
49
|
val color = colorDouble.toInt()
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
package com.facebook.react.uimanager
|
|
9
9
|
|
|
10
|
+
import android.app.Activity
|
|
10
11
|
import android.content.Context
|
|
11
12
|
import android.util.DisplayMetrics
|
|
12
13
|
import android.view.WindowManager
|
|
14
|
+
import androidx.core.view.ViewCompat
|
|
15
|
+
import androidx.core.view.WindowInsetsCompat
|
|
13
16
|
import com.facebook.react.bridge.WritableMap
|
|
14
17
|
import com.facebook.react.bridge.WritableNativeMap
|
|
15
18
|
|
|
@@ -99,4 +102,14 @@ public object DisplayMetricsHolder {
|
|
|
99
102
|
putDouble("fontScale", fontScale)
|
|
100
103
|
putDouble("densityDpi", displayMetrics.densityDpi.toDouble())
|
|
101
104
|
}
|
|
105
|
+
|
|
106
|
+
internal fun getStatusBarHeightPx(activity: Activity?): Int {
|
|
107
|
+
val windowInsets = activity?.window?.decorView?.let(ViewCompat::getRootWindowInsets) ?: return 0
|
|
108
|
+
return windowInsets
|
|
109
|
+
.getInsets(
|
|
110
|
+
WindowInsetsCompat.Type.statusBars() or
|
|
111
|
+
WindowInsetsCompat.Type.navigationBars() or
|
|
112
|
+
WindowInsetsCompat.Type.displayCutout())
|
|
113
|
+
.top
|
|
114
|
+
}
|
|
102
115
|
}
|
|
@@ -136,10 +136,10 @@ public data class BorderRadiusStyle(
|
|
|
136
136
|
(startStart ?: topStart ?: topLeft ?: uniform)?.resolve(width, height)
|
|
137
137
|
?: zeroRadii,
|
|
138
138
|
bottomLeft =
|
|
139
|
-
(endEnd ?:
|
|
139
|
+
(endEnd ?: bottomEnd ?: bottomRight ?: uniform)?.resolve(width, height)
|
|
140
140
|
?: zeroRadii,
|
|
141
141
|
bottomRight =
|
|
142
|
-
(startEnd ?:
|
|
142
|
+
(startEnd ?: bottomStart ?: bottomLeft ?: uniform)?.resolve(width, height)
|
|
143
143
|
?: zeroRadii,
|
|
144
144
|
width = width,
|
|
145
145
|
height = height,
|
|
@@ -37,6 +37,8 @@ import com.facebook.react.bridge.WritableNativeMap
|
|
|
37
37
|
import com.facebook.react.common.ReactConstants
|
|
38
38
|
import com.facebook.react.common.annotations.VisibleForTesting
|
|
39
39
|
import com.facebook.react.config.ReactFeatureFlags
|
|
40
|
+
import com.facebook.react.uimanager.DisplayMetricsHolder
|
|
41
|
+
import com.facebook.react.uimanager.DisplayMetricsHolder.getStatusBarHeightPx
|
|
40
42
|
import com.facebook.react.uimanager.JSPointerDispatcher
|
|
41
43
|
import com.facebook.react.uimanager.JSTouchDispatcher
|
|
42
44
|
import com.facebook.react.uimanager.PixelUtil.pxToDp
|
|
@@ -49,6 +51,7 @@ import com.facebook.react.views.common.ContextUtils
|
|
|
49
51
|
import com.facebook.react.views.view.ReactViewGroup
|
|
50
52
|
import com.facebook.react.views.view.setStatusBarTranslucency
|
|
51
53
|
import com.facebook.react.views.view.setSystemBarsTranslucency
|
|
54
|
+
import com.facebook.yoga.annotations.DoNotStrip
|
|
52
55
|
import java.util.Objects
|
|
53
56
|
|
|
54
57
|
/**
|
|
@@ -119,6 +122,7 @@ public class ReactModalHostView(context: ThemedReactContext) :
|
|
|
119
122
|
private var createNewDialog = false
|
|
120
123
|
|
|
121
124
|
init {
|
|
125
|
+
initStatusBarHeight(context)
|
|
122
126
|
dialogRootViewGroup = DialogRootViewGroup(context)
|
|
123
127
|
}
|
|
124
128
|
|
|
@@ -220,6 +224,15 @@ public class ReactModalHostView(context: ThemedReactContext) :
|
|
|
220
224
|
|
|
221
225
|
private fun getCurrentActivity(): Activity? = (context as ThemedReactContext).currentActivity
|
|
222
226
|
|
|
227
|
+
private fun isFlagSecureSet(activity: Activity?): Boolean {
|
|
228
|
+
if (activity == null) {
|
|
229
|
+
return false
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
val flags = activity.window.attributes.flags
|
|
233
|
+
return (flags and WindowManager.LayoutParams.FLAG_SECURE) != 0
|
|
234
|
+
}
|
|
235
|
+
|
|
223
236
|
/**
|
|
224
237
|
* showOrUpdate will display the Dialog. It is called by the manager once all properties are set
|
|
225
238
|
* because we need to know all of them before creating the Dialog. It is also smart during updates
|
|
@@ -293,6 +306,11 @@ public class ReactModalHostView(context: ThemedReactContext) :
|
|
|
293
306
|
if (hardwareAccelerated) {
|
|
294
307
|
newDialog.window?.addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
|
|
295
308
|
}
|
|
309
|
+
val flagSecureSet = isFlagSecureSet(currentActivity)
|
|
310
|
+
if (flagSecureSet) {
|
|
311
|
+
newDialog.window?.setFlags(
|
|
312
|
+
WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
|
|
313
|
+
}
|
|
296
314
|
if (currentActivity?.isFinishing == false) {
|
|
297
315
|
newDialog.show()
|
|
298
316
|
updateSystemAppearance()
|
|
@@ -395,6 +413,26 @@ public class ReactModalHostView(context: ThemedReactContext) :
|
|
|
395
413
|
|
|
396
414
|
private companion object {
|
|
397
415
|
private const val TAG = "ReactModalHost"
|
|
416
|
+
|
|
417
|
+
// We store the status bar height to be able to properly position
|
|
418
|
+
// the modal on the first render.
|
|
419
|
+
private var statusBarHeight = 0
|
|
420
|
+
|
|
421
|
+
private fun initStatusBarHeight(reactContext: ReactContext) {
|
|
422
|
+
statusBarHeight = getStatusBarHeightPx(reactContext.currentActivity)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
@JvmStatic
|
|
426
|
+
@DoNotStrip
|
|
427
|
+
private fun getScreenDisplayMetricsWithoutInsets(): Long {
|
|
428
|
+
val displayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics()
|
|
429
|
+
return encodeFloatsToLong(
|
|
430
|
+
displayMetrics.widthPixels.toFloat().pxToDp(),
|
|
431
|
+
(displayMetrics.heightPixels - statusBarHeight).toFloat().pxToDp())
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
private fun encodeFloatsToLong(width: Float, height: Float): Long =
|
|
435
|
+
(width.toRawBits().toLong()) shl 32 or (height.toRawBits().toLong())
|
|
398
436
|
}
|
|
399
437
|
|
|
400
438
|
/**
|
|
@@ -410,6 +448,7 @@ public class ReactModalHostView(context: ThemedReactContext) :
|
|
|
410
448
|
*/
|
|
411
449
|
public class DialogRootViewGroup internal constructor(context: Context) :
|
|
412
450
|
ReactViewGroup(context), RootView {
|
|
451
|
+
|
|
413
452
|
internal var stateWrapper: StateWrapper? = null
|
|
414
453
|
internal var eventDispatcher: EventDispatcher? = null
|
|
415
454
|
|
|
@@ -112,7 +112,7 @@ Pod::Spec.new do |s|
|
|
|
112
112
|
ss.subspec "modal" do |sss|
|
|
113
113
|
sss.dependency folly_dep_name, folly_version
|
|
114
114
|
sss.compiler_flags = folly_compiler_flags
|
|
115
|
-
sss.source_files = "react/renderer/components/modal
|
|
115
|
+
sss.source_files = "react/renderer/components/modal/*.{m,mm,cpp,h}"
|
|
116
116
|
sss.exclude_files = "react/renderer/components/modal/tests"
|
|
117
117
|
sss.header_dir = "react/renderer/components/modal"
|
|
118
118
|
end
|
|
@@ -14,7 +14,10 @@ add_compile_options(
|
|
|
14
14
|
-Wpedantic
|
|
15
15
|
-DLOG_TAG=\"Fabric\")
|
|
16
16
|
|
|
17
|
-
file(GLOB rrc_modal_SRC CONFIGURE_DEPENDS
|
|
17
|
+
file(GLOB rrc_modal_SRC CONFIGURE_DEPENDS
|
|
18
|
+
*.cpp
|
|
19
|
+
platform/android/*.cpp)
|
|
20
|
+
|
|
18
21
|
add_library(rrc_modal STATIC ${rrc_modal_SRC})
|
|
19
22
|
|
|
20
23
|
target_include_directories(rrc_modal PUBLIC ${REACT_COMMON_DIR})
|
|
@@ -30,8 +30,9 @@ class ModalHostViewComponentDescriptor final
|
|
|
30
30
|
*shadowNode.getState())
|
|
31
31
|
.getData();
|
|
32
32
|
|
|
33
|
-
layoutableShadowNode.setSize(
|
|
34
|
-
|
|
33
|
+
layoutableShadowNode.setSize(Size{
|
|
34
|
+
.width = stateData.screenSize.width,
|
|
35
|
+
.height = stateData.screenSize.height});
|
|
35
36
|
layoutableShadowNode.setPositionType(YGPositionTypeAbsolute);
|
|
36
37
|
|
|
37
38
|
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
@@ -9,15 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
#include <react/renderer/core/graphicsConversions.h>
|
|
11
11
|
#include <react/renderer/graphics/Float.h>
|
|
12
|
+
#include "ModalHostViewUtils.h"
|
|
12
13
|
|
|
13
14
|
#ifdef ANDROID
|
|
14
15
|
#include <folly/dynamic.h>
|
|
15
16
|
#endif
|
|
16
17
|
|
|
17
|
-
#if defined(__APPLE__) && TARGET_OS_IOS
|
|
18
|
-
#include "ModalHostViewUtils.h"
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
18
|
namespace facebook::react {
|
|
22
19
|
|
|
23
20
|
/*
|
|
@@ -27,12 +24,7 @@ class ModalHostViewState final {
|
|
|
27
24
|
public:
|
|
28
25
|
using Shared = std::shared_ptr<const ModalHostViewState>;
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
ModalHostViewState() : screenSize(RCTModalHostViewScreenSize()) {
|
|
32
|
-
#else
|
|
33
|
-
ModalHostViewState(){
|
|
34
|
-
#endif
|
|
35
|
-
};
|
|
27
|
+
ModalHostViewState() : screenSize(ModalHostViewScreenSize()) {}
|
|
36
28
|
ModalHostViewState(Size screenSize_) : screenSize(screenSize_){};
|
|
37
29
|
|
|
38
30
|
#ifdef ANDROID
|
|
@@ -40,8 +32,8 @@ class ModalHostViewState final {
|
|
|
40
32
|
const ModalHostViewState& previousState,
|
|
41
33
|
folly::dynamic data)
|
|
42
34
|
: screenSize(Size{
|
|
43
|
-
(Float)data["screenWidth"].getDouble(),
|
|
44
|
-
(Float)data["screenHeight"].getDouble()}){};
|
|
35
|
+
.width = (Float)data["screenWidth"].getDouble(),
|
|
36
|
+
.height = (Float)data["screenHeight"].getDouble()}){};
|
|
45
37
|
#endif
|
|
46
38
|
|
|
47
39
|
const Size screenSize{};
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <react/renderer/
|
|
10
|
+
#include <react/renderer/graphics/Size.h>
|
|
11
11
|
|
|
12
12
|
namespace facebook::react {
|
|
13
13
|
|
|
14
|
-
Size
|
|
14
|
+
Size ModalHostViewScreenSize(void);
|
|
15
15
|
|
|
16
16
|
} // namespace facebook::react
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <react/renderer/graphics/Size.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
class JReactModalHostView
|
|
16
|
+
: public facebook::jni::JavaClass<JReactModalHostView> {
|
|
17
|
+
public:
|
|
18
|
+
static auto constexpr kJavaDescriptor =
|
|
19
|
+
"Lcom/facebook/react/views/modal/ReactModalHostView;";
|
|
20
|
+
|
|
21
|
+
static Size getDisplayMetrics() {
|
|
22
|
+
static auto method =
|
|
23
|
+
JReactModalHostView::javaClassStatic()->getStaticMethod<jlong()>(
|
|
24
|
+
"getScreenDisplayMetricsWithoutInsets");
|
|
25
|
+
auto result = method(javaClassStatic());
|
|
26
|
+
|
|
27
|
+
// Inspired from yogaMeassureToSize from conversions.h
|
|
28
|
+
int32_t wBits = 0xFFFFFFFF & (result >> 32);
|
|
29
|
+
int32_t hBits = 0xFFFFFFFF & result;
|
|
30
|
+
|
|
31
|
+
auto* measuredWidth = reinterpret_cast<float*>(&wBits);
|
|
32
|
+
auto* measuredHeight = reinterpret_cast<float*>(&hBits);
|
|
33
|
+
|
|
34
|
+
return Size{.width = *measuredWidth, .height = *measuredHeight};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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
|
+
|
|
8
|
+
#include <react/renderer/components/modal/ModalHostViewUtils.h>
|
|
9
|
+
#include <react/renderer/graphics/Size.h>
|
|
10
|
+
#include "JReactModalHostView.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
Size ModalHostViewScreenSize() {
|
|
15
|
+
return JReactModalHostView::getDisplayMetrics();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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
|
+
|
|
8
|
+
#include <react/renderer/components/modal/ModalHostViewUtils.h>
|
|
9
|
+
#include <react/renderer/graphics/Size.h>
|
|
10
|
+
|
|
11
|
+
namespace facebook::react {
|
|
12
|
+
|
|
13
|
+
Size ModalHostViewScreenSize() {
|
|
14
|
+
return Size{0, 0};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -76,6 +76,39 @@ EventPayloadType ScrollEvent::getType() const {
|
|
|
76
76
|
return EventPayloadType::ScrollEvent;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
jsi::Value ScrollEndDragEvent::asJSIValue(jsi::Runtime& runtime) const {
|
|
80
|
+
auto payload = ScrollEvent::asJSIValue(runtime).asObject(runtime);
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
auto targetContentOffsetObj = jsi::Object(runtime);
|
|
84
|
+
targetContentOffsetObj.setProperty(runtime, "x", targetContentOffset.x);
|
|
85
|
+
targetContentOffsetObj.setProperty(runtime, "y", targetContentOffset.y);
|
|
86
|
+
payload.setProperty(runtime, "targetContentOffset", targetContentOffsetObj);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
auto velocityObj = jsi::Object(runtime);
|
|
91
|
+
velocityObj.setProperty(runtime, "x", velocity.x);
|
|
92
|
+
velocityObj.setProperty(runtime, "y", velocity.y);
|
|
93
|
+
payload.setProperty(runtime, "velocity", velocityObj);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return payload;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
folly::dynamic ScrollEndDragEvent::asDynamic() const {
|
|
100
|
+
auto metrics = ScrollEvent::asDynamic();
|
|
101
|
+
|
|
102
|
+
auto targetContentOffsetObj = folly::dynamic::object(
|
|
103
|
+
"x", targetContentOffset.x)("y", targetContentOffset.y);
|
|
104
|
+
metrics["targetContentOffset"] = std::move(targetContentOffsetObj);
|
|
105
|
+
|
|
106
|
+
auto velocityObj = folly::dynamic::object("x", velocity.x)("y", velocity.y);
|
|
107
|
+
metrics["velocity"] = std::move(velocityObj);
|
|
108
|
+
|
|
109
|
+
return metrics;
|
|
110
|
+
};
|
|
111
|
+
|
|
79
112
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
80
113
|
|
|
81
114
|
std::string getDebugName(const ScrollEvent& /*scrollEvent*/) {
|
|
@@ -37,6 +37,23 @@ struct ScrollEvent : public EventPayload {
|
|
|
37
37
|
EventPayloadType getType() const override;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
struct ScrollEndDragEvent : public ScrollEvent {
|
|
41
|
+
Point targetContentOffset;
|
|
42
|
+
Point velocity;
|
|
43
|
+
|
|
44
|
+
ScrollEndDragEvent() = default;
|
|
45
|
+
|
|
46
|
+
ScrollEndDragEvent(const ScrollEvent& scrollEvent)
|
|
47
|
+
: ScrollEvent(scrollEvent), targetContentOffset({}), velocity({}) {}
|
|
48
|
+
|
|
49
|
+
folly::dynamic asDynamic() const;
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* EventPayload implementations
|
|
53
|
+
*/
|
|
54
|
+
jsi::Value asJSIValue(jsi::Runtime& runtime) const override;
|
|
55
|
+
};
|
|
56
|
+
|
|
40
57
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
41
58
|
|
|
42
59
|
std::string getDebugName(const ScrollEvent& scrollEvent);
|
|
@@ -25,8 +25,9 @@ void ScrollViewEventEmitter::onScrollBeginDrag(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
void ScrollViewEventEmitter::onScrollEndDrag(
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const ScrollEndDragEvent& scrollEvent) const {
|
|
29
|
+
dispatchEvent(
|
|
30
|
+
"scrollEndDrag", std::make_shared<ScrollEndDragEvent>(scrollEvent));
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
void ScrollViewEventEmitter::onMomentumScrollBegin(
|
|
@@ -21,10 +21,11 @@ class ScrollViewEventEmitter : public ViewEventEmitter {
|
|
|
21
21
|
using ViewEventEmitter::ViewEventEmitter;
|
|
22
22
|
|
|
23
23
|
using Metrics = ScrollEvent;
|
|
24
|
+
using EndDragMetrics = ScrollEndDragEvent;
|
|
24
25
|
|
|
25
26
|
void onScroll(const ScrollEvent& scrollEvent) const;
|
|
26
27
|
void onScrollBeginDrag(const ScrollEvent& scrollEvent) const;
|
|
27
|
-
void onScrollEndDrag(const
|
|
28
|
+
void onScrollEndDrag(const ScrollEndDragEvent& scrollEvent) const;
|
|
28
29
|
void onMomentumScrollBegin(const ScrollEvent& scrollEvent) const;
|
|
29
30
|
void onMomentumScrollEnd(const ScrollEvent& scrollEvent) const;
|
|
30
31
|
void onScrollToTop(const ScrollEvent& scrollEvent) const;
|
|
@@ -300,8 +300,9 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
if (!args[0].isObject() || !args[0].asObject(rt).isFunction(rt)) {
|
|
303
|
-
// Do not throw any error to match web spec
|
|
304
|
-
|
|
303
|
+
// Do not throw any error to match web spec; instead return 0, an
|
|
304
|
+
// invalid timer id
|
|
305
|
+
return 0;
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
auto callback = args[0].getObject(rt).getFunction(rt);
|
|
@@ -358,8 +359,9 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
|
|
358
359
|
}
|
|
359
360
|
|
|
360
361
|
if (!args[0].isObject() || !args[0].asObject(rt).isFunction(rt)) {
|
|
361
|
-
throw
|
|
362
|
-
|
|
362
|
+
// Do not throw any error to match web spec; instead return 0, an
|
|
363
|
+
// invalid timer id
|
|
364
|
+
return 0;
|
|
363
365
|
}
|
|
364
366
|
auto callback = args[0].getObject(rt).getFunction(rt);
|
|
365
367
|
auto delay = count > 1
|
|
@@ -93,7 +93,9 @@ class TimerManager {
|
|
|
93
93
|
|
|
94
94
|
// Each timeout that is registered on this queue gets a sequential id. This
|
|
95
95
|
// is the global count from which those are assigned.
|
|
96
|
-
|
|
96
|
+
// As per WHATWG HTML 8.6.1 (Timers) ids must be greater than zero, i.e. start
|
|
97
|
+
// at 1
|
|
98
|
+
TimerHandle timerIndex_{1};
|
|
97
99
|
|
|
98
100
|
// The React Native microtask queue is used to back public APIs including
|
|
99
101
|
// `queueMicrotask`, `clearImmediate`, and `setImmediate` (which is used by
|
|
@@ -266,7 +266,9 @@ TEST_F(ReactInstanceTest, testSetTimeoutWithoutDelay) {
|
|
|
266
266
|
EXPECT_CALL(
|
|
267
267
|
*mockRegistry_,
|
|
268
268
|
createTimer(_, 0)); // If delay is not provided, it should use 0
|
|
269
|
-
eval("setTimeout(() => {});");
|
|
269
|
+
auto val = eval("setTimeout(() => {});");
|
|
270
|
+
expectNoError();
|
|
271
|
+
EXPECT_EQ(val.asNumber(), 1); // First timer id should start at 1
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
TEST_F(ReactInstanceTest, testSetTimeoutWithPassThroughArgs) {
|
|
@@ -298,8 +300,9 @@ TEST_F(ReactInstanceTest, testSetTimeoutWithInvalidArgs) {
|
|
|
298
300
|
getErrorMessage("setTimeout();"),
|
|
299
301
|
"setTimeout must be called with at least one argument (the function to call).");
|
|
300
302
|
|
|
301
|
-
eval("setTimeout('invalid')
|
|
303
|
+
auto val = eval("setTimeout('invalid')");
|
|
302
304
|
expectNoError();
|
|
305
|
+
EXPECT_EQ(val.asNumber(), 0);
|
|
303
306
|
|
|
304
307
|
eval("setTimeout(() => {}, 'invalid');");
|
|
305
308
|
expectNoError();
|
|
@@ -416,9 +419,10 @@ TEST_F(ReactInstanceTest, testSetIntervalWithInvalidArgs) {
|
|
|
416
419
|
EXPECT_EQ(
|
|
417
420
|
getErrorMessage("setInterval();"),
|
|
418
421
|
"setInterval must be called with at least one argument (the function to call).");
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
+
|
|
423
|
+
auto val = eval("setInterval('invalid', 100)");
|
|
424
|
+
expectNoError();
|
|
425
|
+
EXPECT_EQ(val.asNumber(), 0);
|
|
422
426
|
}
|
|
423
427
|
|
|
424
428
|
TEST_F(ReactInstanceTest, testClearInterval) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.77.
|
|
3
|
+
"version": "0.77.7",
|
|
4
4
|
"description": "React Native for macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"@types/react": "^18.2.6",
|
|
104
104
|
"react": "^18.2.0",
|
|
105
|
-
"react-native": "0.77.
|
|
105
|
+
"react-native": "0.77.3"
|
|
106
106
|
},
|
|
107
107
|
"peerDependenciesMeta": {
|
|
108
108
|
"@types/react": {
|
|
@@ -111,13 +111,13 @@
|
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@jest/create-cache-key-function": "^29.6.3",
|
|
114
|
-
"@react-native-macos/virtualized-lists": "0.77.
|
|
115
|
-
"@react-native/assets-registry": "0.77.
|
|
116
|
-
"@react-native/codegen": "0.77.
|
|
117
|
-
"@react-native/community-cli-plugin": "0.77.
|
|
118
|
-
"@react-native/gradle-plugin": "0.77.
|
|
119
|
-
"@react-native/js-polyfills": "0.77.
|
|
120
|
-
"@react-native/normalize-colors": "0.77.
|
|
114
|
+
"@react-native-macos/virtualized-lists": "0.77.7",
|
|
115
|
+
"@react-native/assets-registry": "0.77.3",
|
|
116
|
+
"@react-native/codegen": "0.77.3",
|
|
117
|
+
"@react-native/community-cli-plugin": "0.77.3",
|
|
118
|
+
"@react-native/gradle-plugin": "0.77.3",
|
|
119
|
+
"@react-native/js-polyfills": "0.77.3",
|
|
120
|
+
"@react-native/normalize-colors": "0.77.3",
|
|
121
121
|
"abort-controller": "^3.0.0",
|
|
122
122
|
"anser": "^1.4.9",
|
|
123
123
|
"ansi-regex": "^5.0.0",
|
|
@@ -133,8 +133,8 @@
|
|
|
133
133
|
"jest-environment-node": "^29.6.3",
|
|
134
134
|
"jsc-android": "^250231.0.0",
|
|
135
135
|
"memoize-one": "^5.0.0",
|
|
136
|
-
"metro-runtime": "^0.81.
|
|
137
|
-
"metro-source-map": "^0.81.
|
|
136
|
+
"metro-runtime": "^0.81.5",
|
|
137
|
+
"metro-source-map": "^0.81.5",
|
|
138
138
|
"nullthrows": "^1.1.1",
|
|
139
139
|
"pretty-format": "^29.7.0",
|
|
140
140
|
"promise": "^8.3.0",
|