Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions ios/RCTConvert+RNScreens.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <React/RCTConvert.h>

NS_ASSUME_NONNULL_BEGIN

@interface RCTConvert (RNScreens)

@end

NS_ASSUME_NONNULL_END
42 changes: 42 additions & 0 deletions ios/RCTConvert+RNScreens.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#import "RCTConvert+RNScreens.h"
#import "RNSEnums.h"

@implementation RCTConvert (RNScreens)

+ (NSMutableDictionary *)blurEffectsForIOSVersion
{
NSMutableDictionary *blurEffects = [NSMutableDictionary new];
[blurEffects addEntriesFromDictionary:@{
@"none" : @(RNSBlurEffectStyleNone),
@"extraLight" : @(RNSBlurEffectStyleExtraLight),
@"light" : @(RNSBlurEffectStyleLight),
@"dark" : @(RNSBlurEffectStyleDark),
@"regular" : @(RNSBlurEffectStyleRegular),
@"prominent" : @(RNSBlurEffectStyleProminent),
}];

#if !TARGET_OS_TV
[blurEffects addEntriesFromDictionary:@{
@"systemUltraThinMaterial" : @(RNSBlurEffectStyleSystemUltraThinMaterial),
@"systemThinMaterial" : @(RNSBlurEffectStyleSystemThinMaterial),
@"systemMaterial" : @(RNSBlurEffectStyleSystemMaterial),
@"systemThickMaterial" : @(RNSBlurEffectStyleSystemThickMaterial),
@"systemChromeMaterial" : @(RNSBlurEffectStyleSystemChromeMaterial),
@"systemUltraThinMaterialLight" : @(RNSBlurEffectStyleSystemUltraThinMaterialLight),
@"systemThinMaterialLight" : @(RNSBlurEffectStyleSystemThinMaterialLight),
@"systemMaterialLight" : @(RNSBlurEffectStyleSystemMaterialLight),
@"systemThickMaterialLight" : @(RNSBlurEffectStyleSystemThickMaterialLight),
@"systemChromeMaterialLight" : @(RNSBlurEffectStyleSystemChromeMaterialLight),
@"systemUltraThinMaterialDark" : @(RNSBlurEffectStyleSystemUltraThinMaterialDark),
@"systemThinMaterialDark" : @(RNSBlurEffectStyleSystemThinMaterialDark),
@"systemMaterialDark" : @(RNSBlurEffectStyleSystemMaterialDark),
@"systemThickMaterialDark" : @(RNSBlurEffectStyleSystemThickMaterialDark),
@"systemChromeMaterialDark" : @(RNSBlurEffectStyleSystemChromeMaterialDark),
}];
#endif
return blurEffects;
}

RCT_ENUM_CONVERTER(RNSBlurEffectStyle, ([self blurEffectsForIOSVersion]), RNSBlurEffectStyleNone, integerValue)

@end
36 changes: 0 additions & 36 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1180,40 +1180,6 @@ - (void)setLocalData:(NSObject *)localData

@implementation RCTConvert (RNSScreenStackHeader)

+ (NSMutableDictionary *)blurEffectsForIOSVersion
{
NSMutableDictionary *blurEffects = [NSMutableDictionary new];
[blurEffects addEntriesFromDictionary:@{
@"none" : @(RNSBlurEffectStyleNone),
@"extraLight" : @(RNSBlurEffectStyleExtraLight),
@"light" : @(RNSBlurEffectStyleLight),
@"dark" : @(RNSBlurEffectStyleDark),
@"regular" : @(RNSBlurEffectStyleRegular),
@"prominent" : @(RNSBlurEffectStyleProminent),
}];

#if !TARGET_OS_TV
[blurEffects addEntriesFromDictionary:@{
@"systemUltraThinMaterial" : @(RNSBlurEffectStyleSystemUltraThinMaterial),
@"systemThinMaterial" : @(RNSBlurEffectStyleSystemThinMaterial),
@"systemMaterial" : @(RNSBlurEffectStyleSystemMaterial),
@"systemThickMaterial" : @(RNSBlurEffectStyleSystemThickMaterial),
@"systemChromeMaterial" : @(RNSBlurEffectStyleSystemChromeMaterial),
@"systemUltraThinMaterialLight" : @(RNSBlurEffectStyleSystemUltraThinMaterialLight),
@"systemThinMaterialLight" : @(RNSBlurEffectStyleSystemThinMaterialLight),
@"systemMaterialLight" : @(RNSBlurEffectStyleSystemMaterialLight),
@"systemThickMaterialLight" : @(RNSBlurEffectStyleSystemThickMaterialLight),
@"systemChromeMaterialLight" : @(RNSBlurEffectStyleSystemChromeMaterialLight),
@"systemUltraThinMaterialDark" : @(RNSBlurEffectStyleSystemUltraThinMaterialDark),
@"systemThinMaterialDark" : @(RNSBlurEffectStyleSystemThinMaterialDark),
@"systemMaterialDark" : @(RNSBlurEffectStyleSystemMaterialDark),
@"systemThickMaterialDark" : @(RNSBlurEffectStyleSystemThickMaterialDark),
@"systemChromeMaterialDark" : @(RNSBlurEffectStyleSystemChromeMaterialDark),
}];
#endif
return blurEffects;
}

RCT_ENUM_CONVERTER(
UISemanticContentAttribute,
(@{
Expand All @@ -1233,6 +1199,4 @@ + (NSMutableDictionary *)blurEffectsForIOSVersion
UINavigationItemBackButtonDisplayModeDefault,
integerValue)

RCT_ENUM_CONVERTER(RNSBlurEffectStyle, ([self blurEffectsForIOSVersion]), RNSBlurEffectStyleNone, integerValue)

@end
5 changes: 5 additions & 0 deletions ios/bottom-tabs/RNSBottomTabsHostComponentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong, readonly, nullable) UIColor *tabBarBackgroundColor;
@property (nonatomic, strong, readonly, nullable) UIBlurEffect *tabBarBlurEffect;

#if !RCT_NEW_ARCH_ENABLED
- (void)setTabBarBlurEffectFromRNSBlurEffectStyle;
#endif // !RCT_NEW_ARCH_ENABLED

@property (nonatomic, strong, readonly, nullable) UIColor *tabBarTintColor;

@property (nonatomic, strong, readonly, nullable) NSString *tabBarItemTitleFontFamily;
Expand Down
6 changes: 3 additions & 3 deletions ios/bottom-tabs/RNSBottomTabsHostComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ - (void)updateState:(const facebook::react::State::Shared &)state
{
react::RNSBottomTabsShadowNode::ConcreteState::Shared receivedState =
std::static_pointer_cast<const react::RNSBottomTabsShadowNode::ConcreteState>(state);

_imageLoader = [self retrieveImageLoaderFromState:receivedState];
}

Expand Down Expand Up @@ -400,9 +400,9 @@ - (void)setTabBarBackgroundColor:(UIColor *_Nullable)tabBarBackgroundColor
[self invalidateTabBarAppearance];
}

- (void)setTabBarBlurEffect:(UIBlurEffect *_Nullable)tabBarBlurEffect
- (void)setTabBarBlurEffectFromRNSBlurEffectStyle:(RNSBlurEffectStyle)tabBarBlurEffect
{
_tabBarBlurEffect = tabBarBlurEffect;
_tabBarBlurEffect = rnscreens::conversion::RNSUIBlurEffectFromRNSBlurEffectStyle(tabBarBlurEffect);
[self invalidateTabBarAppearance];
}

Expand Down
4 changes: 2 additions & 2 deletions ios/bottom-tabs/RNSBottomTabsHostComponentViewManager.mm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "RNSBottomTabsHostComponentViewManager.h"

#if !RCT_NEW_ARCH_ENABLED
#import "RNSBottomTabsHostComponentView.h"
#import <React/RCTImageLoader.h>
#import "RNSBottomTabsHostComponentView.h"
#endif

@implementation RNSBottomTabsHostComponentViewManager
Expand All @@ -23,7 +23,7 @@ - (UIView *)view
#pragma mark - LEGACY Props

RCT_EXPORT_VIEW_PROPERTY(tabBarBackgroundColor, UIColor);
RCT_EXPORT_VIEW_PROPERTY(tabBarBlurEffect, UIBlurEffect);
RCT_REMAP_VIEW_PROPERTY(tabBarBlurEffect, tabBarBlurEffectFromRNSBlurEffectStyle, RNSBlurEffectStyle);
RCT_EXPORT_VIEW_PROPERTY(tabBarTintColor, UIColor);
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontFamily, NSString);
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontSize, NSNumber);
Expand Down
8 changes: 6 additions & 2 deletions ios/bottom-tabs/RNSBottomTabsScreenComponentView.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#import <React/RCTImageSource.h>
#import "RNSBottomTabsScreenEventEmitter.h"
#import "RNSEnums.h"
#import "RNSReactBaseView.h"
#import "RNSTabBarAppearanceProvider.h"
#import "RNSScrollViewBehaviorOverriding.h"
#import <React/RCTImageSource.h>
#import "RNSTabBarAppearanceProvider.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -45,6 +45,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong, nullable) UIColor *tabBarBackgroundColor;
@property (nonatomic, strong, nullable) UIBlurEffect *tabBarBlurEffect;

#if !RCT_NEW_ARCH_ENABLED
- (void)setTabBarBlurEffectFromRNSBlurEffectStyle;
#endif // !RCT_NEW_ARCH_ENABLED

@property (nonatomic, strong, nullable) NSString *tabBarItemTitleFontFamily;
@property (nonatomic, strong, nullable) NSNumber *tabBarItemTitleFontSize;
@property (nonatomic, strong, nullable) NSString *tabBarItemTitleFontWeight;
Expand Down
14 changes: 7 additions & 7 deletions ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ - (void)resetProps

_overrideScrollViewContentInsetAdjustmentBehavior = YES;
_isOverrideScrollViewContentInsetAdjustmentBehaviorSet = NO;

_iconType = RNSBottomTabsIconTypeSfSymbol;

_iconImageSource = nil;
Expand Down Expand Up @@ -228,18 +228,18 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(&newComponentProps.iconImageSource, _iconType);
tabItemNeedsAppearanceUpdate = YES;
}

if (newComponentProps.iconSfSymbolName != oldComponentProps.iconSfSymbolName) {
_iconSfSymbolName = RCTNSStringFromStringNilIfEmpty(newComponentProps.iconSfSymbolName);
tabItemNeedsAppearanceUpdate = YES;
}

if (newComponentProps.selectedIconImageSource != oldComponentProps.selectedIconImageSource) {
_selectedIconImageSource =
rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(&newComponentProps.selectedIconImageSource, _iconType);
_selectedIconImageSource = rnscreens::conversion::RCTImageSourceFromImageSourceAndIconType(
&newComponentProps.selectedIconImageSource, _iconType);
tabItemNeedsAppearanceUpdate = YES;
}

if (newComponentProps.selectedIconSfSymbolName != oldComponentProps.selectedIconSfSymbolName) {
_selectedIconSfSymbolName = RCTNSStringFromStringNilIfEmpty(newComponentProps.selectedIconSfSymbolName);
tabItemNeedsAppearanceUpdate = YES;
Expand Down Expand Up @@ -366,9 +366,9 @@ - (void)setTabBarBackgroundColor:(UIColor *)tabBarBackgroundColor
_tabItemNeedsAppearanceUpdate = YES;
}

- (void)setTabBarBlurEffect:(UIBlurEffect *)tabBarBlurEffect
- (void)setTabBarBlurEffectFromRNSBlurEffectStyle:(RNSBlurEffectStyle)tabBarBlurEffect
{
_tabBarBlurEffect = tabBarBlurEffect;
_tabBarBlurEffect = rnscreens::conversion::RNSUIBlurEffectFromRNSBlurEffectStyle(tabBarBlurEffect);
_tabItemNeedsAppearanceUpdate = YES;
}

Expand Down
2 changes: 1 addition & 1 deletion ios/bottom-tabs/RNSBottomTabsScreenComponentViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(title, NSString);
RCT_EXPORT_VIEW_PROPERTY(badgeValue, NSString);
RCT_EXPORT_VIEW_PROPERTY(tabBarBackgroundColor, UIColor);
RCT_EXPORT_VIEW_PROPERTY(tabBarBlurEffect, UIBlurEffect); // needs custom conversion, cause it has `none`
RCT_REMAP_VIEW_PROPERTY(tabBarBlurEffect, tabBarBlurEffectFromRNSBlurEffectStyle, RNSBlurEffectStyle);

RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontFamily, NSString);
RCT_EXPORT_VIEW_PROPERTY(tabBarItemTitleFontSize, NSNumber);
Expand Down
91 changes: 83 additions & 8 deletions ios/conversion/RNSConversions-BottomTabs.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,87 @@

namespace rnscreens::conversion {

UIBlurEffect *RNSUIBlurEffectFromOptionalUIBlurEffectStyle(std::optional<UIBlurEffectStyle> &maybeStyle)
{
if (maybeStyle) {
return [UIBlurEffect effectWithStyle:maybeStyle.value()];
}
return nil;
}

std::optional<UIBlurEffectStyle> RNSMaybeUIBlurEffectStyleFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect)
{
#if !TARGET_OS_TV
switch (blurEffect) {
case RNSBlurEffectStyleNone:
return std::nullopt;
case RNSBlurEffectStyleExtraLight:
return {UIBlurEffectStyleExtraLight};
case RNSBlurEffectStyleLight:
return {UIBlurEffectStyleLight};
case RNSBlurEffectStyleDark:
return {UIBlurEffectStyleDark};
case RNSBlurEffectStyleRegular:
return {UIBlurEffectStyleRegular};
case RNSBlurEffectStyleProminent:
return {UIBlurEffectStyleProminent};
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};
}
#endif

switch (blurEffect) {
case RNSBlurEffectStyleNone:
return std::nullopt;
case RNSBlurEffectStyleLight:
return {UIBlurEffectStyleLight};
case RNSBlurEffectStyleDark:
return {UIBlurEffectStyleDark};
case RNSBlurEffectStyleRegular:
return {UIBlurEffectStyleRegular};
case RNSBlurEffectStyleProminent:
return {UIBlurEffectStyleProminent};
case RNSBlurEffectStyleExtraLight:
return {UIBlurEffectStyleExtraLight};
default:
return std::nullopt;
}
}

UIBlurEffect *RNSUIBlurEffectFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect)
{
std::optional<UIBlurEffectStyle> maybeStyle = RNSMaybeUIBlurEffectStyleFromRNSBlurEffectStyle(blurEffect);
return RNSUIBlurEffectFromOptionalUIBlurEffectStyle(maybeStyle);
}

std::optional<UIBlurEffectStyle> RNSMaybeUIBlurEffectStyleFromRNSBottomTabsTabBarBlurEffect(
react::RNSBottomTabsTabBarBlurEffect blurEffect)
{
Expand Down Expand Up @@ -76,10 +157,7 @@
UIBlurEffect *RNSUIBlurEffectFromRNSBottomTabsTabBarBlurEffect(react::RNSBottomTabsTabBarBlurEffect blurEffect)
{
std::optional<UIBlurEffectStyle> maybeStyle = RNSMaybeUIBlurEffectStyleFromRNSBottomTabsTabBarBlurEffect(blurEffect);
if (maybeStyle) {
return [UIBlurEffect effectWithStyle:maybeStyle.value()];
}
return nil;
return RNSUIBlurEffectFromOptionalUIBlurEffectStyle(maybeStyle);
}

UIOffset RNSBottomTabsTabBarItemTitlePositionAdjustmentStruct(
Expand Down Expand Up @@ -162,10 +240,7 @@ UIOffset RNSBottomTabsTabBarItemTitlePositionAdjustmentStruct(
{
std::optional<UIBlurEffectStyle> maybeStyle =
RNSMaybeUIBlurEffectStyleFromRNSBottomTabsScreenTabBarBlurEffect(blurEffect);
if (maybeStyle) {
return [UIBlurEffect effectWithStyle:maybeStyle.value()];
}
return nil;
return RNSUIBlurEffectFromOptionalUIBlurEffectStyle(maybeStyle);
}

UIOffset RNSBottomTabsScreenTabBarItemTitlePositionAdjustmentStruct(
Expand Down
11 changes: 9 additions & 2 deletions ios/conversion/RNSConversions.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#pragma once

#if defined(__cplusplus)
#import <react/renderer/components/rnscreens/Props.h>
#import <React/RCTImageSource.h>
#import <react/renderer/components/rnscreens/Props.h>
#import "RNSEnums.h"

namespace rnscreens::conversion {

namespace react = facebook::react;

std::optional<UIBlurEffectStyle>
RNSMaybeUIBlurEffectStyleFromRNSBlurEffectStyle(RNSBlurEffectStyle blurEffect);

UIBlurEffect *RNSUIBlurEffectFromRNSBlurEffectStyle(
RNSBlurEffectStyle blurEffect);

std::optional<UIBlurEffectStyle>
RNSMaybeUIBlurEffectStyleFromRNSBottomTabsTabBarBlurEffect(
react::RNSBottomTabsTabBarBlurEffect blurEffect);
Expand All @@ -31,7 +37,8 @@ UIOffset RNSBottomTabsScreenTabBarItemTitlePositionAdjustmentStruct(
react::RNSBottomTabsScreenTabBarItemTitlePositionAdjustmentStruct
titlePositionAdjustment);

RNSBottomTabsIconType RNSBottomTabsIconTypeFromIcon(react::RNSBottomTabsScreenIconType iconType);
RNSBottomTabsIconType RNSBottomTabsIconTypeFromIcon(
react::RNSBottomTabsScreenIconType iconType);

RCTImageSource *RCTImageSourceFromImageSourceAndIconType(
const facebook::react::ImageSource *imageSource,
Expand Down
Loading