Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact(iOS): unify class & method naming with respect to conventions #1841

Merged
merged 4 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion ios/RNSScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN

@class RNSScreenView;

@interface RNSScreen : UIViewController <RNScreensViewControllerDelegate>
@interface RNSScreen : UIViewController <RNSViewControllerDelegate>

- (instancetype)initWithView:(UIView *)view;
- (UIViewController *)findChildVCForConfigAndTrait:(RNSWindowTrait)trait includingModals:(BOOL)includingModals;
Expand Down
15 changes: 7 additions & 8 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,10 @@ - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetric
_newLayoutMetrics = layoutMetrics;
_oldLayoutMetrics = oldLayoutMetrics;
UIViewController *parentVC = self.reactViewController.parentViewController;
if (parentVC != nil && ![parentVC isKindOfClass:[RNScreensNavigationController class]]) {
if (parentVC != nil && ![parentVC isKindOfClass:[RNSNavigationController class]]) {
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
}
// when screen is mounted under RNScreensNavigationController it's size is controller
// when screen is mounted under RNSNavigationController it's size is controller
// by the navigation controller itself. That is, it is set to fill space of
// the controller. In that case we ignore react layout system from managing
// the screen dimensions and we wait for the screen VC to update and then we
Expand Down Expand Up @@ -784,10 +784,10 @@ - (void)reactSetFrame:(CGRect)frame
{
_reactFrame = frame;
UIViewController *parentVC = self.reactViewController.parentViewController;
if (parentVC != nil && ![parentVC isKindOfClass:[RNScreensNavigationController class]]) {
if (parentVC != nil && ![parentVC isKindOfClass:[RNSNavigationController class]]) {
[super reactSetFrame:frame];
}
// when screen is mounted under RNScreensNavigationController it's size is controller
// when screen is mounted under RNSNavigationController it's size is controller
// by the navigation controller itself. That is, it is set to fill space of
// the controller. In that case we ignore react layout system from managing
// the screen dimensions and we wait for the screen VC to update and then we
Expand Down Expand Up @@ -958,12 +958,11 @@ - (void)viewDidLayoutSubviews
[super viewDidLayoutSubviews];

// The below code makes the screen view adapt dimensions provided by the system. We take these
// into account only when the view is mounted under RNScreensNavigationController in which case system
// into account only when the view is mounted under RNSNavigationController in which case system
// provides additional padding to account for possible header, and in the case when screen is
// shown as a native modal, as the final dimensions of the modal on iOS 12+ are shorter than the
// screen size
BOOL isDisplayedWithinUINavController =
[self.parentViewController isKindOfClass:[RNScreensNavigationController class]];
BOOL isDisplayedWithinUINavController = [self.parentViewController isKindOfClass:[RNSNavigationController class]];
BOOL isPresentedAsNativeModal = self.parentViewController == nil && self.presentingViewController != nil;

if (isDisplayedWithinUINavController || isPresentedAsNativeModal) {
Expand Down Expand Up @@ -1078,7 +1077,7 @@ - (UIViewController *)findChildVCForConfigAndTrait:(RNSWindowTrait)trait includi
if (lastViewController == nil) {
return selfOrNil;
} else {
if ([lastViewController conformsToProtocol:@protocol(RNScreensViewControllerDelegate)]) {
if ([lastViewController conformsToProtocol:@protocol(RNSViewControllerDelegate)]) {
// If there is a child (should be VC of ScreenContainer or ScreenStack), that has a child that could provide the
// trait, we recursively go into its findChildVCForConfig, and if one of the children has the trait set, we return
// it, otherwise we return self if this VC has config, and nil if it doesn't we use
Expand Down
4 changes: 2 additions & 2 deletions ios/RNSScreenContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ NS_ASSUME_NONNULL_BEGIN

@end

@protocol RNScreensViewControllerDelegate
@protocol RNSViewControllerDelegate

@end

@interface RNScreensViewController : UIViewController <RNScreensViewControllerDelegate>
@interface RNSViewController : UIViewController <RNSViewControllerDelegate>

- (UIViewController *)findActiveChildVC;

Expand Down
4 changes: 2 additions & 2 deletions ios/RNSScreenContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <react/renderer/components/rnscreens/Props.h>
#endif

@implementation RNScreensViewController
@implementation RNSViewController

#if !TARGET_OS_TV
- (UIViewController *)childViewControllerForStatusBarStyle
Expand Down Expand Up @@ -72,7 +72,7 @@ - (instancetype)init

- (void)setupController
{
_controller = [[RNScreensViewController alloc] init];
_controller = [[RNSViewController alloc] init];
[self addSubview:_controller.view];
}

Expand Down
2 changes: 1 addition & 1 deletion ios/RNSScreenNavigationContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "RNSScreenContainer.h"
#import "RNSScreenStack.h"

@interface RNScreensContainerNavigationController : RNScreensNavigationController
@interface RNSContainerNavigationController : RNSNavigationController

@end

Expand Down
8 changes: 4 additions & 4 deletions ios/RNSScreenNavigationContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
#import <react/renderer/components/rnscreens/Props.h>
#endif

@implementation RNScreensContainerNavigationController
@implementation RNSContainerNavigationController

@end

@implementation RNSScreenNavigationContainerView

- (void)setupController
{
self.controller = [[RNScreensContainerNavigationController alloc] init];
[(RNScreensContainerNavigationController *)self.controller setNavigationBarHidden:YES animated:NO];
self.controller = [[RNSContainerNavigationController alloc] init];
[(RNSContainerNavigationController *)self.controller setNavigationBarHidden:YES animated:NO];
[self addSubview:self.controller.view];
}

Expand All @@ -27,7 +27,7 @@ - (void)updateContainer
if (screen.activityState == RNSActivityStateOnTop) {
// there should never be more than one screen with `RNSActivityStateOnTop`
// since this component should be used for `tabs` and `drawer` navigators
[(RNScreensContainerNavigationController *)self.controller setViewControllers:@[ screen.controller ] animated:NO];
[(RNSContainerNavigationController *)self.controller setViewControllers:@[ screen.controller ] animated:NO];
[screen notifyFinishTransitioning];
}
}
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSScreenStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface RNScreensNavigationController : UINavigationController <RNScreensViewControllerDelegate>
@interface RNSNavigationController : UINavigationController <RNSViewControllerDelegate>

@end

Expand Down
4 changes: 2 additions & 2 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ @interface RNSScreenStackView () <

@end

@implementation RNScreensNavigationController
@implementation RNSNavigationController

#if !TARGET_OS_TV
- (UIViewController *)childViewControllerForStatusBarStyle
Expand Down Expand Up @@ -126,7 +126,7 @@ - (void)initCommonProps
{
_reactSubviews = [NSMutableArray new];
_presentedModals = [NSMutableArray new];
_controller = [RNScreensNavigationController new];
_controller = [RNSNavigationController new];
_controller.delegate = self;
#if !TARGET_OS_TV
[self setupGestureHandlers];
Expand Down
10 changes: 5 additions & 5 deletions ios/RNSScreenWindowTraits.mm
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ + (BOOL)shouldAskScreensForTrait:(RNSWindowTrait)trait
inViewController:(UIViewController *)vc
{
UIViewController *lastViewController = [[vc childViewControllers] lastObject];
if ([lastViewController conformsToProtocol:@protocol(RNScreensViewControllerDelegate)]) {
if ([lastViewController conformsToProtocol:@protocol(RNSViewControllerDelegate)]) {
UIViewController *vc = nil;
if ([lastViewController isKindOfClass:[RNScreensViewController class]]) {
vc = [(RNScreensViewController *)lastViewController findActiveChildVC];
} else if ([lastViewController isKindOfClass:[RNScreensNavigationController class]]) {
vc = [(RNScreensNavigationController *)lastViewController topViewController];
if ([lastViewController isKindOfClass:[RNSViewController class]]) {
vc = [(RNSViewController *)lastViewController findActiveChildVC];
} else if ([lastViewController isKindOfClass:[RNSNavigationController class]]) {
vc = [(RNSNavigationController *)lastViewController topViewController];
}
return [vc isKindOfClass:[RNSScreen class]] &&
[(RNSScreen *)vc findChildVCForConfigAndTrait:trait includingModals:includingModals] != nil;
Expand Down
14 changes: 7 additions & 7 deletions ios/UIViewController+RNScreens.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ @implementation UIViewController (RNScreens)
#if !TARGET_OS_TV
- (UIViewController *)reactNativeScreensChildViewControllerForStatusBarStyle
{
UIViewController *childVC = [self findChildRNScreensViewController];
UIViewController *childVC = [self findChildRNSScreensViewController];
return childVC ?: [self reactNativeScreensChildViewControllerForStatusBarStyle];
}

- (UIViewController *)reactNativeScreensChildViewControllerForStatusBarHidden
{
UIViewController *childVC = [self findChildRNScreensViewController];
UIViewController *childVC = [self findChildRNSScreensViewController];
return childVC ?: [self reactNativeScreensChildViewControllerForStatusBarHidden];
}

- (UIStatusBarAnimation)reactNativeScreensPreferredStatusBarUpdateAnimation
{
UIViewController *childVC = [self findChildRNScreensViewController];
UIViewController *childVC = [self findChildRNSScreensViewController];
return childVC ? childVC.preferredStatusBarUpdateAnimation
: [self reactNativeScreensPreferredStatusBarUpdateAnimation];
}

- (UIInterfaceOrientationMask)reactNativeScreensSupportedInterfaceOrientations
{
UIViewController *childVC = [self findChildRNScreensViewController];
UIViewController *childVC = [self findChildRNSScreensViewController];
return childVC ? childVC.supportedInterfaceOrientations : [self reactNativeScreensSupportedInterfaceOrientations];
}

- (UIViewController *)reactNativeScreensChildViewControllerForHomeIndicatorAutoHidden
{
UIViewController *childVC = [self findChildRNScreensViewController];
UIViewController *childVC = [self findChildRNSScreensViewController];
return childVC ?: [self reactNativeScreensChildViewControllerForHomeIndicatorAutoHidden];
}

- (UIViewController *)findChildRNScreensViewController
- (UIViewController *)findChildRNSScreensViewController
{
UIViewController *lastViewController = [[self childViewControllers] lastObject];
if ([lastViewController conformsToProtocol:@protocol(RNScreensViewControllerDelegate)]) {
if ([lastViewController conformsToProtocol:@protocol(RNSViewControllerDelegate)]) {
return lastViewController;
}
return nil;
Expand Down
Loading