diff --git a/React/Base/macOS/RCTUIKit.m b/React/Base/macOS/RCTUIKit.m index 1729ec896febc6..c5c5f2feb32042 100644 --- a/React/Base/macOS/RCTUIKit.m +++ b/React/Base/macOS/RCTUIKit.m @@ -608,7 +608,7 @@ - (instancetype)initWithFrame:(NSRect)frameRect return self; } -@end // ]TODO(macOS GH#774) +@end // ]TODO(macOS GH#774) @implementation RCTUISwitch diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h index 7bd19f69537162..94e652b30ca0cf 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h @@ -40,7 +40,9 @@ NS_ASSUME_NONNULL_BEGIN * resilient to other code as possible: even if something else nil the delegate, other delegates that were subscribed * via the splitter will continue working. */ +#if !TARGET_OS_OSX // TODO(macOS GH#774) @property (nonatomic, strong, readonly) RCTGenericDelegateSplitter> *delegateSplitter; +#endif // TODO(macOS GH#774) @property (nonatomic, weak) id overridingDelegate; @property (nonatomic, assign) BOOL pinchGestureEnabled; diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm index 02d5f4af0cd1f4..61616d97e38c88 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm @@ -7,12 +7,24 @@ #import "RCTEnhancedScrollView.h" #import - -@interface RCTEnhancedScrollView () +#import +#import + +@interface RCTEnhancedScrollView () < +#if !TARGET_OS_OSX // TODO(macOS GH#774) + UIScrollViewDelegate +#else // [TODO(macOS GH#774) + RCTScrollableProtocol, RCTAutoInsetsProtocol +#endif // ]TODO(macOS GH#774) +> @end @implementation RCTEnhancedScrollView { +#if !TARGET_OS_OSX // TODO(macOS GH#774) __weak id _publicDelegate; +#else // [TODO(macOS GH#774) + __weak id _publicDelegate; +#endif // ]TODO(macOS GH#774) BOOL _isSetContentOffsetDisabled; } @@ -30,6 +42,7 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { +#if !TARGET_OS_OSX // TODO(macOS GH#774) // We set the default behavior to "never" so that iOS // doesn't do weird things to UIScrollView insets automatically // and keeps it as an opt-in behavior. @@ -45,6 +58,7 @@ - (instancetype)initWithFrame:(CGRect)frame [weakSelf setPrivateDelegate:delegate]; }]; [_delegateSplitter addDelegate:self]; +#endif // TODO(macOS GH#774) } return self; @@ -88,6 +102,7 @@ - (void)setContentOffset:(CGPoint)contentOffset RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y")); } +#if !TARGET_OS_OSX // TODO(macOS GH#774) - (BOOL)touchesShouldCancelInContentView:(RCTUIView *)view // TODO(macOS GH#774) { if ([_overridingDelegate respondsToSelector:@selector(touchesShouldCancelInContentView:)]) { @@ -128,6 +143,8 @@ - (void)setDelegate:(id)delegate } } +#endif // TODO(macOS GH#774) + #pragma mark - UIScrollViewDelegate - (void)scrollViewWillEndDragging:(RCTUIScrollView *)scrollView diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index b897d8a8e8b0c8..21c8dce7adcb6d 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -24,7 +24,9 @@ @interface RCTPullToRefreshViewComponentView () (); _props = defaultProps; +#if !TARGET_OS_OSX // TODO(macOS GH#774) _refreshControl = [UIRefreshControl new]; [_refreshControl addTarget:self action:@selector(handleUIControlEventValueChanged) forControlEvents:UIControlEventValueChanged]; +#endif // TODO(macOS GH#774) } return self; @@ -61,11 +65,13 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & auto const &newConcreteProps = *std::static_pointer_cast(props); if (newConcreteProps.refreshing != oldConcreteProps.refreshing) { +#if !TARGET_OS_OSX // TODO(macOS GH#774) if (newConcreteProps.refreshing) { [_refreshControl beginRefreshing]; } else { [_refreshControl endRefreshing]; } +#endif // TODO(macOS GH#774) } BOOL needsUpdateTitle = NO; @@ -97,7 +103,9 @@ - (void)_updateTitle auto const &concreteProps = *std::static_pointer_cast(_props); if (concreteProps.title.empty()) { +#if !TARGET_OS_OSX // TODO(macOS GH#774) _refreshControl.attributedTitle = nil; +#endif // TODO(macOS GH#774) return; } @@ -106,8 +114,10 @@ - (void)_updateTitle attributes[NSForegroundColorAttributeName] = RCTUIColorFromSharedColor(concreteProps.titleColor); } +#if !TARGET_OS_OSX // TODO(macOS GH#774) _refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:RCTNSStringFromString(concreteProps.title) attributes:attributes]; +#endif // TODO(macOS GH#774) } #pragma mark - Attaching & Detaching @@ -132,9 +142,11 @@ - (void)_attach return; } +#if !TARGET_OS_OSX // TODO(macOS GH#774) if (@available(macOS 13.0, *)) { _scrollViewComponentView.scrollView.refreshControl = _refreshControl; } +#endif // TODO(macOS GH#774) } - (void)_detach @@ -144,11 +156,13 @@ - (void)_detach } // iOS requires to end refreshing before unmounting. +#if !TARGET_OS_OSX // TODO(macOS GH#774) [_refreshControl endRefreshing]; if (@available(macOS 13.0, *)) { _scrollViewComponentView.scrollView.refreshControl = nil; } +#endif // TODO(macOS GH#774) _scrollViewComponentView = nil; } @@ -161,11 +175,13 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args - (void)setNativeRefreshing:(BOOL)refreshing { +#if !TARGET_OS_OSX // TODO(macOS GH#774) if (refreshing) { [_refreshControl beginRefreshing]; } else { [_refreshControl endRefreshing]; } +#endif // TODO(macOS GH#774) } #pragma mark - RCTRefreshableProtocol diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h index 33651572822461..cbacc6a0caa974 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h @@ -45,8 +45,10 @@ NS_ASSUME_NONNULL_BEGIN /* * Returns a delegate splitter that can be used to subscribe for UIScrollView delegate. */ +#if !TARGET_OS_OSX // TODO(macOS GH#774) @property (nonatomic, strong, readonly) RCTGenericDelegateSplitter> *scrollViewDelegateSplitter; +#endif // TODO(macOS GH#774) @end diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 4c28bbef2c9cbb..e99f5b7c2b95d0 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -28,6 +28,7 @@ static CGFloat const kClippingLeeway = 44.0; +#if !TARGET_OS_OSX // TODO(macOS GH#774) static UIScrollViewKeyboardDismissMode RCTUIKeyboardDismissModeFromProps(ScrollViewProps const &props) { switch (props.keyboardDismissMode) { @@ -78,9 +79,12 @@ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(RCTUIScrollView *sc userInfo:userInfo]; } } +#endif // TODO(macOS GH#774) @interface RCTScrollViewComponentView () < +#if !TARGET_OS_OSX // TODO(macOS GH#774) UIScrollViewDelegate, +#endif // TODO(macOS GH#774) RCTScrollViewProtocol, RCTScrollableProtocol, RCTEnhancedScrollViewOverridingDelegate> @@ -105,7 +109,7 @@ @implementation RCTScrollViewComponentView { + (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(RCTUIView *)view // TODO(macOS GH#774) { do { - view = view.superview; + view = (RCTUIView *)view.superview; // TODO(macOS GH#774) } while (view != nil && ![view isKindOfClass:[RCTScrollViewComponentView class]]); return (RCTScrollViewComponentView *)view; } @@ -118,7 +122,9 @@ - (instancetype)initWithFrame:(CGRect)frame _scrollView = [[RCTEnhancedScrollView alloc] initWithFrame:self.bounds]; _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; +#if !TARGET_OS_OSX // TODO(macOS GH#774) _scrollView.delaysContentTouches = NO; +#endif // TODO(macOS GH#774) ((RCTEnhancedScrollView *)_scrollView).overridingDelegate = self; _isUserTriggeredScrolling = NO; _shouldUpdateContentInsetAdjustmentBehavior = YES; @@ -126,8 +132,9 @@ - (instancetype)initWithFrame:(CGRect)frame _containerView = [[RCTUIView alloc] initWithFrame:CGRectZero]; // TODO(macOS GH#774) [_scrollView addSubview:_containerView]; - +#if !TARGET_OS_OSX // TODO(macOS GH#774) [self.scrollViewDelegateSplitter addDelegate:self]; +#endif // TODO(macOS GH#774) _scrollEventThrottle = INFINITY; } @@ -139,13 +146,17 @@ - (void)dealloc { // Removing all delegates from the splitter nils the actual delegate which prevents a crash on UIScrollView // deallocation. +#if !TARGET_OS_OSX // TODO(macOS GH#774) [self.scrollViewDelegateSplitter removeAllDelegates]; +#endif // TODO(macOS GH#774) } +#if !TARGET_OS_OSX // TODO(macOS GH#774) - (RCTGenericDelegateSplitter> *)scrollViewDelegateSplitter { return ((RCTEnhancedScrollView *)_scrollView).delegateSplitter; } +#endif // TODO(macOS GH#774) #pragma mark - RCTMountingTransactionObserving @@ -172,7 +183,9 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics : CGAffineTransformMakeScale(-1, 1); _containerView.transform = transform; +#if !TARGET_OS_OSX // TODO(macOS GH#774) _scrollView.transform = transform; +#endif // TODO(macOS GH#774) } } @@ -195,19 +208,25 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & // FIXME: Commented props are not supported yet. MAP_SCROLL_VIEW_PROP(alwaysBounceHorizontal); MAP_SCROLL_VIEW_PROP(alwaysBounceVertical); +#if !TARGET_OS_OSX // TODO(macOS GH#774) MAP_SCROLL_VIEW_PROP(bounces); MAP_SCROLL_VIEW_PROP(bouncesZoom); MAP_SCROLL_VIEW_PROP(canCancelContentTouches); +#endif // TODO(macOS GH#774) MAP_SCROLL_VIEW_PROP(centerContent); // MAP_SCROLL_VIEW_PROP(automaticallyAdjustContentInsets); +#if !TARGET_OS_OSX // TODO(macOS GH#774) MAP_SCROLL_VIEW_PROP(decelerationRate); MAP_SCROLL_VIEW_PROP(directionalLockEnabled); MAP_SCROLL_VIEW_PROP(maximumZoomScale); MAP_SCROLL_VIEW_PROP(minimumZoomScale); +#endif // TODO(macOS GH#774) MAP_SCROLL_VIEW_PROP(scrollEnabled); +#if !TARGET_OS_OSX // TODO(macOS GH#774) MAP_SCROLL_VIEW_PROP(pagingEnabled); MAP_SCROLL_VIEW_PROP(pinchGestureEnabled); MAP_SCROLL_VIEW_PROP(scrollsToTop); +#endif // TODO(macOS GH#774) MAP_SCROLL_VIEW_PROP(showsHorizontalScrollIndicator); MAP_SCROLL_VIEW_PROP(showsVerticalScrollIndicator); @@ -216,7 +235,9 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & } if (oldScrollViewProps.indicatorStyle != newScrollViewProps.indicatorStyle) { +#if !TARGET_OS_OSX // TODO(macOS GH#774) _scrollView.indicatorStyle = RCTUIScrollViewIndicatorStyleFromProps(newScrollViewProps); +#endif // TODO(macOS GH#774) } if (oldScrollViewProps.scrollEventThrottle != newScrollViewProps.scrollEventThrottle) { @@ -260,6 +281,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & scrollView.snapToOffsets = snapToOffsets; } +#if !TARGET_OS_OSX // TODO(macOS GH#774) if (@available(iOS 13.0, *)) { if (oldScrollViewProps.automaticallyAdjustsScrollIndicatorInsets != newScrollViewProps.automaticallyAdjustsScrollIndicatorInsets) { @@ -282,12 +304,15 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & } _shouldUpdateContentInsetAdjustmentBehavior = NO; } - +#endif // TODO(macOS GH#774) + MAP_SCROLL_VIEW_PROP(disableIntervalMomentum); MAP_SCROLL_VIEW_PROP(snapToInterval); if (oldScrollViewProps.keyboardDismissMode != newScrollViewProps.keyboardDismissMode) { +#if !TARGET_OS_OSX // TODO(macOS GH#774) scrollView.keyboardDismissMode = RCTUIKeyboardDismissModeFromProps(newScrollViewProps); +#endif // TODO(macOS GH#774) } [super updateProps:props oldProps:oldProps]; @@ -350,7 +375,7 @@ - (void)unmountChildComponentView:(RCTUIView *)childCo */ - (BOOL)_shouldDisableScrollInteraction { - RCTUIView *ancestorView = self.superview; // TODO(macOS GH#774) + RCTUIView *ancestorView = (RCTUIView *)self.superview; // TODO(macOS GH#774) while (ancestorView) { if ([ancestorView respondsToSelector:@selector(isJSResponder)]) { @@ -360,7 +385,7 @@ - (BOOL)_shouldDisableScrollInteraction } } - ancestorView = ancestorView.superview; + ancestorView = (RCTUIView *)ancestorView.superview; } return NO; @@ -397,7 +422,9 @@ - (void)prepareForRecycle // We set the default behavior to "never" so that iOS // doesn't do weird things to UIScrollView insets automatically // and keeps it as an opt-in behavior. +#if !TARGET_OS_OSX // TODO(macOS GH#774) _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; +#endif // TODO(macOS GH#774) _shouldUpdateContentInsetAdjustmentBehavior = YES; _state.reset(); _isUserTriggeredScrolling = NO; @@ -428,8 +455,9 @@ - (void)scrollViewDidScroll:(RCTUIScrollView *)scrollView // TODO(macOS GH#774) if (_eventEmitter) { std::static_pointer_cast(_eventEmitter)->onScroll([self _scrollViewMetrics]); } - +#if !TARGET_OS_OSX // TODO(macOS GH#774) RCTSendScrollEventForNativeAnimations_DEPRECATED(scrollView, self.tag); +#endif // TODO(macOS GH#774) } [self _remountChildrenIfNeeded]; @@ -563,7 +591,9 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args - (void)flashScrollIndicators { +#if !TARGET_OS_OSX // TODO(macOS GH#774) [_scrollView flashScrollIndicators]; +#endif // TODO(macOS GH#774) } - (void)scrollTo:(double)x y:(double)y animated:(BOOL)animated @@ -631,8 +661,10 @@ - (void)_remountChildrenIfNeeded - (void)_remountChildren { +#if !TARGET_OS_OSX // TODO(macOS GH#774) [_scrollView updateClippedSubviewsWithClipRect:CGRectInset(_scrollView.bounds, -kClippingLeeway, -kClippingLeeway) relativeToView:_scrollView]; +#endif // TODO(macOS GH#774) } #pragma mark - RCTScrollableProtocol @@ -660,7 +692,9 @@ - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated offset.x = self.contentSize.width - _scrollView.frame.size.width - offset.x; } +#if !TARGET_OS_OSX // TODO(macOS GH#774) [_scrollView setContentOffset:offset animated:animated]; +#endif // TODO(macOS GH#774) if (!animated) { // When not animated, the expected workflow in ``scrollViewDidEndScrollingAnimation`` after scrolling is not going @@ -671,9 +705,12 @@ - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated { +#if !TARGET_OS_OSX // TODO(macOS GH#774) [_scrollView zoomToRect:rect animated:animated]; +#endif // TODO(macOS GH#774) } +#if !TARGET_OS_OSX // TODO(macOS GH#774) - (void)addScrollListener:(NSObject *)scrollListener { [self.scrollViewDelegateSplitter addDelegate:scrollListener]; @@ -683,6 +720,7 @@ - (void)removeScrollListener:(NSObject *)scrollListener { [self.scrollViewDelegateSplitter removeDelegate:scrollListener]; } +#endif // TODO(macOS GH#774) @end