mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Compile out more unsupported UIKit APIs (#55213)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55213 Compiling out some various unsupported UIKit APIs. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D90825451 fbshipit-source-id: ee88cc3937c5e17540a2951b39a354f297dd3c41
This commit is contained in:
1 parent
7b0dbc1a66
commit
87d3a19735
8 files changed
+51
-5
No files matched your search
@@ -311,10 +311,12 @@ void RCTUnsafeExecuteOnMainQueueSync(dispatch_block_t block)
|
||||
return;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
if (ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS()) {
|
||||
unsafeExecuteOnMainThreadSync(block);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
block();
|
||||
@@ -339,10 +341,12 @@ static void RCTUnsafeExecuteOnMainQueueOnceSync(dispatch_once_t *onceToken, disp
|
||||
return;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
if (ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS()) {
|
||||
unsafeExecuteOnMainThreadSync(block);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), executeOnce);
|
||||
}
|
||||
@@ -421,10 +425,9 @@ CGSize RCTViewportSize(void)
|
||||
|
||||
CGSize RCTSwitchSize(void)
|
||||
{
|
||||
// UISwitch is not supported on AppleTV
|
||||
#if TARGET_OS_TV
|
||||
return CGSizeMake(0, 0);
|
||||
#endif
|
||||
#else
|
||||
static CGSize rctSwitchSize;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
@@ -433,6 +436,7 @@ CGSize RCTSwitchSize(void)
|
||||
});
|
||||
});
|
||||
return rctSwitchSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
CGFloat RCTRoundPixelValue(CGFloat value)
|
||||
@@ -642,7 +646,9 @@ UIWindow *__nullable RCTKeyWindow(void)
|
||||
// We have apps internally that might use UIScenes which are not window scenes.
|
||||
// Calling keyWindow on a UIScene which is not a UIWindowScene can cause a crash
|
||||
UIWindowScene *windowScene = (UIWindowScene *)sceneToUse;
|
||||
return windowScene.keyWindow;
|
||||
if (@available(iOS 15.0, tvOS 15.0, *)) {
|
||||
return windowScene.keyWindow;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
@@ -166,9 +166,9 @@ RCT_EXPORT_MODULE()
|
||||
static BOOL RCTIsIPhoneNotched()
|
||||
{
|
||||
static BOOL isIPhoneNotched = NO;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
|
||||
@@ -180,7 +180,11 @@ RCT_EXPORT_MODULE()
|
||||
[_container addGestureRecognizer:self.gestureRecognizer];
|
||||
[_container addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)]];
|
||||
|
||||
#if TARGET_OS_TV
|
||||
_container.backgroundColor = [UIColor whiteColor];
|
||||
#else
|
||||
_container.backgroundColor = [UIColor systemBackgroundColor];
|
||||
#endif
|
||||
}
|
||||
|
||||
return _container;
|
||||
|
||||
+2
@@ -352,9 +352,11 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
||||
MAP_SCROLL_VIEW_PROP(maximumZoomScale);
|
||||
MAP_SCROLL_VIEW_PROP(minimumZoomScale);
|
||||
MAP_SCROLL_VIEW_PROP(scrollEnabled);
|
||||
#if !TARGET_OS_TV
|
||||
MAP_SCROLL_VIEW_PROP(pagingEnabled);
|
||||
MAP_SCROLL_VIEW_PROP(pinchGestureEnabled);
|
||||
MAP_SCROLL_VIEW_PROP(scrollsToTop);
|
||||
#endif
|
||||
MAP_SCROLL_VIEW_PROP(showsHorizontalScrollIndicator);
|
||||
MAP_SCROLL_VIEW_PROP(showsVerticalScrollIndicator);
|
||||
|
||||
|
||||
+15
@@ -34,11 +34,16 @@ using namespace facebook::react;
|
||||
|
||||
@end
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
@interface RCTParagraphComponentView () <UIEditMenuInteractionDelegate>
|
||||
|
||||
@property (nonatomic, nullable) UIEditMenuInteraction *editMenuInteraction API_AVAILABLE(ios(16.0));
|
||||
|
||||
@end
|
||||
#else
|
||||
@interface RCTParagraphComponentView ()
|
||||
@end
|
||||
#endif
|
||||
|
||||
@implementation RCTParagraphComponentView {
|
||||
ParagraphAttributes _paragraphAttributes;
|
||||
@@ -280,6 +285,7 @@ using namespace facebook::react;
|
||||
|
||||
#pragma mark - Context Menu
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
- (void)enableContextMenu
|
||||
{
|
||||
_longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
|
||||
@@ -357,6 +363,15 @@ using namespace facebook::react;
|
||||
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
||||
pasteboard.items = @[ item ];
|
||||
}
|
||||
#else
|
||||
- (void)enableContextMenu
|
||||
{
|
||||
}
|
||||
|
||||
- (void)disableContextMenu
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+6
-1
@@ -378,6 +378,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
||||
|
||||
// `accessibilityShowsLargeContentViewer`
|
||||
if (oldViewProps.accessibilityShowsLargeContentViewer != newViewProps.accessibilityShowsLargeContentViewer) {
|
||||
#if !TARGET_OS_TV
|
||||
if (@available(iOS 13.0, *)) {
|
||||
if (newViewProps.accessibilityShowsLargeContentViewer) {
|
||||
self.showsLargeContentViewer = YES;
|
||||
@@ -387,13 +388,16 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
|
||||
self.showsLargeContentViewer = NO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// `accessibilityLargeContentTitle`
|
||||
if (oldViewProps.accessibilityLargeContentTitle != newViewProps.accessibilityLargeContentTitle) {
|
||||
#if !TARGET_OS_TV
|
||||
if (@available(iOS 13.0, *)) {
|
||||
self.largeContentTitle = RCTNSStringFromStringNilIfEmpty(newViewProps.accessibilityLargeContentTitle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// `accessibilityOrder`
|
||||
@@ -941,7 +945,8 @@ static RCTBorderStyle RCTBorderStyleFromOutlineStyle(OutlineStyle outlineStyle)
|
||||
layer.shadowPath = nil;
|
||||
}
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 /* __IPHONE_17_0 */
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
|
||||
__IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 /* __IPHONE_17_0 */
|
||||
// Stage 1.5. Cursor / Hover Effects
|
||||
if (@available(iOS 17.0, *)) {
|
||||
UIHoverStyle *hoverStyle = nil;
|
||||
|
||||
@@ -33,6 +33,14 @@ static UIViewAnimationOptions UIViewAnimationOptionsFromRCTAnimationType(RCTAnim
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
|
||||
// No-op on tvOS
|
||||
+ (void)initializeStatics
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
// Use a custom initialization function rather than implementing `+initialize` so that we can control
|
||||
// when the initialization code runs. `+initialize` runs immediately before the first message is sent
|
||||
// to the class which may be too late for us. By this time, we may have missed some
|
||||
@@ -54,6 +62,8 @@ static UIViewAnimationOptions UIViewAnimationOptionsFromRCTAnimationType(RCTAnim
|
||||
_currentKeyboardAnimationCurve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
- (instancetype)initWithDuration:(NSTimeInterval)duration
|
||||
delay:(NSTimeInterval)delay
|
||||
property:(NSString *)property
|
||||
|
||||
@@ -393,6 +393,7 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
|
||||
RCTProfileEnd(RCTProfilingBridge(), ^(NSString *result) {
|
||||
NSString *outFile = [NSTemporaryDirectory() stringByAppendingString:@"tmp_trace.json"];
|
||||
[result writeToFile:outFile atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
#if !TARGET_OS_TV
|
||||
UIActivityViewController *activityViewController =
|
||||
[[UIActivityViewController alloc] initWithActivityItems:@[ [NSURL fileURLWithPath:outFile] ]
|
||||
applicationActivities:nil];
|
||||
@@ -409,6 +410,9 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
|
||||
animated:YES
|
||||
completion:nil];
|
||||
});
|
||||
#else
|
||||
RCTProfileControlsWindow.hidden = NO;
|
||||
#endif
|
||||
});
|
||||
} else {
|
||||
RCTProfileInit(RCTProfilingBridge());
|
||||
|
||||
Reference in new issue
Block a user