Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
91 changes: 44 additions & 47 deletions ios/RNSConvert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -195,53 +195,50 @@ + (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RN
+ (RNSBlurEffectStyle)RNSBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect
{
using enum react::RNSScreenStackHeaderConfigBlurEffect;
#if !TARGET_OS_TV && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
switch (blurEffect) {
case None:
return RNSBlurEffectStyleNone;
case ExtraLight:
return RNSBlurEffectStyleExtraLight;
case Light:
return RNSBlurEffectStyleLight;
case Dark:
return RNSBlurEffectStyleDark;
case Regular:
return RNSBlurEffectStyleRegular;
case Prominent:
return RNSBlurEffectStyleProminent;
case SystemUltraThinMaterial:
return RNSBlurEffectStyleSystemUltraThinMaterial;
case SystemThinMaterial:
return RNSBlurEffectStyleSystemThinMaterial;
case SystemMaterial:
return RNSBlurEffectStyleSystemMaterial;
case SystemThickMaterial:
return RNSBlurEffectStyleSystemThickMaterial;
case SystemChromeMaterial:
return RNSBlurEffectStyleSystemChromeMaterial;
case SystemUltraThinMaterialLight:
return RNSBlurEffectStyleSystemUltraThinMaterialLight;
case SystemThinMaterialLight:
return RNSBlurEffectStyleSystemThinMaterialLight;
case SystemMaterialLight:
return RNSBlurEffectStyleSystemMaterialLight;
case SystemThickMaterialLight:
return RNSBlurEffectStyleSystemThickMaterialLight;
case SystemChromeMaterialLight:
return RNSBlurEffectStyleSystemChromeMaterialLight;
case SystemUltraThinMaterialDark:
return RNSBlurEffectStyleSystemUltraThinMaterialDark;
case SystemThinMaterialDark:
return RNSBlurEffectStyleSystemThinMaterialDark;
case SystemMaterialDark:
return RNSBlurEffectStyleSystemMaterialDark;
case SystemThickMaterialDark:
return RNSBlurEffectStyleSystemThickMaterialDark;
case SystemChromeMaterialDark:
return RNSBlurEffectStyleSystemChromeMaterialDark;
}
#if !TARGET_OS_TV
switch (blurEffect) {
case None:
return RNSBlurEffectStyleNone;
case ExtraLight:
return RNSBlurEffectStyleExtraLight;
case Light:
return RNSBlurEffectStyleLight;
case Dark:
return RNSBlurEffectStyleDark;
case Regular:
return RNSBlurEffectStyleRegular;
case Prominent:
return RNSBlurEffectStyleProminent;
case SystemUltraThinMaterial:
return RNSBlurEffectStyleSystemUltraThinMaterial;
case SystemThinMaterial:
return RNSBlurEffectStyleSystemThinMaterial;
case SystemMaterial:
return RNSBlurEffectStyleSystemMaterial;
case SystemThickMaterial:
return RNSBlurEffectStyleSystemThickMaterial;
case SystemChromeMaterial:
return RNSBlurEffectStyleSystemChromeMaterial;
case SystemUltraThinMaterialLight:
return RNSBlurEffectStyleSystemUltraThinMaterialLight;
case SystemThinMaterialLight:
return RNSBlurEffectStyleSystemThinMaterialLight;
case SystemMaterialLight:
return RNSBlurEffectStyleSystemMaterialLight;
case SystemThickMaterialLight:
return RNSBlurEffectStyleSystemThickMaterialLight;
case SystemChromeMaterialLight:
return RNSBlurEffectStyleSystemChromeMaterialLight;
case SystemUltraThinMaterialDark:
return RNSBlurEffectStyleSystemUltraThinMaterialDark;
case SystemThinMaterialDark:
return RNSBlurEffectStyleSystemThinMaterialDark;
case SystemMaterialDark:
return RNSBlurEffectStyleSystemMaterialDark;
case SystemThickMaterialDark:
return RNSBlurEffectStyleSystemThickMaterialDark;
case SystemChromeMaterialDark:
return RNSBlurEffectStyleSystemChromeMaterialDark;
}
#endif

Expand Down
35 changes: 6 additions & 29 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,7 @@ - (void)setStackPresentation:(RNSScreenStackPresentation)stackPresentation
{
switch (stackPresentation) {
case RNSScreenStackPresentationModal:
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, tvOS 13.0, *)) {
_controller.modalPresentationStyle = UIModalPresentationAutomatic;
} else {
_controller.modalPresentationStyle = UIModalPresentationFullScreen;
}
#else
_controller.modalPresentationStyle = UIModalPresentationFullScreen;
#endif
_controller.modalPresentationStyle = UIModalPresentationAutomatic;
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_17_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_17_0 && !TARGET_OS_TV
if (@available(iOS 18.0, *)) {
Expand Down Expand Up @@ -337,12 +328,7 @@ - (void)setStackAnimation:(RNSScreenStackAnimation)stackAnimation

- (void)setGestureEnabled:(BOOL)gestureEnabled
{
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, tvOS 13.0, *)) {
_controller.modalInPresentation = !gestureEnabled;
}
#endif
_controller.modalInPresentation = !gestureEnabled;

_gestureEnabled = gestureEnabled;
}
Expand Down Expand Up @@ -753,8 +739,6 @@ - (BOOL)presentationControllerShouldDismiss:(UIPresentationController *)presenta
return _gestureEnabled;
}

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
- (void)presentationControllerDidAttemptToDismiss:(UIPresentationController *)presentationController
{
// NOTE(kkafar): We should consider depracating the use of gesture cancel here & align
Expand All @@ -764,7 +748,6 @@ - (void)presentationControllerDidAttemptToDismiss:(UIPresentationController *)pr
[self notifyDismissCancelledWithDismissCount:1];
}
}
#endif

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
{
Expand Down Expand Up @@ -1572,18 +1555,12 @@ - (CGSize)getStatusBarHeightIsModal:(BOOL)isModal
#if !TARGET_OS_TV && !TARGET_OS_VISION
CGSize fallbackStatusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
CGSize primaryStatusBarSize = self.view.window.windowScene.statusBarManager.statusBarFrame.size;
if (primaryStatusBarSize.height == 0 || primaryStatusBarSize.width == 0)
return fallbackStatusBarSize;

return primaryStatusBarSize;
} else {
CGSize primaryStatusBarSize = self.view.window.windowScene.statusBarManager.statusBarFrame.size;
if (primaryStatusBarSize.height == 0 || primaryStatusBarSize.width == 0) {
return fallbackStatusBarSize;
}
#endif /* Check for iOS 13.0 */

return primaryStatusBarSize;

#else
// TVOS does not have status bar.
Expand Down
11 changes: 3 additions & 8 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,9 @@ - (void)setModalViewControllers:(NSArray<UIViewController *> *)controllers
UIViewController *next = controllers[i];
BOOL lastModal = (i == controllers.count - 1);

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, tvOS 13.0, *)) {
// Inherit UI style from its parent - solves an issue with incorrect style being applied to some UIKit views
// like date picker or segmented control.
next.overrideUserInterfaceStyle = self->_controller.overrideUserInterfaceStyle;
}
#endif
// Inherit UI style from its parent - solves an issue with incorrect style being applied to some UIKit views
// like date picker or segmented control.
next.overrideUserInterfaceStyle = self->_controller.overrideUserInterfaceStyle;

BOOL shouldAnimate = lastModal && [next isKindOfClass:[RNSScreen class]] &&
((RNSScreen *)next).screenView.stackAnimation != RNSScreenStackAnimationNone;
Expand Down
106 changes: 6 additions & 100 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -276,96 +276,9 @@ - (BOOL)shouldBackButtonBeVisibleInNavigationBar:(nullable UINavigationBar *)nav
+ (void)setAnimatedConfig:(UIViewController *)vc withConfig:(RNSScreenStackHeaderConfig *)config
{
UINavigationBar *navbar = ((UINavigationController *)vc.parentViewController).navigationBar;
// It is workaround for loading custom back icon when transitioning from a screen without header to the screen which
// has one. This action fails when navigating to the screen with header for the second time and loads default back
// button. It looks like changing the tint color of navbar triggers an update of the items belonging to it and it
// seems to load the custom back image so we change the tint color's alpha by a very small amount and then set it to
// the one it should have.
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_14_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
// it brakes the behavior of `headerRight` in iOS 14, where the bug desribed above seems to be fixed, so we do nothing
// in iOS 14
if (@available(iOS 14.0, *)) {
} else
#endif
{
[navbar setTintColor:[config.color colorWithAlphaComponent:CGColorGetAlpha(config.color.CGColor) - 0.01]];
}
[navbar setTintColor:config.color];

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
// font customized on the navigation item level, so nothing to do here
} else
#endif
{
BOOL hideShadow = config.hideShadow;

if (config.backgroundColor && CGColorGetAlpha(config.backgroundColor.CGColor) == 0.) {
[navbar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[navbar setBarTintColor:[UIColor clearColor]];
hideShadow = YES;
} else {
[navbar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[navbar setBarTintColor:config.backgroundColor];
}
[navbar setTranslucent:config.translucent];
[navbar setValue:@(hideShadow ? YES : NO) forKey:@"hidesShadow"];

if (config.titleFontFamily || config.titleFontSize || config.titleFontWeight || config.titleColor) {
NSMutableDictionary *attrs = [NSMutableDictionary new];

if (config.titleColor) {
attrs[NSForegroundColorAttributeName] = config.titleColor;
}

NSString *family = config.titleFontFamily ?: nil;
NSNumber *size = config.titleFontSize ?: @17;
NSString *weight = config.titleFontWeight ?: nil;
if (family || weight) {
attrs[NSFontAttributeName] = [RCTFont updateFont:nil
withFamily:family
size:size
weight:weight
style:nil
variant:nil
scaleMultiplier:1.0];
} else {
attrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:[size floatValue]];
}
[navbar setTitleTextAttributes:attrs];
}

#if !TARGET_OS_TV && !TARGET_OS_VISION
if (@available(iOS 11.0, *)) {
if (config.largeTitle &&
(config.largeTitleFontFamily || config.largeTitleFontSize || config.largeTitleFontWeight ||
config.largeTitleColor || config.titleColor)) {
NSMutableDictionary *largeAttrs = [NSMutableDictionary new];
if (config.largeTitleColor || config.titleColor) {
largeAttrs[NSForegroundColorAttributeName] =
config.largeTitleColor ? config.largeTitleColor : config.titleColor;
}
NSString *largeFamily = config.largeTitleFontFamily ?: nil;
NSNumber *largeSize = config.largeTitleFontSize ?: @34;
NSString *largeWeight = config.largeTitleFontWeight ?: nil;
if (largeFamily || largeWeight) {
largeAttrs[NSFontAttributeName] = [RCTFont updateFont:nil
withFamily:largeFamily
size:largeSize
weight:largeWeight
style:nil
variant:nil
scaleMultiplier:1.0];
} else {
largeAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:[largeSize floatValue] weight:UIFontWeightBold];
}
[navbar setLargeTitleTextAttributes:largeAttrs];
}
}
#endif
}
// font customized on the navigation item level, so nothing to do here
}

+ (void)setTitleAttibutes:(NSDictionary *)attrs forButton:(UIBarButtonItem *)button
Expand Down Expand Up @@ -476,8 +389,6 @@ + (void)willShowViewController:(UIViewController *)vc
}
}

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
+ (UINavigationBarAppearance *)buildAppearance:(UIViewController *)vc
withConfig:(RNSScreenStackHeaderConfig *)config API_AVAILABLE(ios(13.0))
{
Expand Down Expand Up @@ -578,7 +489,6 @@ + (UINavigationBarAppearance *)buildAppearance:(UIViewController *)vc
}
return appearance;
}
#endif // Check for >= iOS 13.0

+ (void)updateViewController:(UIViewController *)vc
withConfig:(RNSScreenStackHeaderConfig *)config
Expand Down Expand Up @@ -685,6 +595,7 @@ + (void)updateViewController:(UIViewController *)vc
}
#endif

// TODO: This needs to be removed after min. tvOS deployment target bump
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, tvOS 13.0, *)) {
Expand Down Expand Up @@ -718,7 +629,7 @@ + (void)updateViewController:(UIViewController *)vc
}
navitem.scrollEdgeAppearance = scrollEdgeAppearance;
} else
#endif
#endif // Check for iOS / tvOS 13
{
#if !TARGET_OS_TV
// updating backIndicatotImage does not work when called during transition. On iOS pre 13 we need
Expand Down Expand Up @@ -1239,16 +1150,11 @@ + (NSMutableDictionary *)blurEffectsForIOSVersion
@"extraLight" : @(RNSBlurEffectStyleExtraLight),
@"light" : @(RNSBlurEffectStyleLight),
@"dark" : @(RNSBlurEffectStyleDark),
@"regular" : @(RNSBlurEffectStyleRegular),
@"prominent" : @(RNSBlurEffectStyleProminent),
}];

if (@available(iOS 10.0, *)) {
[blurEffects addEntriesFromDictionary:@{
@"regular" : @(RNSBlurEffectStyleRegular),
@"prominent" : @(RNSBlurEffectStyleProminent),
}];
}
#if !TARGET_OS_TV && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
#if !TARGET_OS_TV
if (@available(iOS 13.0, *)) {
[blurEffects addEntriesFromDictionary:@{
@"systemUltraThinMaterial" : @(RNSBlurEffectStyleSystemUltraThinMaterial),
Expand Down
Loading
Loading