|
19 | 19 | #import <React/RCTFont.h> |
20 | 20 | #import <React/RCTImageLoader.h> |
21 | 21 | #import <React/RCTImageSource.h> |
| 22 | +#import "RNSConvert.h" |
22 | 23 | #import "RNSScreen.h" |
23 | 24 | #import "RNSScreenStackHeaderConfig.h" |
24 | 25 | #import "RNSSearchBar.h" |
@@ -513,6 +514,13 @@ + (void)updateViewController:(UIViewController *)vc |
513 | 514 |
|
514 | 515 | auto isBackButtonCustomized = !isBackTitleBlank || config.disableBackButtonMenu; |
515 | 516 |
|
| 517 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_14_0) && \ |
| 518 | + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 |
| 519 | + if (@available(iOS 14.0, *)) { |
| 520 | + prevItem.backButtonDisplayMode = config.backButtonDisplayMode; |
| 521 | + } |
| 522 | +#endif |
| 523 | + |
516 | 524 | if (config.isBackTitleVisible) { |
517 | 525 | if ((config.backTitleFontFamily && |
518 | 526 | // While being used by react-navigation, the `backTitleFontFamily` will |
@@ -786,26 +794,16 @@ - (void)prepareForRecycle |
786 | 794 | _initialPropsSet = NO; |
787 | 795 | } |
788 | 796 |
|
789 | | -+ (react::ComponentDescriptorProvider)componentDescriptorProvider |
790 | | -{ |
791 | | - return react::concreteComponentDescriptorProvider<react::RNSScreenStackHeaderConfigComponentDescriptor>(); |
792 | | -} |
793 | | - |
794 | 797 | - (NSNumber *)getFontSizePropValue:(int)value |
795 | 798 | { |
796 | 799 | if (value > 0) |
797 | 800 | return [NSNumber numberWithInt:value]; |
798 | 801 | return nil; |
799 | 802 | } |
800 | 803 |
|
801 | | -- (UISemanticContentAttribute)getDirectionPropValue:(react::RNSScreenStackHeaderConfigDirection)direction |
| 804 | ++ (react::ComponentDescriptorProvider)componentDescriptorProvider |
802 | 805 | { |
803 | | - switch (direction) { |
804 | | - case react::RNSScreenStackHeaderConfigDirection::Rtl: |
805 | | - return UISemanticContentAttributeForceRightToLeft; |
806 | | - case react::RNSScreenStackHeaderConfigDirection::Ltr: |
807 | | - return UISemanticContentAttributeForceLeftToRight; |
808 | | - } |
| 806 | + return react::concreteComponentDescriptorProvider<react::RNSScreenStackHeaderConfigComponentDescriptor>(); |
809 | 807 | } |
810 | 808 |
|
811 | 809 | - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps |
@@ -852,9 +850,11 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props:: |
852 | 850 | _backTitleFontSize = [self getFontSizePropValue:newScreenProps.backTitleFontSize]; |
853 | 851 | _hideBackButton = newScreenProps.hideBackButton; |
854 | 852 | _disableBackButtonMenu = newScreenProps.disableBackButtonMenu; |
| 853 | + _backButtonDisplayMode = |
| 854 | + [RNSConvert UINavigationItemBackButtonDisplayModeFromCppEquivalent:newScreenProps.backButtonDisplayMode]; |
855 | 855 |
|
856 | 856 | if (newScreenProps.direction != oldScreenProps.direction) { |
857 | | - _direction = [self getDirectionPropValue:newScreenProps.direction]; |
| 857 | + _direction = [RNSConvert UISemanticContentAttributeFromCppEquivalent:newScreenProps.direction]; |
858 | 858 | } |
859 | 859 |
|
860 | 860 | _backTitleVisible = newScreenProps.backTitleVisible; |
@@ -945,8 +945,8 @@ - (UIView *)view |
945 | 945 | RCT_EXPORT_VIEW_PROPERTY(hideShadow, BOOL) |
946 | 946 | RCT_EXPORT_VIEW_PROPERTY(backButtonInCustomView, BOOL) |
947 | 947 | RCT_EXPORT_VIEW_PROPERTY(disableBackButtonMenu, BOOL) |
948 | | -// `hidden` is an UIView property, we need to use different name internally |
949 | | -RCT_REMAP_VIEW_PROPERTY(hidden, hide, BOOL) |
| 948 | +RCT_EXPORT_VIEW_PROPERTY(backButtonDisplayMode, UINavigationItemBackButtonDisplayMode) |
| 949 | +RCT_REMAP_VIEW_PROPERTY(hidden, hide, BOOL) // `hidden` is an UIView property, we need to use different name internally |
950 | 950 | RCT_EXPORT_VIEW_PROPERTY(translucent, BOOL) |
951 | 951 |
|
952 | 952 | @end |
@@ -1002,6 +1002,16 @@ + (NSMutableDictionary *)blurEffectsForIOSVersion |
1002 | 1002 | UISemanticContentAttributeUnspecified, |
1003 | 1003 | integerValue) |
1004 | 1004 |
|
| 1005 | +RCT_ENUM_CONVERTER( |
| 1006 | + UINavigationItemBackButtonDisplayMode, |
| 1007 | + (@{ |
| 1008 | + @"default" : @(UINavigationItemBackButtonDisplayModeDefault), |
| 1009 | + @"generic" : @(UINavigationItemBackButtonDisplayModeGeneric), |
| 1010 | + @"minimal" : @(UINavigationItemBackButtonDisplayModeMinimal), |
| 1011 | + }), |
| 1012 | + UINavigationItemBackButtonDisplayModeDefault, |
| 1013 | + integerValue) |
| 1014 | + |
1005 | 1015 | RCT_ENUM_CONVERTER(UIBlurEffectStyle, ([self blurEffectsForIOSVersion]), UIBlurEffectStyleExtraLight, integerValue) |
1006 | 1016 |
|
1007 | 1017 | @end |
0 commit comments