@@ -276,96 +276,9 @@ - (BOOL)shouldBackButtonBeVisibleInNavigationBar:(nullable UINavigationBar *)nav
276276+ (void )setAnimatedConfig : (UIViewController *)vc withConfig : (RNSScreenStackHeaderConfig *)config
277277{
278278 UINavigationBar *navbar = ((UINavigationController *)vc.parentViewController ).navigationBar ;
279- // It is workaround for loading custom back icon when transitioning from a screen without header to the screen which
280- // has one. This action fails when navigating to the screen with header for the second time and loads default back
281- // button. It looks like changing the tint color of navbar triggers an update of the items belonging to it and it
282- // 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
283- // the one it should have.
284- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_14_0) && \
285- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
286- // it brakes the behavior of `headerRight` in iOS 14, where the bug desribed above seems to be fixed, so we do nothing
287- // in iOS 14
288- if (@available (iOS 14.0 , *)) {
289- } else
290- #endif
291- {
292- [navbar setTintColor: [config.color colorWithAlphaComponent: CGColorGetAlpha (config.color.CGColor) - 0.01 ]];
293- }
294279 [navbar setTintColor: config.color];
295280
296- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
297- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
298- if (@available (iOS 13.0 , *)) {
299- // font customized on the navigation item level, so nothing to do here
300- } else
301- #endif
302- {
303- BOOL hideShadow = config.hideShadow ;
304-
305- if (config.backgroundColor && CGColorGetAlpha (config.backgroundColor .CGColor ) == 0 .) {
306- [navbar setBackgroundImage: [UIImage new ] forBarMetrics: UIBarMetricsDefault];
307- [navbar setBarTintColor: [UIColor clearColor ]];
308- hideShadow = YES ;
309- } else {
310- [navbar setBackgroundImage: nil forBarMetrics: UIBarMetricsDefault];
311- [navbar setBarTintColor: config.backgroundColor];
312- }
313- [navbar setTranslucent: config.translucent];
314- [navbar setValue: @(hideShadow ? YES : NO ) forKey: @" hidesShadow" ];
315-
316- if (config.titleFontFamily || config.titleFontSize || config.titleFontWeight || config.titleColor ) {
317- NSMutableDictionary *attrs = [NSMutableDictionary new ];
318-
319- if (config.titleColor ) {
320- attrs[NSForegroundColorAttributeName ] = config.titleColor ;
321- }
322-
323- NSString *family = config.titleFontFamily ?: nil ;
324- NSNumber *size = config.titleFontSize ?: @17 ;
325- NSString *weight = config.titleFontWeight ?: nil ;
326- if (family || weight) {
327- attrs[NSFontAttributeName ] = [RCTFont updateFont: nil
328- withFamily: family
329- size: size
330- weight: weight
331- style: nil
332- variant: nil
333- scaleMultiplier: 1.0 ];
334- } else {
335- attrs[NSFontAttributeName ] = [UIFont boldSystemFontOfSize: [size floatValue ]];
336- }
337- [navbar setTitleTextAttributes: attrs];
338- }
339-
340- #if !TARGET_OS_TV && !TARGET_OS_VISION
341- if (@available (iOS 11.0 , *)) {
342- if (config.largeTitle &&
343- (config.largeTitleFontFamily || config.largeTitleFontSize || config.largeTitleFontWeight ||
344- config.largeTitleColor || config.titleColor )) {
345- NSMutableDictionary *largeAttrs = [NSMutableDictionary new ];
346- if (config.largeTitleColor || config.titleColor ) {
347- largeAttrs[NSForegroundColorAttributeName ] =
348- config.largeTitleColor ? config.largeTitleColor : config.titleColor ;
349- }
350- NSString *largeFamily = config.largeTitleFontFamily ?: nil ;
351- NSNumber *largeSize = config.largeTitleFontSize ?: @34 ;
352- NSString *largeWeight = config.largeTitleFontWeight ?: nil ;
353- if (largeFamily || largeWeight) {
354- largeAttrs[NSFontAttributeName ] = [RCTFont updateFont: nil
355- withFamily: largeFamily
356- size: largeSize
357- weight: largeWeight
358- style: nil
359- variant: nil
360- scaleMultiplier: 1.0 ];
361- } else {
362- largeAttrs[NSFontAttributeName ] = [UIFont systemFontOfSize: [largeSize floatValue ] weight: UIFontWeightBold];
363- }
364- [navbar setLargeTitleTextAttributes: largeAttrs];
365- }
366- }
367- #endif
368- }
281+ // font customized on the navigation item level, so nothing to do here
369282}
370283
371284+ (void )setTitleAttibutes : (NSDictionary *)attrs forButton : (UIBarButtonItem *)button
@@ -476,8 +389,6 @@ + (void)willShowViewController:(UIViewController *)vc
476389 }
477390}
478391
479- #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
480- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
481392+ (UINavigationBarAppearance *)buildAppearance: (UIViewController *)vc
482393 withConfig: (RNSScreenStackHeaderConfig *)config API_AVAILABLE (ios(13.0 ))
483394{
@@ -578,7 +489,6 @@ + (UINavigationBarAppearance *)buildAppearance:(UIViewController *)vc
578489 }
579490 return appearance;
580491}
581- #endif // Check for >= iOS 13.0
582492
583493+ (void )updateViewController: (UIViewController *)vc
584494 withConfig: (RNSScreenStackHeaderConfig *)config
@@ -684,6 +594,7 @@ + (void)updateViewController:(UIViewController *)vc
684594 }
685595#endif
686596
597+ // TODO: This needs to be removed after min. tvOS deployment target bump
687598#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
688599 __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
689600 if (@available (iOS 13.0 , tvOS 13.0 , *)) {
@@ -717,7 +628,7 @@ + (void)updateViewController:(UIViewController *)vc
717628 }
718629 navitem.scrollEdgeAppearance = scrollEdgeAppearance;
719630 } else
720- #endif
631+ #endif // Check for iOS / tvOS 13
721632 {
722633#if !TARGET_OS_TV
723634 // updating backIndicatotImage does not work when called during transition. On iOS pre 13 we need
@@ -1238,35 +1149,28 @@ + (NSMutableDictionary *)blurEffectsForIOSVersion
12381149 @" extraLight" : @(RNSBlurEffectStyleExtraLight),
12391150 @" light" : @(RNSBlurEffectStyleLight),
12401151 @" dark" : @(RNSBlurEffectStyleDark),
1152+ @" regular" : @(RNSBlurEffectStyleRegular),
1153+ @" prominent" : @(RNSBlurEffectStyleProminent),
12411154 }];
12421155
1243- if (@available (iOS 10.0 , *)) {
1244- [blurEffects addEntriesFromDictionary: @{
1245- @" regular" : @(RNSBlurEffectStyleRegular),
1246- @" prominent" : @(RNSBlurEffectStyleProminent),
1247- }];
1248- }
1249- #if !TARGET_OS_TV && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
1250- __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
1251- if (@available (iOS 13.0 , *)) {
1252- [blurEffects addEntriesFromDictionary: @{
1253- @" systemUltraThinMaterial" : @(RNSBlurEffectStyleSystemUltraThinMaterial),
1254- @" systemThinMaterial" : @(RNSBlurEffectStyleSystemThinMaterial),
1255- @" systemMaterial" : @(RNSBlurEffectStyleSystemMaterial),
1256- @" systemThickMaterial" : @(RNSBlurEffectStyleSystemThickMaterial),
1257- @" systemChromeMaterial" : @(RNSBlurEffectStyleSystemChromeMaterial),
1258- @" systemUltraThinMaterialLight" : @(RNSBlurEffectStyleSystemUltraThinMaterialLight),
1259- @" systemThinMaterialLight" : @(RNSBlurEffectStyleSystemThinMaterialLight),
1260- @" systemMaterialLight" : @(RNSBlurEffectStyleSystemMaterialLight),
1261- @" systemThickMaterialLight" : @(RNSBlurEffectStyleSystemThickMaterialLight),
1262- @" systemChromeMaterialLight" : @(RNSBlurEffectStyleSystemChromeMaterialLight),
1263- @" systemUltraThinMaterialDark" : @(RNSBlurEffectStyleSystemUltraThinMaterialDark),
1264- @" systemThinMaterialDark" : @(RNSBlurEffectStyleSystemThinMaterialDark),
1265- @" systemMaterialDark" : @(RNSBlurEffectStyleSystemMaterialDark),
1266- @" systemThickMaterialDark" : @(RNSBlurEffectStyleSystemThickMaterialDark),
1267- @" systemChromeMaterialDark" : @(RNSBlurEffectStyleSystemChromeMaterialDark),
1268- }];
1269- }
1156+ #if !TARGET_OS_TV
1157+ [blurEffects addEntriesFromDictionary: @{
1158+ @" systemUltraThinMaterial" : @(RNSBlurEffectStyleSystemUltraThinMaterial),
1159+ @" systemThinMaterial" : @(RNSBlurEffectStyleSystemThinMaterial),
1160+ @" systemMaterial" : @(RNSBlurEffectStyleSystemMaterial),
1161+ @" systemThickMaterial" : @(RNSBlurEffectStyleSystemThickMaterial),
1162+ @" systemChromeMaterial" : @(RNSBlurEffectStyleSystemChromeMaterial),
1163+ @" systemUltraThinMaterialLight" : @(RNSBlurEffectStyleSystemUltraThinMaterialLight),
1164+ @" systemThinMaterialLight" : @(RNSBlurEffectStyleSystemThinMaterialLight),
1165+ @" systemMaterialLight" : @(RNSBlurEffectStyleSystemMaterialLight),
1166+ @" systemThickMaterialLight" : @(RNSBlurEffectStyleSystemThickMaterialLight),
1167+ @" systemChromeMaterialLight" : @(RNSBlurEffectStyleSystemChromeMaterialLight),
1168+ @" systemUltraThinMaterialDark" : @(RNSBlurEffectStyleSystemUltraThinMaterialDark),
1169+ @" systemThinMaterialDark" : @(RNSBlurEffectStyleSystemThinMaterialDark),
1170+ @" systemMaterialDark" : @(RNSBlurEffectStyleSystemMaterialDark),
1171+ @" systemThickMaterialDark" : @(RNSBlurEffectStyleSystemThickMaterialDark),
1172+ @" systemChromeMaterialDark" : @(RNSBlurEffectStyleSystemChromeMaterialDark),
1173+ }];
12701174#endif
12711175 return blurEffects;
12721176}
0 commit comments