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,488 @@
#import <React/RCTConversions.h>
#import <cxxreact/ReactNativeVersion.h>
#import <react/renderer/imagemanager/RCTImagePrimitivesConversions.h>
#import "RNSConversions.h"
#import "RNSDefines.h"
namespace rnscreens::conversion {
UIBlurEffect *RNSUIBlurEffectFromOptionalUIBlurEffectStyle(std::optional<UIBlurEffectStyle> &maybeStyle)
{
if (maybeStyle) {
return [UIBlurEffect effectWithStyle:maybeStyle.value()];
}
return nil;
}
std::optional<UIBlurEffectStyle> RNSMaybeUIBlurEffectStyleFromString(NSString *blurEffectString)
{
if ([blurEffectString isEqualToString:@"none"] || [blurEffectString isEqualToString:@"systemDefault"]) {
return std::nullopt;
} else if ([blurEffectString isEqualToString:@"extraLight"]) {
return {UIBlurEffectStyleExtraLight};
} else if ([blurEffectString isEqualToString:@"light"]) {
return {UIBlurEffectStyleLight};
} else if ([blurEffectString isEqualToString:@"dark"]) {
return {UIBlurEffectStyleDark};
} else if ([blurEffectString isEqualToString:@"regular"]) {
return {UIBlurEffectStyleRegular};
} else if ([blurEffectString isEqualToString:@"prominent"]) {
return {UIBlurEffectStyleProminent};
}
#if !TARGET_OS_TV
else if ([blurEffectString isEqualToString:@"systemUltraThinMaterial"]) {
return {UIBlurEffectStyleSystemUltraThinMaterial};
} else if ([blurEffectString isEqualToString:@"systemThinMaterial"]) {
return {UIBlurEffectStyleSystemThinMaterial};
} else if ([blurEffectString isEqualToString:@"systemMaterial"]) {
return {UIBlurEffectStyleSystemMaterial};
} else if ([blurEffectString isEqualToString:@"systemThickMaterial"]) {
return {UIBlurEffectStyleSystemThickMaterial};
} else if ([blurEffectString isEqualToString:@"systemChromeMaterial"]) {
return {UIBlurEffectStyleSystemChromeMaterial};
} else if ([blurEffectString isEqualToString:@"systemUltraThinMaterialLight"]) {
return {UIBlurEffectStyleSystemUltraThinMaterialLight};
} else if ([blurEffectString isEqualToString:@"systemThinMaterialLight"]) {
return {UIBlurEffectStyleSystemThinMaterialLight};
} else if ([blurEffectString isEqualToString:@"systemMaterialLight"]) {
return {UIBlurEffectStyleSystemMaterialLight};
} else if ([blurEffectString isEqualToString:@"systemThickMaterialLight"]) {
return {UIBlurEffectStyleSystemThickMaterialLight};
} else if ([blurEffectString isEqualToString:@"systemChromeMaterialLight"]) {
return {UIBlurEffectStyleSystemChromeMaterialLight};
} else if ([blurEffectString isEqualToString:@"systemUltraThinMaterialDark"]) {
return {UIBlurEffectStyleSystemUltraThinMaterialDark};
} else if ([blurEffectString isEqualToString:@"systemThinMaterialDark"]) {
return {UIBlurEffectStyleSystemThinMaterialDark};
} else if ([blurEffectString isEqualToString:@"systemMaterialDark"]) {
return {UIBlurEffectStyleSystemMaterialDark};
} else if ([blurEffectString isEqualToString:@"systemThickMaterialDark"]) {
return {UIBlurEffectStyleSystemThickMaterialDark};
} else if ([blurEffectString isEqualToString:@"systemChromeMaterialDark"]) {
return {UIBlurEffectStyleSystemChromeMaterialDark};
}
#endif // !TARGET_OS_TV
else {
#if !TARGET_OS_TV
RCTLogError(@"[RNScreens] Unsupported blur effect style: %@", blurEffectString);
#endif // !TARGET_OS_TV
return std::nullopt;
}
}
UIBlurEffect *RNSUIBlurEffectFromString(NSString *blurEffectString)
{
std::optional<UIBlurEffectStyle> maybeStyle = RNSMaybeUIBlurEffectStyleFromString(blurEffectString);
return RNSUIBlurEffectFromOptionalUIBlurEffectStyle(maybeStyle);
}
std::optional<UIBlurEffectStyle> RNSMaybeUIBlurEffectStyleFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect)
{
switch (blurEffect) {
case RNSBlurEffectStyleNone:
case RNSBlurEffectStyleSystemDefault:
return std::nullopt;
case RNSBlurEffectStyleExtraLight:
return {UIBlurEffectStyleExtraLight};
case RNSBlurEffectStyleLight:
return {UIBlurEffectStyleLight};
case RNSBlurEffectStyleDark:
return {UIBlurEffectStyleDark};
case RNSBlurEffectStyleRegular:
return {UIBlurEffectStyleRegular};
case RNSBlurEffectStyleProminent:
return {UIBlurEffectStyleProminent};
#if !TARGET_OS_TV
case RNSBlurEffectStyleSystemUltraThinMaterial:
return {UIBlurEffectStyleSystemUltraThinMaterial};
case RNSBlurEffectStyleSystemThinMaterial:
return {UIBlurEffectStyleSystemThinMaterial};
case RNSBlurEffectStyleSystemMaterial:
return {UIBlurEffectStyleSystemMaterial};
case RNSBlurEffectStyleSystemThickMaterial:
return {UIBlurEffectStyleSystemThickMaterial};
case RNSBlurEffectStyleSystemChromeMaterial:
return {UIBlurEffectStyleSystemChromeMaterial};
case RNSBlurEffectStyleSystemUltraThinMaterialLight:
return {UIBlurEffectStyleSystemUltraThinMaterialLight};
case RNSBlurEffectStyleSystemThinMaterialLight:
return {UIBlurEffectStyleSystemThinMaterialLight};
case RNSBlurEffectStyleSystemMaterialLight:
return {UIBlurEffectStyleSystemMaterialLight};
case RNSBlurEffectStyleSystemThickMaterialLight:
return {UIBlurEffectStyleSystemThickMaterialLight};
case RNSBlurEffectStyleSystemChromeMaterialLight:
return {UIBlurEffectStyleSystemChromeMaterialLight};
case RNSBlurEffectStyleSystemUltraThinMaterialDark:
return {UIBlurEffectStyleSystemUltraThinMaterialDark};
case RNSBlurEffectStyleSystemThinMaterialDark:
return {UIBlurEffectStyleSystemThinMaterialDark};
case RNSBlurEffectStyleSystemMaterialDark:
return {UIBlurEffectStyleSystemMaterialDark};
case RNSBlurEffectStyleSystemThickMaterialDark:
return {UIBlurEffectStyleSystemThickMaterialDark};
case RNSBlurEffectStyleSystemChromeMaterialDark:
return {UIBlurEffectStyleSystemChromeMaterialDark};
default:
RCTLogError(@"[RNScreens] unsupported blur effect style");
return std::nullopt;
#else // !TARGET_OS_TV
default:
return std::nullopt;
#endif // !TARGET_OS_TV
}
}
UIBlurEffect *RNSUIBlurEffectFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect)
{
std::optional<UIBlurEffectStyle> maybeStyle = RNSMaybeUIBlurEffectStyleFromRNSBlurEffectStyle(blurEffect);
return RNSUIBlurEffectFromOptionalUIBlurEffectStyle(maybeStyle);
}
#if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
#if RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
UITabBarMinimizeBehavior UITabBarMinimizeBehaviorFromRNSBottomTabsTabBarMinimizeBehavior(
react::RNSBottomTabsTabBarMinimizeBehavior tabBarMinimizeBehavior)
{
using enum facebook::react::RNSBottomTabsTabBarMinimizeBehavior;
switch (tabBarMinimizeBehavior) {
case Never:
return UITabBarMinimizeBehaviorNever;
case OnScrollDown:
return UITabBarMinimizeBehaviorOnScrollDown;
case OnScrollUp:
return UITabBarMinimizeBehaviorOnScrollUp;
default:
return UITabBarMinimizeBehaviorAutomatic;
}
}
#else // RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
UITabBarMinimizeBehavior UITabBarMinimizeBehaviorFromRNSTabBarMinimizeBehavior(
RNSTabBarMinimizeBehavior tabBarMinimizeBehavior)
{
switch (tabBarMinimizeBehavior) {
case RNSTabBarMinimizeBehaviorNever:
return UITabBarMinimizeBehaviorNever;
case RNSTabBarMinimizeBehaviorOnScrollDown:
return UITabBarMinimizeBehaviorOnScrollDown;
case RNSTabBarMinimizeBehaviorOnScrollUp:
return UITabBarMinimizeBehaviorOnScrollUp;
default:
return UITabBarMinimizeBehaviorAutomatic;
}
}
#endif // RCT_NEW_ARCH_ENABLED
#endif // Check for iOS >= 26
#if RNS_IPHONE_OS_VERSION_AVAILABLE(18_0)
#if RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(18.0))
UITabBarControllerMode UITabBarControllerModeFromRNSBottomTabsTabBarControllerMode(
react::RNSBottomTabsTabBarControllerMode tabBarControllerMode)
{
using enum facebook::react::RNSBottomTabsTabBarControllerMode;
switch (tabBarControllerMode) {
case Automatic:
return UITabBarControllerModeAutomatic;
case TabBar:
return UITabBarControllerModeTabBar;
case TabSidebar:
return UITabBarControllerModeTabSidebar;
default:
return UITabBarControllerModeAutomatic;
}
}
#else // RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(18.0))
UITabBarControllerMode UITabBarControllerModeFromRNSTabBarControllerMode(RNSTabBarControllerMode tabBarDisplayMode)
{
switch (tabBarDisplayMode) {
case RNSTabBarControllerModeAutomatic:
return UITabBarControllerModeAutomatic;
case RNSTabBarControllerModeTabBar:
return UITabBarControllerModeTabBar;
case RNSTabBarControllerModeTabSidebar:
return UITabBarControllerModeTabSidebar;
default:
return UITabBarControllerModeAutomatic;
}
}
#endif // RCT_NEW_ARCH_ENABLED
#endif // Check for iOS >= 18
RNSBottomTabsIconType RNSBottomTabsIconTypeFromIcon(react::RNSBottomTabsScreenIconType iconType)
{
using enum facebook::react::RNSBottomTabsScreenIconType;
switch (iconType) {
case Image:
return RNSBottomTabsIconTypeImage;
case Template:
return RNSBottomTabsIconTypeTemplate;
case SfSymbol:
return RNSBottomTabsIconTypeSfSymbol;
case Xcasset:
return RNSBottomTabsIconTypeXcasset;
}
}
RCTImageSource *RCTImageSourceFromImageSourceAndIconType(
const facebook::react::ImageSource *imageSource,
RNSBottomTabsIconType iconType)
{
RCTImageSource *iconImageSource;
switch (iconType) {
case RNSBottomTabsIconTypeSfSymbol:
iconImageSource = nil;
break;
case RNSBottomTabsIconTypeImage:
case RNSBottomTabsIconTypeTemplate:
iconImageSource =
[[RCTImageSource alloc] initWithURLRequest:NSURLRequestFromImageSource(*imageSource)
size:CGSizeMake(imageSource->size.width, imageSource->size.height)
scale:imageSource->scale];
break;
default:
RCTLogError(@"[RNScreens] unsupported icon type");
}
return iconImageSource;
}
RNSOrientation RNSOrientationFromRNSBottomTabsScreenOrientation(react::RNSBottomTabsScreenOrientation orientation)
{
using enum facebook::react::RNSBottomTabsScreenOrientation;
switch (orientation) {
case Inherit:
return RNSOrientationInherit;
case All:
return RNSOrientationAll;
case AllButUpsideDown:
return RNSOrientationAllButUpsideDown;
case Portrait:
return RNSOrientationPortrait;
case PortraitUp:
return RNSOrientationPortraitUp;
case PortraitDown:
return RNSOrientationPortraitDown;
case Landscape:
return RNSOrientationLandscape;
case LandscapeLeft:
return RNSOrientationLandscapeLeft;
case LandscapeRight:
return RNSOrientationLandscapeRight;
default:
RCTLogError(@"[RNScreens] unsupported orientation");
return RNSOrientationInherit;
}
}
RNSBottomTabsScreenSystemItem RNSBottomTabsScreenSystemItemFromReactRNSBottomTabsScreenSystemItem(
react::RNSBottomTabsScreenSystemItem systemItem)
{
using enum facebook::react::RNSBottomTabsScreenSystemItem;
switch (systemItem) {
case None:
return RNSBottomTabsScreenSystemItemNone;
case Bookmarks:
return RNSBottomTabsScreenSystemItemBookmarks;
case Contacts:
return RNSBottomTabsScreenSystemItemContacts;
case Downloads:
return RNSBottomTabsScreenSystemItemDownloads;
case Favorites:
return RNSBottomTabsScreenSystemItemFavorites;
case Featured:
return RNSBottomTabsScreenSystemItemFeatured;
case History:
return RNSBottomTabsScreenSystemItemHistory;
case More:
return RNSBottomTabsScreenSystemItemMore;
case MostRecent:
return RNSBottomTabsScreenSystemItemMostRecent;
case MostViewed:
return RNSBottomTabsScreenSystemItemMostViewed;
case Recents:
return RNSBottomTabsScreenSystemItemRecents;
case Search:
return RNSBottomTabsScreenSystemItemSearch;
case TopRated:
return RNSBottomTabsScreenSystemItemTopRated;
default:
RCTLogError(@"[RNScreens] unsupported bottom tabs screen systemItem");
return RNSBottomTabsScreenSystemItemNone;
}
}
UITabBarSystemItem RNSBottomTabsScreenSystemItemToUITabBarSystemItem(RNSBottomTabsScreenSystemItem systemItem)
{
RCTAssert(
systemItem != RNSBottomTabsScreenSystemItemNone,
@"Attempt to convert bottom tabs systemItem none to UITabBarSystemItem");
switch (systemItem) {
case RNSBottomTabsScreenSystemItemBookmarks:
return UITabBarSystemItemBookmarks;
case RNSBottomTabsScreenSystemItemContacts:
return UITabBarSystemItemContacts;
case RNSBottomTabsScreenSystemItemDownloads:
return UITabBarSystemItemDownloads;
case RNSBottomTabsScreenSystemItemFavorites:
return UITabBarSystemItemFavorites;
case RNSBottomTabsScreenSystemItemFeatured:
return UITabBarSystemItemFeatured;
case RNSBottomTabsScreenSystemItemHistory:
return UITabBarSystemItemHistory;
case RNSBottomTabsScreenSystemItemMore:
return UITabBarSystemItemMore;
case RNSBottomTabsScreenSystemItemMostRecent:
return UITabBarSystemItemMostRecent;
case RNSBottomTabsScreenSystemItemMostViewed:
return UITabBarSystemItemMostViewed;
case RNSBottomTabsScreenSystemItemRecents:
return UITabBarSystemItemRecents;
case RNSBottomTabsScreenSystemItemSearch:
return UITabBarSystemItemSearch;
case RNSBottomTabsScreenSystemItemTopRated:
return UITabBarSystemItemTopRated;
}
RCTAssert(true, @"Attempt to convert unknown bottom tabs screen systemItem to UITabBarSystemItem [%d]", systemItem);
return UITabBarSystemItemSearch;
}
#define SWITCH_EDGE_EFFECT(X) \
switch (edgeEffect) { \
using enum react::X; \
case Automatic: \
return RNSScrollEdgeEffectAutomatic; \
case Hard: \
return RNSScrollEdgeEffectHard; \
case Soft: \
return RNSScrollEdgeEffectSoft; \
case Hidden: \
return RNSScrollEdgeEffectHidden; \
default: \
RCTLogError(@"[RNScreens] unsupported edge effect"); \
return RNSScrollEdgeEffectAutomatic; \
}
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenBottomScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenBottomScrollEdgeEffect edgeEffect)
{
SWITCH_EDGE_EFFECT(RNSBottomTabsScreenBottomScrollEdgeEffect);
}
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenLeftScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenLeftScrollEdgeEffect edgeEffect)
{
SWITCH_EDGE_EFFECT(RNSBottomTabsScreenLeftScrollEdgeEffect);
}
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenRightScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenRightScrollEdgeEffect edgeEffect)
{
SWITCH_EDGE_EFFECT(RNSBottomTabsScreenRightScrollEdgeEffect);
}
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenTopScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenTopScrollEdgeEffect edgeEffect)
{
SWITCH_EDGE_EFFECT(RNSBottomTabsScreenTopScrollEdgeEffect);
}
#undef SWITCH_EDGE_EFFECT
#if RNS_BOTTOM_ACCESSORY_AVAILABLE
#if RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
std::optional<react::RNSBottomTabsAccessoryEventEmitter::OnEnvironmentChangeEnvironment>
RNSBottomTabsAccessoryOnEnvironmentChangePayloadFromUITabAccessoryEnvironment(UITabAccessoryEnvironment environment)
{
switch (environment) {
case UITabAccessoryEnvironmentRegular:
return react::RNSBottomTabsAccessoryEventEmitter::OnEnvironmentChangeEnvironment::Regular;
case UITabAccessoryEnvironmentInline:
return react::RNSBottomTabsAccessoryEventEmitter::OnEnvironmentChangeEnvironment::Inline;
default:
// We want to ignore other environments (e.g. `none`), that's why there is no warning here.
return std::nullopt;
}
}
#if REACT_NATIVE_VERSION_MINOR >= 82
RNSBottomTabsAccessoryEnvironment RNSBottomTabsAccessoryEnvironmentFromCppEquivalent(
react::RNSBottomTabsAccessoryContentEnvironment environment)
{
using enum react::RNSBottomTabsAccessoryContentEnvironment;
switch (environment) {
case Regular:
return RNSBottomTabsAccessoryEnvironmentRegular;
case Inline:
return RNSBottomTabsAccessoryEnvironmentInline;
default:
RCTLogError(@"[RNScreens] Unsupported BottomTabsAccessory environment");
}
}
#endif // REACT_NATIVE_VERSION_MINOR >= 82
#else // RCT_NEW_ARCH_ENABLED
static NSString *const BOTTOM_TABS_ACCESSORY_REGULAR_ENVIRONMENT = @"regular";
static NSString *const BOTTOM_TABS_ACCESSORY_INLINE_ENVIRONMENT = @"inline";
API_AVAILABLE(ios(26.0))
NSString *RNSBottomTabsAccessoryOnEnvironmentChangePayloadFromUITabAccessoryEnvironment(
UITabAccessoryEnvironment environment)
{
NSString *environmentString;
switch (environment) {
case UITabAccessoryEnvironmentRegular:
environmentString = BOTTOM_TABS_ACCESSORY_REGULAR_ENVIRONMENT;
break;
case UITabAccessoryEnvironmentInline:
environmentString = BOTTOM_TABS_ACCESSORY_INLINE_ENVIRONMENT;
break;
default:
// We want to ignore other environments (e.g. `none`), that's why there is no warning here.
environmentString = nil;
break;
}
return environmentString;
}
#endif // RCT_NEW_ARCH_ENABLED
#endif // RNS_BOTTOM_ACCESSORY_AVAILABLE
UIUserInterfaceStyle UIUserInterfaceStyleFromBottomTabsScreenCppEquivalent(
react::RNSBottomTabsScreenUserInterfaceStyle userInterfaceStyle)
{
using enum facebook::react::RNSBottomTabsScreenUserInterfaceStyle;
switch (userInterfaceStyle) {
case Unspecified:
return UIUserInterfaceStyleUnspecified;
case Light:
return UIUserInterfaceStyleLight;
case Dark:
return UIUserInterfaceStyleDark;
default:
RCTLogError(@"[RNScreens] unsupported user interface style");
}
}
}; // namespace rnscreens::conversion

View File

@@ -0,0 +1,47 @@
#import "RNSConversions.h"
namespace rnscreens::conversion {
// copied from FollyConvert.mm
id RNSConvertFollyDynamicToId(const folly::dynamic &dyn)
{
// I could imagine an implementation which avoids copies by wrapping the
// dynamic in a derived class of NSDictionary. We can do that if profiling
// implies it will help.
switch (dyn.type()) {
case folly::dynamic::NULLT:
return nil;
case folly::dynamic::BOOL:
return dyn.getBool() ? @YES : @NO;
case folly::dynamic::INT64:
return @(dyn.getInt());
case folly::dynamic::DOUBLE:
return @(dyn.getDouble());
case folly::dynamic::STRING:
return [[NSString alloc] initWithBytes:dyn.c_str() length:dyn.size() encoding:NSUTF8StringEncoding];
case folly::dynamic::ARRAY: {
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:dyn.size()];
for (const auto &elem : dyn) {
id value = RNSConvertFollyDynamicToId(elem);
if (value) {
[array addObject:value];
}
}
return array;
}
case folly::dynamic::OBJECT: {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()];
for (const auto &elem : dyn.items()) {
id key = RNSConvertFollyDynamicToId(elem.first);
id value = RNSConvertFollyDynamicToId(elem.second);
if (key && value) {
dict[key] = value;
}
}
return dict;
}
}
}
}; // namespace rnscreens::conversion

View File

@@ -0,0 +1,164 @@
#import "RNSConversions.h"
namespace rnscreens::conversion {
#pragma mark SplitViewHost props
UISplitViewControllerSplitBehavior SplitViewPreferredSplitBehaviorFromHostProp(
facebook::react::RNSSplitViewHostPreferredSplitBehavior splitBehavior)
{
using enum facebook::react::RNSSplitViewHostPreferredSplitBehavior;
switch (splitBehavior) {
case Displace:
return UISplitViewControllerSplitBehaviorDisplace;
case Overlay:
return UISplitViewControllerSplitBehaviorOverlay;
case Tile:
return UISplitViewControllerSplitBehaviorTile;
case Automatic:
default:
return UISplitViewControllerSplitBehaviorAutomatic;
}
}
UISplitViewControllerPrimaryEdge SplitViewPrimaryEdgeFromHostProp(
facebook::react::RNSSplitViewHostPrimaryEdge primaryEdge)
{
using enum facebook::react::RNSSplitViewHostPrimaryEdge;
switch (primaryEdge) {
case Trailing:
return UISplitViewControllerPrimaryEdgeTrailing;
case Leading:
default:
return UISplitViewControllerPrimaryEdgeLeading;
}
}
UISplitViewControllerDisplayMode SplitViewPreferredDisplayModeFromHostProp(
facebook::react::RNSSplitViewHostPreferredDisplayMode displayMode)
{
using enum facebook::react::RNSSplitViewHostPreferredDisplayMode;
switch (displayMode) {
case SecondaryOnly:
return UISplitViewControllerDisplayModeSecondaryOnly;
case OneBesideSecondary:
return UISplitViewControllerDisplayModeOneBesideSecondary;
case OneOverSecondary:
return UISplitViewControllerDisplayModeOneOverSecondary;
case TwoBesideSecondary:
return UISplitViewControllerDisplayModeTwoBesideSecondary;
case TwoOverSecondary:
return UISplitViewControllerDisplayModeTwoOverSecondary;
case TwoDisplaceSecondary:
return UISplitViewControllerDisplayModeTwoDisplaceSecondary;
case Automatic:
default:
return UISplitViewControllerDisplayModeAutomatic;
}
}
#if !TARGET_OS_TV
UISplitViewControllerBackgroundStyle SplitViewPrimaryBackgroundStyleFromHostProp(
facebook::react::RNSSplitViewHostPrimaryBackgroundStyle primaryBackgroundStyle)
{
using enum facebook::react::RNSSplitViewHostPrimaryBackgroundStyle;
switch (primaryBackgroundStyle) {
case None:
return UISplitViewControllerBackgroundStyleNone;
case Sidebar:
return UISplitViewControllerBackgroundStyleSidebar;
case Default:
default:
UISplitViewController *tempSplitVC = [[UISplitViewController alloc] init];
return tempSplitVC.primaryBackgroundStyle;
}
}
#endif // !TARGET_OS_TV
UISplitViewControllerDisplayModeButtonVisibility SplitViewDisplayModeButtonVisibilityFromHostProp(
react::RNSSplitViewHostDisplayModeButtonVisibility displayModeButtonVisibility)
{
using enum facebook::react::RNSSplitViewHostDisplayModeButtonVisibility;
switch (displayModeButtonVisibility) {
case Always:
return UISplitViewControllerDisplayModeButtonVisibilityAlways;
case Never:
return UISplitViewControllerDisplayModeButtonVisibilityNever;
case Automatic:
default:
return UISplitViewControllerDisplayModeButtonVisibilityAutomatic;
}
}
std::string UISplitViewControllerDisplayModeToString(UISplitViewControllerDisplayMode displayMode)
{
switch (displayMode) {
case UISplitViewControllerDisplayModeSecondaryOnly:
return "secondaryOnly";
case UISplitViewControllerDisplayModeOneBesideSecondary:
return "oneBesideSecondary";
case UISplitViewControllerDisplayModeOneOverSecondary:
return "oneOverSecondary";
case UISplitViewControllerDisplayModeTwoBesideSecondary:
return "twoBesideSecondary";
case UISplitViewControllerDisplayModeTwoOverSecondary:
return "twoOverSecondary";
case UISplitViewControllerDisplayModeTwoDisplaceSecondary:
return "twoDisplaceSecondary";
case UISplitViewControllerDisplayModeAutomatic:
default:
return "automatic";
}
}
RNSOrientation RNSOrientationFromRNSSplitViewHostOrientation(react::RNSSplitViewHostOrientation orientation)
{
using enum facebook::react::RNSSplitViewHostOrientation;
switch (orientation) {
case Inherit:
return RNSOrientationInherit;
case All:
return RNSOrientationAll;
case AllButUpsideDown:
return RNSOrientationAllButUpsideDown;
case Portrait:
return RNSOrientationPortrait;
case PortraitUp:
return RNSOrientationPortraitUp;
case PortraitDown:
return RNSOrientationPortraitDown;
case Landscape:
return RNSOrientationLandscape;
case LandscapeLeft:
return RNSOrientationLandscapeLeft;
case LandscapeRight:
return RNSOrientationLandscapeRight;
default:
RCTLogError(@"[RNScreens] unsupported orientation");
return RNSOrientationInherit;
}
}
#pragma mark SplitViewScreen props
RNSSplitViewScreenColumnType RNSSplitViewScreenColumnTypeFromScreenProp(
facebook::react::RNSSplitViewScreenColumnType columnType)
{
using enum facebook::react::RNSSplitViewScreenColumnType;
switch (columnType) {
case Inspector:
return RNSSplitViewScreenColumnTypeInspector;
case Column:
default:
return RNSSplitViewScreenColumnTypeColumn;
}
}
}; // namespace rnscreens::conversion

View File

@@ -0,0 +1,23 @@
#pragma once
#if RCT_NEW_ARCH_ENABLED && RNS_GAMMA_ENABLED
#import <react/renderer/components/rnscreens/Props.h>
#import "RNSStackScreenComponentView.h"
#import "always_false.h"
namespace rnscreens::conversion {
template <typename TargetType, typename InputType>
TargetType convert(InputType) {
static_assert(
rnscreens::always_false<TargetType>::value,
"[RNScreens] Missing template specialisation for demanded types!");
}
template <>
RNSStackScreenActivityMode convert(react::RNSStackScreenActivityMode mode);
}; // namespace rnscreens::conversion
#endif // RCT_NEW_ARCH_ENABLED && RNS_GAMMA_ENABLED

View File

@@ -0,0 +1,17 @@
#import "RNSConversions-Stack.h"
#if RCT_NEW_ARCH_ENABLED && RNS_GAMMA_ENABLED
namespace rnscreens::conversion {
namespace react = facebook::react;
template <>
RNSStackScreenActivityMode convert(react::RNSStackScreenActivityMode mode)
{
return static_cast<RNSStackScreenActivityMode>(mode);
};
}; // namespace rnscreens::conversion
#endif // RCT_NEW_ARCH_ENABLED && RNS_GAMMA_ENABLED

View File

@@ -0,0 +1,144 @@
#pragma once
#if defined(__cplusplus)
#import <React/RCTImageSource.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import "RNSDefines.h"
#import "RNSEnums.h"
#if RCT_NEW_ARCH_ENABLED
#import <folly/dynamic.h>
#endif // RCT_NEW_ARCH_ENABLED
namespace rnscreens::conversion {
namespace react = facebook::react;
#if RCT_NEW_ARCH_ENABLED
// copied from FollyConvert.mm
id RNSConvertFollyDynamicToId(const folly::dynamic &dyn);
#endif // RCT_NEW_ARCH_ENABLED
std::optional<UIBlurEffectStyle> RNSMaybeUIBlurEffectStyleFromString(NSString *blurEffectString);
UIBlurEffect *RNSUIBlurEffectFromString(NSString *blurEffectString);
std::optional<UIBlurEffectStyle> RNSMaybeUIBlurEffectStyleFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect);
UIBlurEffect *RNSUIBlurEffectFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect);
#if RNS_IPHONE_OS_VERSION_AVAILABLE(26_0)
#if RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
UITabBarMinimizeBehavior UITabBarMinimizeBehaviorFromRNSBottomTabsTabBarMinimizeBehavior(
react::RNSBottomTabsTabBarMinimizeBehavior tabBarMinimizeBehavior);
#else // RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
UITabBarMinimizeBehavior UITabBarMinimizeBehaviorFromRNSTabBarMinimizeBehavior(
RNSTabBarMinimizeBehavior tabBarMinimizeBehavior);
#endif // RCT_NEW_ARCH_ENABLED
#endif // Check for iOS >= 26
#if RNS_IPHONE_OS_VERSION_AVAILABLE(18_0)
#if RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(18.0))
UITabBarControllerMode UITabBarControllerModeFromRNSBottomTabsTabBarControllerMode(
react::RNSBottomTabsTabBarControllerMode tabBarControllerMode);
#else // RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(18.0))
UITabBarControllerMode UITabBarControllerModeFromRNSTabBarControllerMode(RNSTabBarControllerMode tabBarControllerMode);
#endif // RCT_NEW_ARCH_ENABLED
#endif // Check for iOS >= 18
RNSBottomTabsIconType RNSBottomTabsIconTypeFromIcon(react::RNSBottomTabsScreenIconType iconType);
RNSBottomTabsScreenSystemItem RNSBottomTabsScreenSystemItemFromReactRNSBottomTabsScreenSystemItem(
react::RNSBottomTabsScreenSystemItem systemItem);
UITabBarSystemItem RNSBottomTabsScreenSystemItemToUITabBarSystemItem(RNSBottomTabsScreenSystemItem systemItem);
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenBottomScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenBottomScrollEdgeEffect edgeEffect);
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenLeftScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenLeftScrollEdgeEffect edgeEffect);
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenRightScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenRightScrollEdgeEffect edgeEffect);
RNSScrollEdgeEffect RNSBottomTabsScrollEdgeEffectFromBottomTabsScreenTopScrollEdgeEffectCppEquivalent(
react::RNSBottomTabsScreenTopScrollEdgeEffect edgeEffect);
#if RNS_BOTTOM_ACCESSORY_AVAILABLE
#if RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
std::optional<react::RNSBottomTabsAccessoryEventEmitter::OnEnvironmentChangeEnvironment>
RNSBottomTabsAccessoryOnEnvironmentChangePayloadFromUITabAccessoryEnvironment(UITabAccessoryEnvironment environment);
#if REACT_NATIVE_VERSION_MINOR >= 82
RNSBottomTabsAccessoryEnvironment RNSBottomTabsAccessoryEnvironmentFromCppEquivalent(
react::RNSBottomTabsAccessoryContentEnvironment environment);
#endif // REACT_NATIVE_VERSION_MINOR >= 82
#else // RCT_NEW_ARCH_ENABLED
API_AVAILABLE(ios(26.0))
NSString *_Nullable RNSBottomTabsAccessoryOnEnvironmentChangePayloadFromUITabAccessoryEnvironment(
UITabAccessoryEnvironment environment);
#endif // RCT_NEW_ARCH_ENABLED
#endif // RNS_BOTTOM_ACCESSORY_AVAILABLE
UIUserInterfaceStyle UIUserInterfaceStyleFromBottomTabsScreenCppEquivalent(
react::RNSBottomTabsScreenUserInterfaceStyle userInterfaceStyle);
RCTImageSource *RCTImageSourceFromImageSourceAndIconType(
const facebook::react::ImageSource *imageSource,
RNSBottomTabsIconType iconType);
RNSOrientation RNSOrientationFromRNSBottomTabsScreenOrientation(react::RNSBottomTabsScreenOrientation orientation);
#if !TARGET_OS_TV
UIInterfaceOrientationMask UIInterfaceOrientationMaskFromRNSOrientation(RNSOrientation orientation);
RNSOrientation RNSOrientationFromUIInterfaceOrientationMask(UIInterfaceOrientationMask orientationMask);
#endif // !TARGET_OS_TV
#pragma mark SplitViewHost props
UISplitViewControllerSplitBehavior SplitViewPreferredSplitBehaviorFromHostProp(
react::RNSSplitViewHostPreferredSplitBehavior behavior);
UISplitViewControllerPrimaryEdge SplitViewPrimaryEdgeFromHostProp(react::RNSSplitViewHostPrimaryEdge primaryEdge);
UISplitViewControllerDisplayMode SplitViewPreferredDisplayModeFromHostProp(
react::RNSSplitViewHostPreferredDisplayMode displayMode);
#if !TARGET_OS_TV
UISplitViewControllerBackgroundStyle SplitViewPrimaryBackgroundStyleFromHostProp(
react::RNSSplitViewHostPrimaryBackgroundStyle primaryBackgroundStyle);
#endif // !TARGET_OS_TV
UISplitViewControllerDisplayModeButtonVisibility SplitViewDisplayModeButtonVisibilityFromHostProp(
react::RNSSplitViewHostDisplayModeButtonVisibility displayModeButtonVisibility);
std::string UISplitViewControllerDisplayModeToString(UISplitViewControllerDisplayMode displayMode);
RNSOrientation RNSOrientationFromRNSSplitViewHostOrientation(react::RNSSplitViewHostOrientation orientation);
#pragma mark SplitViewScreen props
RNSSplitViewScreenColumnType RNSSplitViewScreenColumnTypeFromScreenProp(react::RNSSplitViewScreenColumnType columnType);
}; // namespace rnscreens::conversion
#if RCT_NEW_ARCH_ENABLED
#import "RNSConversions-Stack.h"
#endif // RCT_NEW_ARCH_ENABLED
#endif

View File

@@ -0,0 +1,61 @@
#import "RNSConversions.h"
#import <React/RCTLog.h>
namespace rnscreens::conversion {
#if !TARGET_OS_TV
UIInterfaceOrientationMask UIInterfaceOrientationMaskFromRNSOrientation(RNSOrientation orientation)
{
switch (orientation) {
case RNSOrientationAll:
return UIInterfaceOrientationMaskAll;
case RNSOrientationAllButUpsideDown:
return UIInterfaceOrientationMaskAllButUpsideDown;
case RNSOrientationPortrait:
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
case RNSOrientationPortraitUp:
return UIInterfaceOrientationMaskPortrait;
case RNSOrientationPortraitDown:
return UIInterfaceOrientationMaskPortraitUpsideDown;
case RNSOrientationLandscape:
return UIInterfaceOrientationMaskLandscape;
case RNSOrientationLandscapeLeft:
return UIInterfaceOrientationMaskLandscapeLeft;
case RNSOrientationLandscapeRight:
return UIInterfaceOrientationMaskLandscapeRight;
case RNSOrientationInherit:
RCTLogError(@"[RNScreens] RNSOrientationInherit does not map directly to any UIInterfaceOrientationMask");
return 0;
default:
RCTLogError(@"[RNScreens] Unsupported orientation");
return 0;
}
}
RNSOrientation RNSOrientationFromUIInterfaceOrientationMask(UIInterfaceOrientationMask orientationMask)
{
switch (orientationMask) {
case UIInterfaceOrientationMaskAll:
return RNSOrientationAll;
case UIInterfaceOrientationMaskAllButUpsideDown:
return RNSOrientationAllButUpsideDown;
case UIInterfaceOrientationMaskLandscape:
return RNSOrientationLandscape;
case UIInterfaceOrientationMaskLandscapeLeft:
return RNSOrientationLandscapeLeft;
case UIInterfaceOrientationMaskLandscapeRight:
return RNSOrientationLandscapeRight;
case UIInterfaceOrientationMaskPortraitUpsideDown:
return RNSOrientationPortraitDown;
case UIInterfaceOrientationMaskPortrait:
return RNSOrientationPortraitUp;
case UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown:
return RNSOrientationPortrait;
default:
RCTLogError(@"[RNScreens] Unsupported orientation mask");
return RNSOrientationInherit;
}
}
#endif // !TARGET_OS_TV
}; // namespace rnscreens::conversion

View File

@@ -0,0 +1,31 @@
#pragma once
#if defined(__cplusplus)
namespace rnscreens {
namespace do_not_use {
/// This is a marker type, that should never be instantiated.
/// It is here to assert that there is a valid template specialization for
/// `always_false` that can return `true`. Check out this article:
/// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html#valid-workaround
struct DoNotUseThis {
DoNotUseThis() = delete;
DoNotUseThis(const DoNotUseThis &other) = delete;
DoNotUseThis(const DoNotUseThis &&other) = delete;
};
}; // namespace do_not_use
/// Workaround for `static_assert(false)`. See:
/// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html#valid-workaround
/// https://stackoverflow.com/questions/14637356/static-assert-fails-compilation-even-though-template-function-is-called-nowhere/14637534#14637534
template <typename T>
struct always_false : std::false_type {};
template <>
struct always_false<do_not_use::DoNotUseThis> : std::true_type {};
}; // namespace rnscreens
#endif // defined(__cplusplus)