Skip to content

Commit

Permalink
Added switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
alduzy committed Jul 19, 2024
1 parent ab1f949 commit b21c8da
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,22 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
- (void)setViewToSnapshot:(RNSScreenStackHeaderSubview *)childComponentView
{
UINavigationItem *navitem = _screenView.controller.navigationItem;
if (childComponentView.type == RNSScreenStackHeaderSubviewTypeLeft) {
navitem.leftBarButtonItem.customView = [navitem.leftBarButtonItem.customView snapshotViewAfterScreenUpdates:NO];
} else if (childComponentView.type == RNSScreenStackHeaderSubviewTypeCenter) {
navitem.titleView = [navitem.titleView snapshotViewAfterScreenUpdates:NO];
} else if (childComponentView.type == RNSScreenStackHeaderSubviewTypeRight) {
navitem.rightBarButtonItem.customView = [navitem.rightBarButtonItem.customView snapshotViewAfterScreenUpdates:NO];
UIView *snapshot = [childComponentView snapshotViewAfterScreenUpdates:NO];

switch (childComponentView.type) {
case RNSScreenStackHeaderSubviewTypeLeft:
navitem.leftBarButtonItem.customView = snapshot;
break;
case RNSScreenStackHeaderSubviewTypeCenter:
case RNSScreenStackHeaderSubviewTypeTitle:
navitem.titleView = snapshot;
break;
case RNSScreenStackHeaderSubviewTypeRight:
navitem.rightBarButtonItem.customView = snapshot;
break;
case RNSScreenStackHeaderSubviewTypeSearchBar:
case RNSScreenStackHeaderSubviewTypeBackButton:
break;
}
}

Expand Down

0 comments on commit b21c8da

Please sign in to comment.