first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#pragma once
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSString (RNSUtility)
+ (BOOL)rnscreens_isBlankOrNull:(NSString *)string;
+ (nullable NSString *)rnscreens_stringOrNilIfBlank:(NSString *)string;
+ (BOOL)rnscreens_isEmptyOrNull:(NSString *)string;
+ (nullable NSString *)rnscreens_stringOrNilIfEmpty:(NSString *)string;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,37 @@
#import "NSString+RNSUtility.h"
@implementation NSString (RNSUtility)
+ (BOOL)rnscreens_isBlankOrNull:(NSString *)string
{
if (string == nil) {
return YES;
}
return [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0;
}
+ (BOOL)rnscreens_isEmptyOrNull:(NSString *)string
{
if (string == nil) {
return YES;
}
return [string length] == 0;
}
+ (nullable NSString *)rnscreens_stringOrNilIfBlank:(NSString *)string
{
if ([NSString rnscreens_isBlankOrNull:string]) {
return nil;
}
return string;
}
+ (nullable NSString *)rnscreens_stringOrNilIfEmpty:(NSString *)string
{
if ([NSString rnscreens_isEmptyOrNull:string]) {
return nil;
}
return string;
}
@end

View File

@@ -0,0 +1,17 @@
#pragma once
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTSurfaceTouchHandler.h>
NS_ASSUME_NONNULL_BEGIN
@interface RCTSurfaceTouchHandler (RNSUtility)
- (void)rnscreens_cancelTouches;
@end
NS_ASSUME_NONNULL_END
#endif // RCT_NEW_ARCH_ENABLED

View File

@@ -0,0 +1,14 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RCTSurfaceTouchHandler+RNSUtility.h"
@implementation RCTSurfaceTouchHandler (RNSUtility)
- (void)rnscreens_cancelTouches
{
[self setEnabled:NO];
[self setEnabled:YES];
[self reset];
}
@end
#endif // RCT_NEW_ARCH_ENABLED

View File

@@ -0,0 +1,17 @@
#pragma once
#ifndef RCT_NEW_ARCH_ENABLED
#import <React/RCTTouchHandler.h>
NS_ASSUME_NONNULL_BEGIN
@interface RCTTouchHandler (RNSUtility)
- (void)rnscreens_cancelTouches;
@end
NS_ASSUME_NONNULL_END
#endif // !RCT_NEW_ARCH_ENABLED

View File

@@ -0,0 +1,15 @@
#ifndef RCT_NEW_ARCH_ENABLED
#import "RCTTouchHandler+RNSUtility.h"
@implementation RCTTouchHandler (RNSUtility)
- (void)rnscreens_cancelTouches
{
[self setEnabled:NO];
[self setEnabled:YES];
[self reset];
}
@end
#endif // !RCT_NEW_ARCH_ENABLED

View File

@@ -0,0 +1,9 @@
#pragma once
#import <UIKit/UIKit.h>
@interface RNSBackBarButtonItem : UIBarButtonItem
@property (nonatomic) BOOL menuHidden;
@end

View File

@@ -0,0 +1,18 @@
#import "./RNSBackBarButtonItem.h"
#import "RNSDefines.h"
@implementation RNSBackBarButtonItem
- (void)setMenuHidden:(BOOL)menuHidden
{
_menuHidden = menuHidden;
}
- (void)setMenu:(UIMenu *)menu
{
if (!_menuHidden) {
super.menu = menu;
}
}
@end

View File

@@ -0,0 +1,52 @@
#pragma once
#pragma mark - Compiler utility
#define RNS_IGNORE_SUPER_CALL_BEGIN \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wobjc-missing-super-calls\"")
#define RNS_IGNORE_SUPER_CALL_END _Pragma("clang diagnostic pop")
#pragma mark - React Native version dependent code
#if defined __has_include
#if __has_include(<React-RCTAppDelegate/RCTReactNativeFactory.h>) ||\
__has_include(<React_RCTAppDelegate/RCTReactNativeFactory.h>) // added in 78; underscore is used in dynamic frameworks
#define RNS_REACT_NATIVE_VERSION_MINOR_BELOW_78 0
#else
#define RNS_REACT_NATIVE_VERSION_MINOR_BELOW_78 1
#endif
#else
#define RNS_REACT_NATIVE_VERSION_MINOR_BELOW_78 \
1 // Wild guess, close eyes and hope for the best.
#endif
#if RNS_REACT_NATIVE_VERSION_MINOR_BELOW_78
#define MUTATION_PARENT_TAG(mutation) mutation.parentShadowView.tag
#else
#define MUTATION_PARENT_TAG(mutation) mutation.parentTag
#endif
#pragma mark - React Native architecture dependent code
#ifdef RCT_NEW_ARCH_ENABLED
#define RNS_REACT_SCROLL_VIEW_COMPONENT RCTScrollViewComponentView
#else
#define RNS_REACT_SCROLL_VIEW_COMPONENT RCTScrollView
#endif
#pragma mark - SDK availability utility
#define RNS_IPHONE_OS_VERSION_AVAILABLE(v) \
(defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_##v) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_##v)
#pragma mark - Availability utils
#define RNS_BOTTOM_ACCESSORY_AVAILABLE \
RNS_IPHONE_OS_VERSION_AVAILABLE(26_0) && !TARGET_OS_TV && !TARGET_OS_VISION

10
node_modules/react-native-screens/ios/utils/RNSLog.h generated vendored Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#ifdef RNS_DEBUG_LOGGING
#define RNSLog(...) NSLog(__VA_ARGS__)
#else
// Replace with NOOP
#define RNSLog(...) \
do { \
} while (0)
#endif

View File

@@ -0,0 +1,39 @@
#pragma once
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UINavigationBar (RNSUtility)
/**
* Aims to find main content view of the `UINavigationBar`.
*
* This method relies on internal iOS implementation details (see the implementation)
* and might need patches specific to future iOS versions, in case the view hierarchy inside
* the navigation bar changes.
*
* Tested to work reliably on iOS 18.0, 17.5, 15.5.
*
* @returns `_UINavigationBarContentView` view mounted directly under the navigation bar itself
*/
- (nullable UIView *)rnscreens_findContentView;
/**
* Aims to find the back button wrapper view of the `UINavigationBar`. This is the view that contains
* the back button itself alongside all the margin / padding used to position the back button by the system.
*
* This method relies on internal iOS implementation details (see the implementation)
* and might need patches specific to future iOS versions, in case the view hierarchy inside
* the navigation bar changes.
*
* Tested to work reliably on iOS 18.0, 17.5, 15.5.
*
* @returns `_UIButtonBarButton` view, if present and mounted in anticipated place;
* if the back button is not present, this method returns `nil`.
*/
- (nullable UIView *)rnscreens_findBackButtonWrapperView;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,86 @@
#import "UINavigationBar+RNSUtility.h"
@implementation UINavigationBar (RNSUtility)
- (nullable UIView *)rnscreens_findContentView
{
static Class ContentViewClass = [UINavigationBar rnscreens_getContentViewRuntimeClass];
// Fast path
if (self.subviews.count > 1 && [self.subviews[1] isKindOfClass:ContentViewClass]) {
return self.subviews[1];
}
for (UIView *subview in self.subviews) {
if ([subview isKindOfClass:ContentViewClass]) {
return subview;
}
}
return nil;
}
- (nullable UIView *)rnscreens_findBackButtonWrapperView
{
UIView *contentView = [self rnscreens_findContentView];
return [self rnscreens_findDescendantBackButtonWrapperFromView:contentView];
}
- (nullable UIView *)rnscreens_findDescendantBackButtonWrapperFromView:(nullable UIView *)view
{
static Class BarButtonViewClass = NSClassFromString(@"_UIButtonBarButton");
if (@available(iOS 26.0, *)) {
return [self rnscreens_ios26_findDescendantBackButtonWrapper:BarButtonViewClass fromView:view];
} else {
return [self rnscreens_ios15_findDescendantBackButtonWrapper:BarButtonViewClass fromView:view];
}
}
- (nullable UIView *)rnscreens_ios26_findDescendantBackButtonWrapper:(Class)BarButtonViewClass
fromView:(nullable UIView *)view
{
if (view == nil) {
return nil;
}
if ([view isKindOfClass:BarButtonViewClass]) {
return view;
}
UIView *maybeButtonWrapperView = nil;
for (UIView *subview in view.subviews) {
maybeButtonWrapperView = [self rnscreens_ios26_findDescendantBackButtonWrapper:BarButtonViewClass fromView:subview];
if (maybeButtonWrapperView != nil) {
return maybeButtonWrapperView;
}
}
return nil;
}
- (nullable UIView *)rnscreens_ios15_findDescendantBackButtonWrapper:(Class)BarButtonViewClass
fromView:(nullable UIView *)view
{
if (view == nil) {
return nil;
}
for (UIView *subview in view.subviews) {
if ([subview isKindOfClass:BarButtonViewClass]) {
return subview;
}
}
return nil;
}
+ (Class)rnscreens_getContentViewRuntimeClass
{
if (@available(iOS 26.0, *)) {
return NSClassFromString(@"UIKit.NavigationBarContentView"); // Sampled from iOS 26 Beta (iPhone 16)
}
return NSClassFromString(@"_UINavigationBarContentView"); // Sampled from iOS 17.5 (iPhone 15 Pro)
}
@end

View File

@@ -0,0 +1,25 @@
#pragma once
#import <Foundation/Foundation.h>
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTSurfaceTouchHandler.h>
#else
#import <React/RCTTouchHandler.h>
#endif // RCT_NEW_ARCH_ENABLED
#ifdef RCT_NEW_ARCH_ENABLED
#define RNS_TOUCH_HANDLER_ARCH_TYPE RCTSurfaceTouchHandler
#else
#define RNS_TOUCH_HANDLER_ARCH_TYPE RCTTouchHandler
#endif // RCT_NEW_ARCH_ENABLED
NS_ASSUME_NONNULL_BEGIN
@interface UIView (RNSUtility)
- (nullable RNS_TOUCH_HANDLER_ARCH_TYPE *)rnscreens_findTouchHandlerInAncestorChain;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,57 @@
#import "UIView+RNSUtility.h"
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTSurfaceView.h>
#import "RNSModalScreen.h"
#endif
@implementation UIView (RNSUtility)
- (nullable RNS_TOUCH_HANDLER_ARCH_TYPE *)rnscreens_findTouchHandlerInAncestorChain
{
UIView *parent = self.superview;
#ifdef RCT_NEW_ARCH_ENABLED
// On Fabric there is no view that exposes touchHandler above us in the view hierarchy, however it is still
// utilised. `RCTSurfaceView` should be present above us, which hosts `RCTFabricSurface` instance, which in turn
// hosts `RCTSurfaceTouchHandler` as a private field. When initialised, `RCTSurfaceTouchHandler` is attached to the
// surface view as a gestureRecognizer <- and this is where we can lay our hands on it.
// On Fabric, every screen not mounted under react root view has it's own surface touch handler attached
// (done when the screen is moved to window).
while (parent != nil && ![parent isKindOfClass:RCTSurfaceView.class] &&
![parent isKindOfClass:RNSModalScreen.class]) {
parent = parent.superview;
}
// This could be possible in modal context
if (parent == nil) {
return nil;
}
// Experimentation shows that RCTSurfaceTouchHandler is the only gestureRecognizer registered here,
// so we should not be afraid of any performance hit here.
for (UIGestureRecognizer *recognizer in parent.gestureRecognizers) {
if ([recognizer isKindOfClass:RCTSurfaceTouchHandler.class]) {
return static_cast<RNS_TOUCH_HANDLER_ARCH_TYPE *>(recognizer);
}
}
#else
// On Paper we can access touchHandler hosted by `RCTRootContentView` which should be above ScreenStack
// in view hierarchy.
while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) {
parent = parent.superview;
}
if (parent != nil) {
RCTTouchHandler *touchHandler = [parent performSelector:@selector(touchHandler)];
return static_cast<RNS_TOUCH_HANDLER_ARCH_TYPE *>(touchHandler);
}
#endif // RCT_NEW_ARCH_ENABLED
return nil;
}
@end

View File

@@ -0,0 +1,9 @@
#pragma once
// This field should exist in extension in `RCTImageSource.m`
@interface RCTImageSource (AccessHiddenMembers)
@property (nonatomic, assign) BOOL packagerAsset;
@end