react-native-macos 0.0.0-bb8a035db → 0.0.0-bc0c2c4d1

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.
Files changed (64) hide show
  1. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  2. package/Libraries/Components/TextInput/TextInput.js +7 -0
  3. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  4. package/Libraries/Core/ReactNativeVersion.js +1 -1
  5. package/Libraries/Image/RCTImageView.mm +14 -10
  6. package/Libraries/Lists/VirtualizedList.js +13 -1
  7. package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
  8. package/Libraries/Text/RCTTextAttributes.h +2 -0
  9. package/Libraries/Text/RCTTextAttributes.m +9 -0
  10. package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
  11. package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
  12. package/Libraries/Text/Text/RCTTextView.m +118 -47
  13. package/Libraries/Text/Text.js +0 -8
  14. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +5 -0
  15. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +55 -5
  16. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +2 -0
  17. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +1 -1
  18. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +1 -1
  19. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +0 -1
  20. package/Libraries/Text/TextNativeComponent.js +2 -0
  21. package/Libraries/Text/TextProps.js +29 -0
  22. package/React/Base/RCTAssert.h +4 -3
  23. package/React/Base/RCTAssert.m +11 -2
  24. package/React/Base/RCTBridge.m +1 -1
  25. package/React/Base/RCTConstants.h +6 -0
  26. package/React/Base/RCTConstants.m +15 -0
  27. package/React/Base/RCTConvert.m +1 -1
  28. package/React/Base/RCTUIKit.h +8 -13
  29. package/React/Base/RCTVersion.m +1 -1
  30. package/React/Base/macOS/RCTUIKit.m +33 -0
  31. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +6 -2
  32. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
  33. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +17 -3
  34. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
  35. package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
  36. package/React/Fabric/Mounting/RCTMountingManager.mm +3 -3
  37. package/React/Fabric/RCTConversions.h +9 -1
  38. package/React/Fabric/RCTLocalizationProvider.mm +10 -4
  39. package/React/Fabric/RCTScheduler.h +5 -0
  40. package/React/Fabric/RCTScheduler.mm +10 -0
  41. package/React/Fabric/RCTSurfacePresenter.h +2 -0
  42. package/React/Fabric/RCTSurfacePresenter.mm +12 -11
  43. package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
  44. package/React/React-RCTFabric.podspec +1 -1
  45. package/React/Views/RCTView.m +6 -1
  46. package/React/Views/RCTViewManager.m +1 -1
  47. package/React/Views/ScrollView/RCTScrollView.m +1 -1
  48. package/ReactAndroid/gradle.properties +1 -1
  49. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  50. package/ReactCommon/React-Fabric.podspec +1 -1
  51. package/ReactCommon/React-rncore.podspec +1 -1
  52. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  53. package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
  54. package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
  55. package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
  56. package/ReactCommon/react/renderer/core/EventListener.h +44 -0
  57. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  58. package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +14 -0
  59. package/ReactCommon/react/renderer/scheduler/Scheduler.h +6 -0
  60. package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
  61. package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
  62. package/package.json +1 -1
  63. package/template/Gemfile.lock +3 -3
  64. package/template/package.json +1 -1
@@ -15,6 +15,7 @@
15
15
  {
16
16
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
17
17
  RCTUIScrollView *_scrollView;
18
+ RCTClipView *_clipView;
18
19
  #endif // ]TODO(macOS GH#774)
19
20
  RCTUITextView *_backedTextInputView;
20
21
  }
@@ -28,6 +29,7 @@
28
29
  _backedTextInputView = [[RCTUITextView alloc] initWithFrame:self.bounds];
29
30
  _backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
30
31
  #if TARGET_OS_OSX // TODO(macOS GH#774)
32
+ self.hideVerticalScrollIndicator = NO;
31
33
  _scrollView = [[RCTUIScrollView alloc] initWithFrame:self.bounds]; // TODO(macOS ISS#3536887)
32
34
  _scrollView.backgroundColor = [RCTUIColor clearColor];
33
35
  _scrollView.drawsBackground = NO;
@@ -35,6 +37,10 @@
35
37
  _scrollView.hasHorizontalRuler = NO;
36
38
  _scrollView.hasVerticalRuler = NO;
37
39
  _scrollView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
40
+ [_scrollView setHasVerticalScroller:YES];
41
+
42
+ _clipView = [[RCTClipView alloc] initWithFrame:_scrollView.frame];
43
+ [_scrollView setContentView:_clipView];
38
44
 
39
45
  _backedTextInputView.verticallyResizable = YES;
40
46
  _backedTextInputView.horizontallyResizable = YES;
@@ -92,16 +98,63 @@
92
98
  [self setNeedsLayout];
93
99
  }
94
100
 
95
- - (void)setEnableFocusRing:(BOOL)enableFocusRing {
101
+ - (void)setEnableFocusRing:(BOOL)enableFocusRing
102
+ {
96
103
  [super setEnableFocusRing:enableFocusRing];
97
104
  if ([_scrollView respondsToSelector:@selector(setEnableFocusRing:)]) {
98
105
  [_scrollView setEnableFocusRing:enableFocusRing];
99
106
  }
100
107
  }
101
108
 
102
- - (void)setReadablePasteBoardTypes:(NSArray<NSPasteboardType> *)readablePasteboardTypes {
109
+ - (void)setReadablePasteBoardTypes:(NSArray<NSPasteboardType> *)readablePasteboardTypes
110
+ {
103
111
  [_backedTextInputView setReadablePasteBoardTypes:readablePasteboardTypes];
104
112
  }
113
+
114
+ - (void)setScrollEnabled:(BOOL)scrollEnabled
115
+ {
116
+ if (scrollEnabled) {
117
+ _scrollView.scrollEnabled = YES;
118
+ [_clipView setConstrainScrolling:NO];
119
+ } else {
120
+ _scrollView.scrollEnabled = NO;
121
+ [_clipView setConstrainScrolling:YES];
122
+ }
123
+ }
124
+
125
+ - (BOOL)scrollEnabled
126
+ {
127
+ return _scrollView.isScrollEnabled;
128
+ }
129
+
130
+ - (BOOL)shouldShowVerticalScrollbar
131
+ {
132
+ // Hide vertical scrollbar if explicity set to NO
133
+ if (self.hideVerticalScrollIndicator) {
134
+ return NO;
135
+ }
136
+
137
+ // Hide vertical scrollbar if attributed text overflows view
138
+ CGSize textViewSize = [_backedTextInputView intrinsicContentSize];
139
+ NSClipView *clipView = (NSClipView *)_scrollView.contentView;
140
+ if (textViewSize.height > clipView.bounds.size.height) {
141
+ return YES;
142
+ };
143
+
144
+ return NO;
145
+ }
146
+
147
+ - (void)textInputDidChange
148
+ {
149
+ [_scrollView setHasVerticalScroller:[self shouldShowVerticalScrollbar]];
150
+ }
151
+
152
+ - (void)setAttributedText:(NSAttributedString *)attributedText
153
+ {
154
+ [_backedTextInputView setAttributedText:attributedText];
155
+ [_scrollView setHasVerticalScroller:[self shouldShowVerticalScrollbar]];
156
+ }
157
+
105
158
  #endif // ]TODO(macOS GH#774)
106
159
 
107
160
  #pragma mark - UIScrollViewDelegate
@@ -109,9 +162,6 @@
109
162
  - (void)scrollViewDidScroll:(RCTUIScrollView *)scrollView // TODO(macOS ISS#3536887)
110
163
  {
111
164
  RCTDirectEventBlock onScroll = self.onScroll;
112
- #if TARGET_OS_OSX // [TODO(macOS GH#774)
113
- [_scrollView setHasVerticalScroller:YES];
114
- #endif // ]TODO(macOS GH#774)
115
165
  if (onScroll) {
116
166
  CGPoint contentOffset = scrollView.contentOffset;
117
167
  CGSize contentSize = scrollView.contentSize;
@@ -24,6 +24,8 @@ RCT_REMAP_NOT_OSX_VIEW_PROPERTY(dataDetectorTypes, backedTextInputView.dataDetec
24
24
  RCT_REMAP_OSX_VIEW_PROPERTY(dataDetectorTypes, backedTextInputView.enabledTextCheckingTypes, NSTextCheckingTypes) // TODO(macOS GH#774)
25
25
 
26
26
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
27
+ RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
28
+ RCT_EXPORT_VIEW_PROPERTY(hideVerticalScrollIndicator, BOOL)
27
29
  RCT_CUSTOM_VIEW_PROPERTY(pastedTypes, NSArray<NSPasteboardType>*, RCTUITextView)
28
30
  {
29
31
  NSArray<NSPasteboardType> *types = json ? [RCTConvert NSPasteboardTypeArray:json] : nil;
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
46
46
  @property (nonatomic, strong, nullable) NSString *inputAccessoryViewID;
47
47
 
48
48
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
49
- @property (nonatomic, assign) BOOL scrollEnabled;
49
+ @property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
50
50
  @property (nonatomic, strong, nullable) RCTUIColor *selectionColor; // TODO(OSS Candidate ISS#2710739)
51
51
  @property (nonatomic, assign) UIEdgeInsets textContainerInsets;
52
52
  @property (nonatomic, copy) NSString *text;
@@ -681,7 +681,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)decoder)
681
681
  - (BOOL)textInputShouldHandlePaste:(__unused id)sender
682
682
  {
683
683
  NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
684
- NSPasteboardType fileType = [pasteboard availableTypeFromArray:@[NSPasteboardTypeFileURL, NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
684
+ NSPasteboardType fileType = [pasteboard availableTypeFromArray:@[NSFilenamesPboardType, NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
685
685
  NSArray<NSPasteboardType>* pastedTypes = ((RCTUITextView*) self.backedTextInputView).readablePasteboardTypes;
686
686
 
687
687
  // If there's a fileType that is of interest, notify JS. Also blocks notifying JS if it's a text paste
@@ -53,7 +53,6 @@ RCT_REMAP_NOT_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingTyp
53
53
  RCT_REMAP_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.continuousSpellCheckingEnabled, BOOL) // TODO(macOS GH#774)
54
54
  RCT_REMAP_NOT_OSX_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) // TODO(macOS GH#774)
55
55
  RCT_REMAP_NOT_OSX_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode) // TODO(macOS GH#774)
56
- RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL)
57
56
  RCT_REMAP_NOT_OSX_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) // TODO(macOS GH#774)
58
57
  RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL)
59
58
  RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
@@ -33,7 +33,9 @@ export const NativeText: HostComponent<NativeTextProps> =
33
33
  isPressable: true,
34
34
  numberOfLines: true,
35
35
  ellipsizeMode: true,
36
+ focusable: true,
36
37
  allowFontScaling: true,
38
+ dynamicTypeRamp: true,
37
39
  maxFontSizeMultiplier: true,
38
40
  disabled: true,
39
41
  selectable: true,
@@ -186,6 +186,23 @@ export type TextProps = $ReadOnly<{|
186
186
  */
187
187
  adjustsFontSizeToFit?: ?boolean,
188
188
 
189
+ /**
190
+ * The Dynamic Text scale ramp to apply to this element on iOS.
191
+ */
192
+ dynamicTypeRamp?: ?(
193
+ | 'caption2'
194
+ | 'caption1'
195
+ | 'footnote'
196
+ | 'subheadline'
197
+ | 'callout'
198
+ | 'body'
199
+ | 'headline'
200
+ | 'title3'
201
+ | 'title2'
202
+ | 'title1'
203
+ | 'largeTitle'
204
+ ),
205
+
189
206
  /**
190
207
  * Smallest possible scale a font can reach.
191
208
  *
@@ -208,4 +225,16 @@ export type TextProps = $ReadOnly<{|
208
225
  * Specifies the Tooltip for the button view
209
226
  */
210
227
  tooltip?: ?string,
228
+
229
+ /**
230
+ * When `true`, indicates that the text can be focused in key view loop
231
+ * By default, when `selectable={true}` the text view will be focusable unless disabled
232
+ */
233
+ focusable?: ?boolean,
234
+
235
+ /**
236
+ * Specifies whether focus ring should be drawn when the view has the first responder status.
237
+ * Only works when `focusable={true}`
238
+ */
239
+ enableFocusRing?: ?boolean, // TODO(macOS GH#774)
211
240
  |}>;
@@ -183,7 +183,8 @@ __attribute__((used)) RCT_EXTERN void RCTEnableNewArchitectureViolationReporting
183
183
 
184
184
  // When reporting is enabled, trigger an assertion.
185
185
  __attribute__((used)) RCT_EXTERN void RCTEnforceNotAllowedForNewArchitecture(id context, NSString *extra);
186
-
187
- // When reporting is enabled, warn about the violation. Use this to prepare a specific callsite
186
+ // When reporting is enabled, trigger an error but do not crash. Use this to prepare a specific callsite
188
187
  // for stricter enforcement. When ready, switch it to use the variant above.
189
- __attribute__((used)) RCT_EXTERN void RCTWarnNotAllowedForNewArchitecture(id context, NSString *extra);
188
+ __attribute__((used)) RCT_EXTERN void RCTErrorNotAllowedForNewArchitecture(id context, NSString *extra);
189
+ // When reporting is enabled, log an message. When ready, switch it to use the variant above.
190
+ __attribute__((used)) RCT_EXTERN void RCTLogNotAllowedForNewArchitecture(id context, NSString *extra);
@@ -274,11 +274,20 @@ void RCTEnforceNotAllowedForNewArchitecture(id context, NSString *extra)
274
274
  RCTAssert(0, @"%@", getNewArchitectureViolationMessage(context, extra));
275
275
  }
276
276
 
277
- void RCTWarnNotAllowedForNewArchitecture(id context, NSString *extra)
277
+ void RCTErrorNotAllowedForNewArchitecture(id context, NSString *extra)
278
278
  {
279
279
  if (!newArchitectureViolationReporting) {
280
280
  return;
281
281
  }
282
282
 
283
- RCTLogWarn(@"%@", getNewArchitectureViolationMessage(context, extra));
283
+ RCTLogError(@"%@", getNewArchitectureViolationMessage(context, extra));
284
+ }
285
+
286
+ void RCTLogNotAllowedForNewArchitecture(id context, NSString *extra)
287
+ {
288
+ if (!newArchitectureViolationReporting) {
289
+ return;
290
+ }
291
+
292
+ RCTLogInfo(@"%@", getNewArchitectureViolationMessage(context, extra));
284
293
  }
@@ -60,7 +60,7 @@ NSArray<Class> *RCTGetModuleClasses(void)
60
60
  void RCTRegisterModule(Class);
61
61
  void RCTRegisterModule(Class moduleClass)
62
62
  {
63
- RCTWarnNotAllowedForNewArchitecture(
63
+ RCTLogNotAllowedForNewArchitecture(
64
64
  @"RCTRegisterModule()", [NSString stringWithFormat:@"'%@' was registered unexpectedly", moduleClass]);
65
65
 
66
66
  static dispatch_once_t onceToken;
@@ -15,3 +15,9 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec
15
15
  */
16
16
  RCT_EXTERN BOOL RCTExperimentGetPreemptiveViewAllocationDisabled(void);
17
17
  RCT_EXTERN void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value);
18
+
19
+ /*
20
+ * W3C Pointer Events
21
+ */
22
+ RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void);
23
+ RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value);
@@ -24,3 +24,18 @@ void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value)
24
24
  {
25
25
  RCTExperimentPreemptiveViewAllocationDisabled = value;
26
26
  }
27
+
28
+ /*
29
+ * W3C Pointer Events
30
+ */
31
+ static BOOL RCTDispatchW3CPointerEvents = NO;
32
+
33
+ BOOL RCTGetDispatchW3CPointerEvents()
34
+ {
35
+ return RCTDispatchW3CPointerEvents;
36
+ }
37
+
38
+ void RCTSetDispatchW3CPointerEvents(BOOL value)
39
+ {
40
+ RCTDispatchW3CPointerEvents = value;
41
+ }
@@ -1233,7 +1233,7 @@ RCT_JSON_ARRAY_CONVERTER(NSNumber)
1233
1233
  }
1234
1234
 
1235
1235
  if ([type isEqualToString:@"fileUrl"]) {
1236
- return @[NSPasteboardTypeFileURL];
1236
+ return @[NSFilenamesPboardType];
1237
1237
  } else if ([type isEqualToString:@"image"]) {
1238
1238
  return @[NSPasteboardTypePNG, NSPasteboardTypeTIFF];
1239
1239
  } else if ([type isEqualToString:@"string"]) {
@@ -80,11 +80,6 @@ UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
80
80
  view.contentMode = UIViewContentModeRedraw;
81
81
  }
82
82
 
83
- UIKIT_STATIC_INLINE BOOL RCTUIViewDrawViewHierarchyInRectAfterScreenUpdates(RCTPlatformView *view, CGRect rect, BOOL afterUpdates)
84
- {
85
- return [view drawViewHierarchyInRect:rect afterScreenUpdates:afterUpdates];
86
- }
87
-
88
83
  UIKIT_STATIC_INLINE BOOL RCTUIViewIsDescendantOfView(RCTPlatformView *view, RCTPlatformView *parent)
89
84
  {
90
85
  return [view isDescendantOfView:parent];
@@ -427,9 +422,17 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
427
422
  @property (nonatomic, assign) BOOL alwaysBounceVertical;
428
423
  // macOS specific properties
429
424
  @property (nonatomic, assign) BOOL enableFocusRing;
425
+ @property (nonatomic, assign, getter=isScrollEnabled) BOOL scrollEnabled;
430
426
 
431
427
  @end
432
428
 
429
+ @interface RCTClipView : NSClipView // [TODO(macOS GH#774)
430
+
431
+ @property (nonatomic, assign) BOOL constrainScrolling;
432
+
433
+ @end // ]TODO(macOS GH#774)
434
+
435
+
433
436
  NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *event)
434
437
  {
435
438
  return [view hitTest:point];
@@ -442,14 +445,6 @@ NS_INLINE void RCTUIViewSetContentModeRedraw(RCTPlatformView *view)
442
445
  view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
443
446
  }
444
447
 
445
- NS_INLINE BOOL RCTUIViewDrawViewHierarchyInRectAfterScreenUpdates(RCTPlatformView *view, CGRect rect, __unused BOOL afterUpdates)
446
- {
447
- RCTAssert(afterUpdates, @"We're redrawing the view so it will necessarily include the latest changes.");
448
- (void) afterUpdates;
449
- [view displayRectIgnoringOpacity:NSRectToCGRect(rect)];
450
- return YES;
451
- }
452
-
453
448
  NS_INLINE BOOL RCTUIViewIsDescendantOfView(RCTPlatformView *view, RCTPlatformView *parent)
454
449
  {
455
450
  return [view isDescendantOf:parent];
@@ -28,7 +28,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(0),
30
30
  RCTVersionPatch: @(0),
31
- RCTVersionPrerelease: @"bb8a035db",
31
+ RCTVersionPrerelease: @"bc0c2c4d1",
32
32
  };
33
33
  });
34
34
  return __rnVersion;
@@ -436,6 +436,15 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
436
436
 
437
437
  @implementation RCTUIScrollView // TODO(macOS ISS#3536887)
438
438
 
439
+ - (instancetype)initWithFrame:(CGRect)frame
440
+ {
441
+ if (self = [super initWithFrame:frame]) {
442
+ self.scrollEnabled = YES;
443
+ }
444
+
445
+ return self;
446
+ }
447
+
439
448
  - (void)setEnableFocusRing:(BOOL)enableFocusRing {
440
449
  if (_enableFocusRing != enableFocusRing) {
441
450
  _enableFocusRing = enableFocusRing;
@@ -542,6 +551,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
542
551
  self.verticalScrollElasticity = alwaysBounceVertical ? NSScrollElasticityAllowed : NSScrollElasticityNone;
543
552
  }
544
553
 
554
+
545
555
  @end
546
556
 
547
557
  BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
@@ -557,3 +567,26 @@ BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
557
567
 
558
568
  return clipsToBounds;
559
569
  }
570
+
571
+ @implementation RCTClipView
572
+
573
+ - (instancetype)initWithFrame:(NSRect)frameRect
574
+ {
575
+ if (self = [super initWithFrame:frameRect]) {
576
+ self.constrainScrolling = NO;
577
+ self.drawsBackground = NO;
578
+ }
579
+
580
+ return self;
581
+ }
582
+
583
+ - (NSRect)constrainBoundsRect:(NSRect)proposedBounds
584
+ {
585
+ if (self.constrainScrolling) {
586
+ return NSMakeRect(0, 0, 0, 0);
587
+ }
588
+
589
+ return [super constrainBoundsRect:proposedBounds];
590
+ }
591
+
592
+ @end
@@ -29,8 +29,6 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
29
29
  - (instancetype)initWithFrame:(CGRect)frame
30
30
  {
31
31
  if (self = [super initWithFrame:frame]) {
32
- RCTWarnNotAllowedForNewArchitecture(
33
- self, @"ViewManager with interop layer is not allowed in the new architecture.");
34
32
  static const auto defaultProps = std::make_shared<const LegacyViewManagerInteropViewProps>();
35
33
  _props = defaultProps;
36
34
  _viewsToBeMounted = [NSMutableArray new];
@@ -67,6 +65,12 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
67
65
 
68
66
  + (BOOL)isSupported:(NSString *)componentName
69
67
  {
68
+ RCTLogNotAllowedForNewArchitecture(
69
+ self,
70
+ [NSString
71
+ stringWithFormat:
72
+ @"Legacy ViewManagers should be migrated to Fabric ComponentViews in the new architecture to reduce risk. Component using interop layer: %@",
73
+ componentName]);
70
74
  return [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] containsObject:componentName];
71
75
  }
72
76
 
@@ -25,7 +25,7 @@ using namespace facebook::react;
25
25
 
26
26
  @implementation RCTPullToRefreshViewComponentView {
27
27
  UIRefreshControl *_refreshControl;
28
- RCTScrollViewComponentView *_scrollViewComponentView;
28
+ RCTScrollViewComponentView *__weak _scrollViewComponentView;
29
29
  }
30
30
 
31
31
  - (instancetype)initWithFrame:(CGRect)frame
@@ -85,6 +85,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
85
85
  // This helps to only update state from `scrollViewDidScroll` in case
86
86
  // some other part of the system scrolls scroll view.
87
87
  BOOL _isUserTriggeredScrolling;
88
+ BOOL _shouldUpdateContentInsetAdjustmentBehavior;
88
89
 
89
90
  CGPoint _contentOffsetWhenClipped;
90
91
  }
@@ -108,6 +109,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
108
109
  _scrollView.delaysContentTouches = NO;
109
110
  ((RCTEnhancedScrollView *)_scrollView).overridingDelegate = self;
110
111
  _isUserTriggeredScrolling = NO;
112
+ _shouldUpdateContentInsetAdjustmentBehavior = YES;
111
113
  [self addSubview:_scrollView];
112
114
 
113
115
  _containerView = [[UIView alloc] initWithFrame:CGRectZero];
@@ -253,7 +255,8 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
253
255
  }
254
256
  }
255
257
 
256
- if (oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) {
258
+ if ((oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) ||
259
+ _shouldUpdateContentInsetAdjustmentBehavior) {
257
260
  auto const contentInsetAdjustmentBehavior = newScrollViewProps.contentInsetAdjustmentBehavior;
258
261
  if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Never) {
259
262
  scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
@@ -264,6 +267,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
264
267
  } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Always) {
265
268
  scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
266
269
  }
270
+ _shouldUpdateContentInsetAdjustmentBehavior = NO;
267
271
  }
268
272
 
269
273
  MAP_SCROLL_VIEW_PROP(disableIntervalMomentum);
@@ -377,8 +381,16 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
377
381
  {
378
382
  const auto &props = *std::static_pointer_cast<const ScrollViewProps>(_props);
379
383
  _scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset);
384
+ // We set the default behavior to "never" so that iOS
385
+ // doesn't do weird things to UIScrollView insets automatically
386
+ // and keeps it as an opt-in behavior.
387
+ _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
388
+ _shouldUpdateContentInsetAdjustmentBehavior = YES;
380
389
  _state.reset();
381
390
  _isUserTriggeredScrolling = NO;
391
+ CGRect oldFrame = self.frame;
392
+ self.frame = CGRectZero;
393
+ self.frame = oldFrame;
382
394
  [super prepareForRecycle];
383
395
  }
384
396
 
@@ -566,7 +578,6 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
566
578
  offset = CGPointMake(localX, localY);
567
579
  }
568
580
 
569
- [self _forceDispatchNextScrollEvent];
570
581
  [self scrollToOffset:offset animated:animated];
571
582
  }
572
583
 
@@ -621,12 +632,15 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
621
632
 
622
633
  - (void)scrollToOffset:(CGPoint)offset
623
634
  {
624
- [self _forceDispatchNextScrollEvent];
625
635
  [self scrollToOffset:offset animated:YES];
626
636
  }
627
637
 
628
638
  - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
629
639
  {
640
+ if (CGPointEqualToPoint(_scrollView.contentOffset, offset)) {
641
+ return;
642
+ }
643
+
630
644
  [self _forceDispatchNextScrollEvent];
631
645
 
632
646
  if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
@@ -591,6 +591,12 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
591
591
 
592
592
  RCTBorderColors borderColors = RCTCreateRCTBorderColorsFromBorderColors(borderMetrics.borderColors);
593
593
 
594
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
595
+ CGFloat scaleFactor = self.window.backingScaleFactor;
596
+ #else
597
+ // On iOS setting the scaleFactor to 0.0 will default to the device's native scale factor.
598
+ CGFloat scaleFactor = 0.0;
599
+ #endif // ]TODO(macOS GH#774)
594
600
  UIImage *image = RCTGetBorderImage(
595
601
  RCTBorderStyleFromBorderStyle(borderMetrics.borderStyles.left),
596
602
  layer.bounds.size,
@@ -598,7 +604,8 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
598
604
  RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths),
599
605
  borderColors,
600
606
  _backgroundColor.CGColor,
601
- self.clipsToBounds);
607
+ self.clipsToBounds,
608
+ scaleFactor); // TODO(macOS GH#774)
602
609
 
603
610
  RCTReleaseRCTBorderColors(borderColors);
604
611
 
@@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
63
63
 
64
64
  - (void)setIsJSResponder:(BOOL)isJSResponder
65
65
  blockNativeResponder:(BOOL)blockNativeResponder
66
- forShadowView:(facebook::react::ShadowView)shadowView;
66
+ forShadowView:(facebook::react::ShadowView const &)shadowView;
67
67
 
68
68
  - (void)synchronouslyUpdateViewOnUIThread:(ReactTag)reactTag
69
69
  changedProps:(NSDictionary *)props
@@ -280,11 +280,11 @@ static void RCTPerformMountInstructions(
280
280
 
281
281
  - (void)setIsJSResponder:(BOOL)isJSResponder
282
282
  blockNativeResponder:(BOOL)blockNativeResponder
283
- forShadowView:(facebook::react::ShadowView)shadowView
283
+ forShadowView:(facebook::react::ShadowView const &)shadowView
284
284
  {
285
+ ReactTag reactTag = shadowView.tag;
285
286
  RCTExecuteOnMainQueue(^{
286
- UIView<RCTComponentViewProtocol> *componentView =
287
- [self->_componentViewRegistry findComponentViewWithTag:shadowView.tag];
287
+ UIView<RCTComponentViewProtocol> *componentView = [self->_componentViewRegistry findComponentViewWithTag:reactTag];
288
288
  [componentView setIsJSResponder:isJSResponder];
289
289
  });
290
290
  }
@@ -173,9 +173,17 @@ inline facebook::react::Point RCTPointFromCGPoint(const CGPoint &point)
173
173
  return {point.x, point.y};
174
174
  }
175
175
 
176
+ inline facebook::react::Float RCTFloatFromCGFloat(CGFloat value)
177
+ {
178
+ if (value == CGFLOAT_MAX) {
179
+ return std::numeric_limits<facebook::react::Float>::infinity();
180
+ }
181
+ return value;
182
+ }
183
+
176
184
  inline facebook::react::Size RCTSizeFromCGSize(const CGSize &size)
177
185
  {
178
- return {size.width, size.height};
186
+ return {RCTFloatFromCGFloat(size.width), RCTFloatFromCGFloat(size.height)};
179
187
  }
180
188
 
181
189
  inline facebook::react::Rect RCTRectFromCGRect(const CGRect &rect)
@@ -26,15 +26,21 @@ void setLocalizationLanguagePack(NSDictionary<NSString *, NSString *> *pack)
26
26
 
27
27
  + (NSString *)RCTLocalizedString:(NSString *)oldString withDescription:(NSString *)description
28
28
  {
29
+ NSString *candidate = nil;
30
+
29
31
  if (_delegate != nil) {
30
- return [_delegate localizedString:oldString withDescription:description];
32
+ candidate = [_delegate localizedString:oldString withDescription:description];
33
+ }
34
+
35
+ if (candidate == nil && _languagePack != nil) {
36
+ candidate = _languagePack[oldString];
31
37
  }
32
38
 
33
- if (_languagePack != nil) {
34
- return _languagePack[oldString];
39
+ if (candidate == nil) {
40
+ candidate = oldString;
35
41
  }
36
42
 
37
- return oldString;
43
+ return candidate;
38
44
  }
39
45
 
40
46
  @end
@@ -10,6 +10,7 @@
10
10
 
11
11
  #import <react/renderer/componentregistry/ComponentDescriptorFactory.h>
12
12
  #import <react/renderer/core/ComponentDescriptor.h>
13
+ #import <react/renderer/core/EventListener.h>
13
14
  #import <react/renderer/core/LayoutConstraints.h>
14
15
  #import <react/renderer/core/LayoutContext.h>
15
16
  #import <react/renderer/mounting/MountingCoordinator.h>
@@ -64,6 +65,10 @@ NS_ASSUME_NONNULL_BEGIN
64
65
 
65
66
  - (void)animationTick;
66
67
 
68
+ - (void)addEventListener:(std::shared_ptr<facebook::react::EventListener> const &)listener;
69
+
70
+ - (void)removeEventListener:(std::shared_ptr<facebook::react::EventListener> const &)listener;
71
+
67
72
  @end
68
73
 
69
74
  NS_ASSUME_NONNULL_END
@@ -193,4 +193,14 @@ class LayoutAnimationDelegateProxy : public LayoutAnimationStatusDelegate, publi
193
193
  }
194
194
  }
195
195
 
196
+ - (void)addEventListener:(std::shared_ptr<EventListener> const &)listener
197
+ {
198
+ return _scheduler->addEventListener(listener);
199
+ }
200
+
201
+ - (void)removeEventListener:(std::shared_ptr<EventListener> const &)listener
202
+ {
203
+ return _scheduler->removeEventListener(listener);
204
+ }
205
+
196
206
  @end
@@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
19
19
  @class RCTFabricSurface;
20
20
  @class RCTImageLoader;
21
21
  @class RCTMountingManager;
22
+ @class RCTScheduler;
22
23
 
23
24
  /**
24
25
  * Coordinates presenting of React Native Surfaces and represents application
@@ -53,6 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
53
54
  - (void)unregisterSurface:(RCTFabricSurface *)surface;
54
55
 
55
56
  @property (readonly) RCTMountingManager *mountingManager;
57
+ @property (readonly, nullable) RCTScheduler *scheduler;
56
58
 
57
59
  - (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag;
58
60