Skip to content

Commit

Permalink
fix: move private method to implementation and use proper naming conv…
Browse files Browse the repository at this point in the history
…ention
  • Loading branch information
maciekstosio committed May 9, 2024
1 parent 376151c commit 4809030
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
5 changes: 2 additions & 3 deletions ios/RNSConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ namespace react = facebook::react;

@interface RNSConvert : NSObject

+ (NSNumber *)getFontSizePropValue:(int)value;

+ (UISemanticContentAttribute)getDirectionPropValue:(react::RNSScreenStackHeaderConfigDirection)direction;
+ (UISemanticContentAttribute)UISemanticContentAttributeFromCppEquivalent:
(react::RNSScreenStackHeaderConfigDirection)direction;

+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayModeFromCppEquivalent:
(react::RNSScreenStackHeaderConfigBackButtonDisplayMode)backButtonDisplayMode;
Expand Down
12 changes: 3 additions & 9 deletions ios/RNSConvert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
#ifdef RCT_NEW_ARCH_ENABLED
@implementation RNSConvert

+ (NSNumber *)getFontSizePropValue:(int)value
{
if (value > 0)
return [NSNumber numberWithInt:value];
return nil;
}

+ (UISemanticContentAttribute)getDirectionPropValue:(react::RNSScreenStackHeaderConfigDirection)direction
+ (UISemanticContentAttribute)UISemanticContentAttributeFromCppEquivalent:
(react::RNSScreenStackHeaderConfigDirection)direction
{
switch (direction) {
case react::RNSScreenStackHeaderConfigDirection::Rtl:
Expand All @@ -20,7 +14,7 @@ + (UISemanticContentAttribute)getDirectionPropValue:(react::RNSScreenStackHeader
}
}

+ (UINavigationItemBackButtonDisplayMode)getBackButtonDisplayModePropValue:
+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayModeFromCppEquivalent:
(react::RNSScreenStackHeaderConfigBackButtonDisplayMode)backButtonDisplayMode
{
switch (backButtonDisplayMode) {
Expand Down
18 changes: 13 additions & 5 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,13 @@ - (void)prepareForRecycle
_initialPropsSet = NO;
}

- (NSNumber *)getFontSizePropValue:(int)value
{
if (value > 0)
return [NSNumber numberWithInt:value];
return nil;
}

+ (react::ComponentDescriptorProvider)componentDescriptorProvider
{
return react::concreteComponentDescriptorProvider<react::RNSScreenStackHeaderConfigComponentDescriptor>();
Expand Down Expand Up @@ -822,28 +829,29 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
_titleFontFamily = RCTNSStringFromStringNilIfEmpty(newScreenProps.titleFontFamily);
}
_titleFontWeight = RCTNSStringFromStringNilIfEmpty(newScreenProps.titleFontWeight);
_titleFontSize = [RNSConvert getFontSizePropValue:newScreenProps.titleFontSize];
_titleFontSize = [self getFontSizePropValue:newScreenProps.titleFontSize];
_hideShadow = newScreenProps.hideShadow;

_largeTitle = newScreenProps.largeTitle;
if (newScreenProps.largeTitleFontFamily != oldScreenProps.largeTitleFontFamily) {
_largeTitleFontFamily = RCTNSStringFromStringNilIfEmpty(newScreenProps.largeTitleFontFamily);
}
_largeTitleFontWeight = RCTNSStringFromStringNilIfEmpty(newScreenProps.largeTitleFontWeight);
_largeTitleFontSize = [RNSConvert getFontSizePropValue:newScreenProps.largeTitleFontSize];
_largeTitleFontSize = [self getFontSizePropValue:newScreenProps.largeTitleFontSize];
_largeTitleHideShadow = newScreenProps.largeTitleHideShadow;

_backTitle = RCTNSStringFromStringNilIfEmpty(newScreenProps.backTitle);
if (newScreenProps.backTitleFontFamily != oldScreenProps.backTitleFontFamily) {
_backTitleFontFamily = RCTNSStringFromStringNilIfEmpty(newScreenProps.backTitleFontFamily);
}
_backTitleFontSize = [RNSConvert getFontSizePropValue:newScreenProps.backTitleFontSize];
_backTitleFontSize = [self getFontSizePropValue:newScreenProps.backTitleFontSize];
_hideBackButton = newScreenProps.hideBackButton;
_disableBackButtonMenu = newScreenProps.disableBackButtonMenu;
_backButtonDisplayMode = [RNSConvert getBackButtonDisplayModePropValue:newScreenProps.backButtonDisplayMode];
_backButtonDisplayMode =
[RNSConvert UINavigationItemBackButtonDisplayModeFromCppEquivalent:newScreenProps.backButtonDisplayMode];

if (newScreenProps.direction != oldScreenProps.direction) {
_direction = [RNSConvert getDirectionPropValue:newScreenProps.direction];
_direction = [RNSConvert UISemanticContentAttributeFromCppEquivalent:newScreenProps.direction];
}

_backTitleVisible = newScreenProps.backTitleVisible;
Expand Down

0 comments on commit 4809030

Please sign in to comment.