Skip to content

[Fabric] Convert UIView to RCTUIView shim #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

/**
* UIView class for root <ActivityIndicator> component.
* RCTUIView class for root <ActivityIndicator> component.
*/
@interface RCTActivityIndicatorViewComponentView : RCTViewComponentView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

/**
* UIView class for root <Image> component.
* RCTUIView class for root <Image> component.
*/
@interface RCTImageComponentView : RCTViewComponentView <RCTImageResponseDelegate> {
@protected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

/**
* UIView class for root <InputAccessoryView> component.
* RCTUIView class for root <InputAccessoryView> component.
*/
@interface RCTInputAccessoryComponentView : RCTViewComponentView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@

using namespace facebook::react;

static UIView<RCTBackedTextInputViewProtocol> *_Nullable RCTFindTextInputWithNativeId(UIView *view, NSString *nativeId)
static RCTUIView<RCTBackedTextInputViewProtocol> *_Nullable RCTFindTextInputWithNativeId(RCTUIView *view, NSString *nativeId)
{
if ([view respondsToSelector:@selector(inputAccessoryViewID)] &&
[view respondsToSelector:@selector(setInputAccessoryView:)]) {
UIView<RCTBackedTextInputViewProtocol> *typed = (UIView<RCTBackedTextInputViewProtocol> *)view;
RCTUIView<RCTBackedTextInputViewProtocol> *typed = (RCTUIView<RCTBackedTextInputViewProtocol> *)view;
if (!nativeId || [typed.inputAccessoryViewID isEqualToString:nativeId]) {
return typed;
}
}

for (UIView *subview in view.subviews) {
UIView<RCTBackedTextInputViewProtocol> *result = RCTFindTextInputWithNativeId(subview, nativeId);
for (RCTUIView *subview in view.subviews) {
RCTUIView<RCTBackedTextInputViewProtocol> *result = RCTFindTextInputWithNativeId(subview, nativeId);
if (result) {
return result;
}
Expand All @@ -44,7 +44,7 @@ @implementation RCTInputAccessoryComponentView {
InputAccessoryShadowNode::ConcreteState::Shared _state;
RCTInputAccessoryContentView *_contentView;
RCTSurfaceTouchHandler *_touchHandler;
UIView<RCTBackedTextInputViewProtocol> __weak *_textInput;
RCTUIView<RCTBackedTextInputViewProtocol> __weak *_textInput;
}

- (instancetype)initWithFrame:(CGRect)frame
Expand Down Expand Up @@ -83,7 +83,7 @@ - (BOOL)canBecomeFirstResponder
return true;
}

- (UIView *)inputAccessoryView
- (RCTUIView *)inputAccessoryView
{
return _contentView;
}
Expand All @@ -95,12 +95,12 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
return concreteComponentDescriptorProvider<InputAccessoryComponentDescriptor>();
}

- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[_contentView insertSubview:childComponentView atIndex:index];
}

- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[childComponentView removeFromSuperview];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

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

@interface RCTInputAccessoryContentView : UIView
@interface RCTInputAccessoryContentView : RCTUIView

@end
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "RCTInputAccessoryContentView.h"

@implementation RCTInputAccessoryContentView {
UIView *_safeAreaContainer;
RCTUIView *_safeAreaContainer;
NSLayoutConstraint *_heightConstraint;
}

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

_safeAreaContainer = [UIView new];
_safeAreaContainer = [RCTUIView new];
_safeAreaContainer.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_safeAreaContainer];

Expand All @@ -40,7 +40,7 @@ - (CGSize)intrinsicContentSize
return CGSizeZero;
}

- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
- (void)insertSubview:(RCTUIView *)view atIndex:(NSInteger)index
{
[_safeAreaContainer insertSubview:view atIndex:index];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@implementation RCTLegacyViewManagerInteropComponentView {
NSMutableArray<NSDictionary *> *_viewsToBeMounted;
NSMutableArray<UIView *> *_viewsToBeUnmounted;
NSMutableArray<RCTUIView *> *_viewsToBeUnmounted;
RCTLegacyViewManagerInteropCoordinatorAdapter *_adapter;
LegacyViewManagerInteropShadowNode::ConcreteState::Shared _state;
BOOL _hasInvokedForwardingWarning;
Expand All @@ -41,9 +41,9 @@ - (instancetype)initWithFrame:(CGRect)frame
return self;
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
- (RCTUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *result = [super hitTest:point withEvent:event];
RCTUIView *result = [super hitTest:point withEvent:event];

if (result == _adapter.paperView) {
return self;
Expand Down Expand Up @@ -149,15 +149,15 @@ - (void)prepareForRecycle
[super prepareForRecycle];
}

- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[_viewsToBeMounted addObject:@{
kRCTLegacyInteropChildIndexKey : [NSNumber numberWithInteger:index],
kRCTLegacyInteropChildComponentKey : childComponentView
}];
}

- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
if (_adapter) {
[_adapter.paperView removeReactSubview:childComponentView];
Expand Down Expand Up @@ -208,7 +208,7 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask

[_viewsToBeMounted removeAllObjects];

for (UIView *view in _viewsToBeUnmounted) {
for (RCTUIView *view in _viewsToBeUnmounted) {
[_adapter.paperView removeReactSubview:view];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN

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

@property (strong, nonatomic) UIView *paperView;
@property (strong, nonatomic) RCTUIView *paperView;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ - (void)dealloc
[_coordinator removeObserveForTag:_tag];
}

- (UIView *)paperView
- (RCTUIView *)paperView
{
if (!_paperView) {
_paperView = [_coordinator createPaperViewWithTag:_tag];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <React/RCTViewComponentView.h>

/**
* UIView class for root <ModalHostView> component.
* RCTUIView class for root <ModalHostView> component.
*/
@interface RCTModalHostViewComponentView : RCTViewComponentView <RCTMountingTransactionObserving>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ @implementation RCTModalHostViewComponentView {
BOOL _shouldAnimatePresentation;
BOOL _shouldPresent;
BOOL _isPresented;
UIView *_modalContentsSnapshot;
RCTUIView *_modalContentsSnapshot;
}

- (instancetype)initWithFrame:(CGRect)frame
Expand Down Expand Up @@ -165,7 +165,7 @@ - (void)ensurePresentedOnlyIfNeeded
_isPresented = NO;
// To animate dismissal of view controller, snapshot of
// view hierarchy needs to be added to the UIViewController.
UIView *snapshot = _modalContentsSnapshot;
RCTUIView *snapshot = _modalContentsSnapshot;
[self.viewController.view addSubview:snapshot];

[self dismissViewController:self.viewController
Expand Down Expand Up @@ -198,7 +198,7 @@ - (void)mountingTransactionWillMount:(MountingTransaction const &)transaction
_modalContentsSnapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO];
}

#pragma mark - UIView methods
#pragma mark - RCTUIView methods

- (void)didMoveToWindow
{
Expand Down Expand Up @@ -269,12 +269,12 @@ - (void)updateState:(facebook::react::State::Shared const &)state
_state = std::static_pointer_cast<const ModalHostViewShadowNode::ConcreteState>(state);
}

- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[self.viewController.view insertSubview:childComponentView atIndex:index];
}

- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[childComponentView removeFromSuperview];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

/**
* UIView class for root <View> component.
* RCTUIView class for root <View> component.
*/
@interface RCTRootComponentView : RCTViewComponentView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

/**
* UIView class for root <SafeAreaView> component.
* RCTUIView class for root <SafeAreaView> component.
*/
@interface RCTSafeAreaViewComponentView : RCTViewComponentView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@protocol RCTEnhancedScrollViewOverridingDelegate <NSObject>

- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
- (BOOL)touchesShouldCancelInContentView:(RCTUIView *)view;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ - (void)setContentOffset:(CGPoint)contentOffset
RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y"));
}

- (BOOL)touchesShouldCancelInContentView:(UIView *)view
- (BOOL)touchesShouldCancelInContentView:(RCTUIView *)view
{
if ([_overridingDelegate respondsToSelector:@selector(touchesShouldCancelInContentView:)]) {
return [_overridingDelegate touchesShouldCancelInContentView:view];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

/*
* UIView class for root <PullToRefreshView> component.
* RCTUIView class for root <PullToRefreshView> component.
* This view is designed to only serve ViewController-like purpose for the actual `UIRefreshControl` view which is being
* attached to some `UIScrollView` (not to this view).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
NS_ASSUME_NONNULL_BEGIN

/*
* UIView class for <ScrollView> component.
* RCTUIView class for <ScrollView> component.
*
* By design, the class does not implement any logic that contradicts to the normal behavior of UIScrollView and does
* not contain any special/custom support for things like floating headers, pull-to-refresh components,
Expand All @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
/*
* Finds and returns the closet RCTScrollViewComponentView component to the given view
*/
+ (nullable RCTScrollViewComponentView *)findScrollViewComponentViewForView:(UIView *)view;
+ (nullable RCTScrollViewComponentView *)findScrollViewComponentViewForView:(RCTUIView *)view;

/*
* Returns an actual UIScrollView that this component uses under the hood.
Expand All @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
* separate component views from auxiliary views to be able to reliably implement pull-to-refresh- and RTL-related
* functionality.
*/
@property (nonatomic, strong, readonly) UIView *containerView;
@property (nonatomic, strong, readonly) RCTUIView *containerView;

/*
* Returns a delegate splitter that can be used to subscribe for UIScrollView delegate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ @implementation RCTScrollViewComponentView {
CGPoint _contentOffsetWhenClipped;
}

+ (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view
+ (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(RCTUIView *)view
{
do {
view = view.superview;
Expand All @@ -124,7 +124,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_shouldUpdateContentInsetAdjustmentBehavior = YES;
[self addSubview:_scrollView];

_containerView = [[UIView alloc] initWithFrame:CGRectZero];
_containerView = [[RCTUIView alloc] initWithFrame:CGRectZero];
[_scrollView addSubview:_containerView];

[self.scrollViewDelegateSplitter addDelegate:self];
Expand Down Expand Up @@ -334,12 +334,12 @@ - (void)_preserveContentOffsetIfNeededWithBlock:(void (^)())block
[((RCTEnhancedScrollView *)_scrollView) preserveContentOffsetWithBlock:block];
}

- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[_containerView insertSubview:childComponentView atIndex:index];
}

- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[childComponentView removeFromSuperview];
}
Expand All @@ -350,11 +350,11 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
*/
- (BOOL)_shouldDisableScrollInteraction
{
UIView *ancestorView = self.superview;
RCTUIView *ancestorView = self.superview;

while (ancestorView) {
if ([ancestorView respondsToSelector:@selector(isJSResponder)]) {
BOOL isJSResponder = ((UIView<RCTComponentViewProtocol> *)ancestorView).isJSResponder;
BOOL isJSResponder = ((RCTUIView<RCTComponentViewProtocol> *)ancestorView).isJSResponder;
if (isJSResponder) {
return YES;
}
Expand Down Expand Up @@ -409,7 +409,7 @@ - (void)prepareForRecycle

#pragma mark - UIScrollViewDelegate

- (BOOL)touchesShouldCancelInContentView:(__unused UIView *)view
- (BOOL)touchesShouldCancelInContentView:(__unused RCTUIView *)view
{
// Historically, `UIScrollView`s in React Native do not cancel touches
// started on `UIControl`-based views (as normal iOS `UIScrollView`s do).
Expand Down Expand Up @@ -519,7 +519,7 @@ - (void)_handleFinishedScrolling:(UIScrollView *)scrollView
[self _updateStateWithContentOffset];
}

- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable RCTUIView *)view
{
[self _forceDispatchNextScrollEvent];

Expand All @@ -530,7 +530,7 @@ - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable
std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]);
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable RCTUIView *)view atScale:(CGFloat)scale
{
[self _forceDispatchNextScrollEvent];

Expand All @@ -542,7 +542,7 @@ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UI
[self _updateStateWithContentOffset];
}

- (UIView *)viewForZoomingInScrollView:(__unused UIScrollView *)scrollView
- (RCTUIView *)viewForZoomingInScrollView:(__unused UIScrollView *)scrollView
{
return _containerView;
}
Expand Down Expand Up @@ -610,7 +610,7 @@ - (void)scrollToEnd:(BOOL)animated

#pragma mark - Child views mounting

- (void)updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView:(UIView *)clipView
- (void)updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView:(RCTUIView *)clipView
{
// Do nothing. ScrollView manages its subview clipping individually in `_remountChildren`.
}
Expand Down
Loading