Skip to content

Commit ba489e9

Browse files
shwantonShawn Dempsey
andcommitted
[Fabric] Convert UIView to RCTUIView shim (microsoft#1524)
* [Fabric] Replace UIKit with RCTUIKit * [Fabric] Convert UIView to RCTUIView shim * Add macOS tags * Add missing tags * Revert "Merge remote-tracking branch 'meta/main' into fabric/rctuiview-shim" This reverts commit 8d36246, reversing changes made to a36200d. * Fix bad merge of meta/main * Actually fix bad merge! Co-authored-by: Shawn Dempsey <shawndempsey@fb.com>
1 parent c4e6c89 commit ba489e9

36 files changed

+115
-114
lines changed

React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020

2121
using namespace facebook::react;
2222

23-
static UIView<RCTBackedTextInputViewProtocol> *_Nullable RCTFindTextInputWithNativeId(UIView *view, NSString *nativeId)
23+
static RCTUIView<RCTBackedTextInputViewProtocol> *_Nullable RCTFindTextInputWithNativeId(RCTUIView *view, NSString *nativeId) // TODO(macOS GH#774)
2424
{
2525
if ([view respondsToSelector:@selector(inputAccessoryViewID)] &&
2626
[view respondsToSelector:@selector(setInputAccessoryView:)]) {
27-
UIView<RCTBackedTextInputViewProtocol> *typed = (UIView<RCTBackedTextInputViewProtocol> *)view;
27+
RCTUIView<RCTBackedTextInputViewProtocol> *typed = (RCTUIView<RCTBackedTextInputViewProtocol> *)view; // TODO(macOS GH#774)
2828
if (!nativeId || [typed.inputAccessoryViewID isEqualToString:nativeId]) {
2929
return typed;
3030
}
3131
}
3232

33-
for (UIView *subview in view.subviews) {
34-
UIView<RCTBackedTextInputViewProtocol> *result = RCTFindTextInputWithNativeId(subview, nativeId);
33+
for (RCTUIView *subview in view.subviews) { // TODO(macOS GH#774)
34+
RCTUIView<RCTBackedTextInputViewProtocol> *result = RCTFindTextInputWithNativeId(subview, nativeId); // TODO(macOS GH#774)
3535
if (result) {
3636
return result;
3737
}
@@ -44,7 +44,7 @@ @implementation RCTInputAccessoryComponentView {
4444
InputAccessoryShadowNode::ConcreteState::Shared _state;
4545
RCTInputAccessoryContentView *_contentView;
4646
RCTSurfaceTouchHandler *_touchHandler;
47-
UIView<RCTBackedTextInputViewProtocol> __weak *_textInput;
47+
RCTUIView<RCTBackedTextInputViewProtocol> __weak *_textInput; // TODO(macOS GH#774)
4848
}
4949

5050
- (instancetype)initWithFrame:(CGRect)frame
@@ -83,7 +83,7 @@ - (BOOL)canBecomeFirstResponder
8383
return true;
8484
}
8585

86-
- (UIView *)inputAccessoryView
86+
- (RCTUIView *)inputAccessoryView // TODO(macOS GH#774)
8787
{
8888
return _contentView;
8989
}
@@ -95,12 +95,12 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
9595
return concreteComponentDescriptorProvider<InputAccessoryComponentDescriptor>();
9696
}
9797

98-
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
98+
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // TODO(macOS GH#774)
9999
{
100100
[_contentView insertSubview:childComponentView atIndex:index];
101101
}
102102

103-
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
103+
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // TODO(macOS GH#774)
104104
{
105105
[childComponentView removeFromSuperview];
106106
}

React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
#import <React/RCTUIKit.h> // TODO(macOS GH#774)
99

10-
@interface RCTInputAccessoryContentView : UIView
10+
@interface RCTInputAccessoryContentView : RCTUIView // TODO(macOS GH#774)
1111

1212
@end

React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#import "RCTInputAccessoryContentView.h"
99

1010
@implementation RCTInputAccessoryContentView {
11-
UIView *_safeAreaContainer;
11+
RCTUIView *_safeAreaContainer; // TODO(macOS GH#774)
1212
NSLayoutConstraint *_heightConstraint;
1313
}
1414

@@ -17,7 +17,7 @@ - (instancetype)init
1717
if (self = [super init]) {
1818
self.autoresizingMask = UIViewAutoresizingFlexibleHeight;
1919

20-
_safeAreaContainer = [UIView new];
20+
_safeAreaContainer = [RCTUIView new]; // TODO(macOS GH#774)
2121
_safeAreaContainer.translatesAutoresizingMaskIntoConstraints = NO;
2222
[self addSubview:_safeAreaContainer];
2323

@@ -40,7 +40,7 @@ - (CGSize)intrinsicContentSize
4040
return CGSizeZero;
4141
}
4242

43-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
43+
- (void)insertSubview:(RCTUIView *)view atIndex:(NSInteger)index // TODO(macOS GH#774)
4444
{
4545
[_safeAreaContainer insertSubview:view atIndex:index];
4646
}

React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
@implementation RCTLegacyViewManagerInteropComponentView {
2424
NSMutableArray<NSDictionary *> *_viewsToBeMounted;
25-
NSMutableArray<UIView *> *_viewsToBeUnmounted;
25+
NSMutableArray<RCTUIView *> *_viewsToBeUnmounted; // TODO(macOS GH#774)
2626
RCTLegacyViewManagerInteropCoordinatorAdapter *_adapter;
2727
LegacyViewManagerInteropShadowNode::ConcreteState::Shared _state;
2828
BOOL _hasInvokedForwardingWarning;
@@ -41,9 +41,9 @@ - (instancetype)initWithFrame:(CGRect)frame
4141
return self;
4242
}
4343

44-
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
44+
- (RCTUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // TODO(macOS GH#774)
4545
{
46-
UIView *result = [super hitTest:point withEvent:event];
46+
RCTUIView *result = [super hitTest:point withEvent:event]; // TODO(macOS GH#774)
4747

4848
if (result == _adapter.paperView) {
4949
return self;
@@ -149,15 +149,15 @@ - (void)prepareForRecycle
149149
[super prepareForRecycle];
150150
}
151151

152-
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
152+
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // TODO(macOS GH#774)
153153
{
154154
[_viewsToBeMounted addObject:@{
155155
kRCTLegacyInteropChildIndexKey : [NSNumber numberWithInteger:index],
156156
kRCTLegacyInteropChildComponentKey : childComponentView
157157
}];
158158
}
159159

160-
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
160+
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // TODO(macOS GH#774)
161161
{
162162
if (_adapter) {
163163
[_adapter.paperView removeReactSubview:childComponentView];
@@ -208,7 +208,7 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
208208

209209
[_viewsToBeMounted removeAllObjects];
210210

211-
for (UIView *view in _viewsToBeUnmounted) {
211+
for (RCTUIView *view in _viewsToBeUnmounted) { // TODO(macOS GH#774)
212212
[_adapter.paperView removeReactSubview:view];
213213
}
214214

React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
1414

1515
- (instancetype)initWithCoordinator:(RCTLegacyViewManagerInteropCoordinator *)coordinator reactTag:(NSInteger)tag;
1616

17-
@property (strong, nonatomic) UIView *paperView;
17+
@property (strong, nonatomic) RCTUIView *paperView; // TODO(macOS GH#774)
1818

1919
@property (nonatomic, copy, nullable) void (^eventInterceptor)(std::string eventName, folly::dynamic event);
2020

React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ - (void)dealloc
2828
[_coordinator removeObserveForTag:_tag];
2929
}
3030

31-
- (UIView *)paperView
31+
- (RCTUIView *)paperView // TODO(macOS GH#774)
3232
{
3333
if (!_paperView) {
3434
_paperView = [_coordinator createPaperViewWithTag:_tag];

React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ @implementation RCTModalHostViewComponentView {
104104
BOOL _shouldAnimatePresentation;
105105
BOOL _shouldPresent;
106106
BOOL _isPresented;
107-
UIView *_modalContentsSnapshot;
107+
RCTUIView *_modalContentsSnapshot; // TODO(macOS GH#774)
108108
}
109109

110110
- (instancetype)initWithFrame:(CGRect)frame
@@ -165,7 +165,7 @@ - (void)ensurePresentedOnlyIfNeeded
165165
_isPresented = NO;
166166
// To animate dismissal of view controller, snapshot of
167167
// view hierarchy needs to be added to the UIViewController.
168-
UIView *snapshot = _modalContentsSnapshot;
168+
RCTUIView *snapshot = _modalContentsSnapshot; // TODO(macOS GH#774)
169169
[self.viewController.view addSubview:snapshot];
170170

171171
[self dismissViewController:self.viewController
@@ -269,12 +269,12 @@ - (void)updateState:(facebook::react::State::Shared const &)state
269269
_state = std::static_pointer_cast<const ModalHostViewShadowNode::ConcreteState>(state);
270270
}
271271

272-
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
272+
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // TODO(macOS GH#774)
273273
{
274274
[self.viewController.view insertSubview:childComponentView atIndex:index];
275275
}
276276

277-
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
277+
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index // TODO(macOS GH#774)
278278
{
279279
[childComponentView removeFromSuperview];
280280
}

React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
1919
*/
2020
@protocol RCTEnhancedScrollViewOverridingDelegate <NSObject>
2121

22-
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
22+
- (BOOL)touchesShouldCancelInContentView:(RCTUIView *)view; // TODO(macOS GH#774)
2323

2424
@end
2525

React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ - (void)setContentOffset:(CGPoint)contentOffset
8888
RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y"));
8989
}
9090

91-
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
91+
- (BOOL)touchesShouldCancelInContentView:(RCTUIView *)view // TODO(macOS GH#774)
9292
{
9393
if ([_overridingDelegate respondsToSelector:@selector(touchesShouldCancelInContentView:)]) {
9494
return [_overridingDelegate touchesShouldCancelInContentView:view];

React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
2828
/*
2929
* Finds and returns the closet RCTScrollViewComponentView component to the given view
3030
*/
31-
+ (nullable RCTScrollViewComponentView *)findScrollViewComponentViewForView:(UIView *)view;
31+
+ (nullable RCTScrollViewComponentView *)findScrollViewComponentViewForView:(RCTUIView *)view; // TODO(macOS GH#774)
3232

3333
/*
3434
* Returns an actual UIScrollView that this component uses under the hood.
@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
4040
* separate component views from auxiliary views to be able to reliably implement pull-to-refresh- and RTL-related
4141
* functionality.
4242
*/
43-
@property (nonatomic, strong, readonly) UIView *containerView;
43+
@property (nonatomic, strong, readonly) RCTUIView *containerView; // TODO(macOS GH#774)
4444

4545
/*
4646
* Returns a delegate splitter that can be used to subscribe for UIScrollView delegate.

0 commit comments

Comments
 (0)