Skip to content

Commit

Permalink
fix(iOS): fix build issues when building with -Werror -Wreturn-path (
Browse files Browse the repository at this point in the history
…#2497)

## Description

Possible build issues.

## Changes

- **Add default for resizemode conversion**
- **Remove unimplemented and unused method**

## Test code and steps to reproduce

CI

## Checklist

- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored Nov 13, 2024
1 parent 6a95fe7 commit 4614702
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ findHeaderConfigChild(const YogaLayoutableShadowNode &screenShadowNode) {
return {};
}

#ifdef ANDROID
static constexpr const char *kScreenDummyLayoutHelperClass =
"com/swmansion/rnscreens/utils/ScreenDummyLayoutHelper";

#ifdef ANDROID
std::optional<float> findHeaderHeight(
const int fontSize,
const bool isTitleEmpty) {
Expand Down
2 changes: 0 additions & 2 deletions ios/RNSConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ namespace react = facebook::react;

+ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RNSSearchBarPlacement)placement;

+ (NSMutableArray<NSNumber *> *)NSNumberMutableArrayFromFloatVector:(const std::vector<CGFloat> &)vector;

+ (NSMutableArray<NSNumber *> *)arrayFromVector:(const std::vector<CGFloat> &)vector;

+ (RNSBlurEffectStyle)RNSBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect;
Expand Down
4 changes: 4 additions & 0 deletions ios/RNSFullWindowOverlay.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import <UIKit/UIKit.h>

#import "RNSDefines.h"
#import "RNSFullWindowOverlay.h"

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down Expand Up @@ -198,13 +199,16 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
[childComponentView removeFromSuperview];
}

RNS_IGNORE_SUPER_CALL_BEGIN
// We do not set frame for ouselves, but rather for the container.
- (void)updateLayoutMetrics:(react::LayoutMetrics const &)layoutMetrics
oldLayoutMetrics:(react::LayoutMetrics const &)oldLayoutMetrics
{
CGRect frame = RCTCGRectFromRect(layoutMetrics.frame);
_reactFrame = frame;
[_container setFrame:frame];
}
RNS_IGNORE_SUPER_CALL_END

#else
#pragma mark - Paper specific
Expand Down
5 changes: 5 additions & 0 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "RNSScreenStack.h"
#import "RNSScreenStackHeaderConfig.h"

#import "RNSDefines.h"
#import "UIView+RNSUtility.h"

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down Expand Up @@ -136,10 +137,12 @@ - (UIViewController *)reactViewController
}

#ifdef RCT_NEW_ARCH_ENABLED
RNS_IGNORE_SUPER_CALL_BEGIN
- (NSArray<UIView *> *)reactSubviews
{
return _reactSubviews;
}
RNS_IGNORE_SUPER_CALL_END
#endif

- (void)updateBounds
Expand Down Expand Up @@ -374,10 +377,12 @@ - (void)setHomeIndicatorHidden:(BOOL)homeIndicatorHidden
}
#endif

RNS_IGNORE_SUPER_CALL_BEGIN
- (UIView *)reactSuperview
{
return _reactSuperview;
}
RNS_IGNORE_SUPER_CALL_END

/// This is RNSScreenContentWrapperDelegate method, where we do get notified when React did update frame of our child.
- (void)reactDidSetFrame:(CGRect)reactFrame forContentWrapper:(RNSScreenContentWrapper *)contentWrapepr
Expand Down
5 changes: 5 additions & 0 deletions ios/RNSScreenContainer.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "RNSScreenContainer.h"
#import "RNSDefines.h"
#import "RNSScreen.h"

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down Expand Up @@ -89,6 +90,9 @@ - (void)markChildUpdated
[self updateContainer];
}

RNS_IGNORE_SUPER_CALL_BEGIN
// We do not call super as we do not want to update UIKit model. It will
// be updated after we receive all mutations.
- (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex
{
subview.reactSuperview = self;
Expand All @@ -106,6 +110,7 @@ - (void)removeReactSubview:(RNSScreenView *)subview
{
return _reactSubviews;
}
RNS_IGNORE_SUPER_CALL_END

- (UIViewController *)reactViewController
{
Expand Down
49 changes: 24 additions & 25 deletions ios/RNSScreenFooter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,34 @@ - (instancetype)init
- (void)willMoveToSuperview:(UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
if ([newSuperview isKindOfClass:RNSScreenView.class]) {
RNSScreenView *screen = (RNSScreenView *)newSuperview;
_parent = (RNSScreenView *)newSuperview;

// [NSLayoutConstraint activateConstraints:@[
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeBottom multiplier:1.0
// constant:0.0], [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeft
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0],
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual
// toItem:screen attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint
// constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:screen
// attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
// attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self
// attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint
// constraintWithItem:screen attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self
// attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
// attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self
// attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
// attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop
// multiplier:1.0 constant:0.0],
// ]];
// [self setNeedsLayout];
}
// if ([newSuperview isKindOfClass:RNSScreenView.class]) {
// RNSScreenView *screen = (RNSScreenView *)newSuperview;
// _parent = (RNSScreenView *)newSuperview;

// [NSLayoutConstraint activateConstraints:@[
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeBottom multiplier:1.0
// constant:0.0], [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeft
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0],
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual
// toItem:screen attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint
// constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:screen
// attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
// attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self
// attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint
// constraintWithItem:screen attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self
// attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
// attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self
// attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
// attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop
// multiplier:1.0 constant:0.0],
// ]];
// [self setNeedsLayout];
// }
}

- (void)didMoveToSuperview
{
NSLog(@"Adding constraints between %@ and %@", self, _parent);
if (_parent != nil) {
// [NSLayoutConstraint activateConstraints:@[
// [NSLayoutConstraint constraintWithItem:self
Expand Down
7 changes: 7 additions & 0 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "RCTTouchHandler+RNSUtility.h"
#endif // RCT_NEW_ARCH_ENABLED

#import "RNSDefines.h"
#import "RNSPercentDrivenInteractiveTransition.h"
#import "RNSScreen.h"
#import "RNSScreenStack.h"
Expand Down Expand Up @@ -290,10 +291,12 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)presentatio
}
}

RNS_IGNORE_SUPER_CALL_BEGIN
- (NSArray<UIView *> *)reactSubviews
{
return _reactSubviews;
}
RNS_IGNORE_SUPER_CALL_END

- (void)didMoveToWindow
{
Expand Down Expand Up @@ -1086,6 +1089,9 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer

#endif // !TARGET_OS_TV

RNS_IGNORE_SUPER_CALL_BEGIN
// We hijack the udpates as we don't want to update UIKit model yet.
// This is done after all mutations are processed.
- (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex
{
if (![subview isKindOfClass:[RNSScreenView class]]) {
Expand All @@ -1101,6 +1107,7 @@ - (void)removeReactSubview:(RNSScreenView *)subview
subview.reactSuperview = nil;
[_reactSubviews removeObject:subview];
}
RNS_IGNORE_SUPER_CALL_END

- (void)didUpdateReactSubviews
{
Expand Down
15 changes: 9 additions & 6 deletions ios/RNSScreenStackHeaderConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@interface NSString (RNSStringUtil)

+ (BOOL)RNSisBlank:(NSString *)string;
+ (BOOL)RNSisBlank:(nullable NSString *)string;

@end

Expand All @@ -31,6 +31,8 @@
@property (nonatomic) BOOL hide;
#endif

NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *titleFontFamily;
@property (nonatomic, retain) NSNumber *titleFontSize;
Expand Down Expand Up @@ -58,9 +60,11 @@
@property (nonatomic) UINavigationItemBackButtonDisplayMode backButtonDisplayMode;
@property (nonatomic) RNSBlurEffectStyle blurEffect;

+ (void)willShowViewController:(UIViewController *)vc
NS_ASSUME_NONNULL_END

+ (void)willShowViewController:(nonnull UIViewController *)vc
animated:(BOOL)animated
withConfig:(RNSScreenStackHeaderConfig *)config;
withConfig:(nonnull RNSScreenStackHeaderConfig *)config;

/**
* Allows to send information with insets to the corresponding node in shadow tree.
Expand Down Expand Up @@ -132,8 +136,7 @@

@interface RCTConvert (RNSScreenStackHeader)

+ (UIBlurEffectStyle)UIBlurEffectStyle:(id)json;
+ (UISemanticContentAttribute)UISemanticContentAttribute:(id)json;
+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayMode:(id)json;
+ (UISemanticContentAttribute)UISemanticContentAttribute:(nonnull id)json;
+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayMode:(nonnull id)json;

@end
8 changes: 8 additions & 0 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import <React/RCTImageLoader.h>
#import <React/RCTImageSource.h>
#import "RNSConvert.h"
#import "RNSDefines.h"
#import "RNSScreen.h"
#import "RNSScreenStackHeaderConfig.h"
#import "RNSSearchBar.h"
Expand Down Expand Up @@ -113,6 +114,7 @@ - (void)initProps
_blurEffect = RNSBlurEffectStyleNone;
}

RNS_IGNORE_SUPER_CALL_BEGIN
- (UIView *)reactSuperview
{
return _screenView;
Expand All @@ -122,6 +124,7 @@ - (UIView *)reactSuperview
{
return _reactSubviews;
}
RNS_IGNORE_SUPER_CALL_END

- (void)removeFromSuperview
{
Expand Down Expand Up @@ -785,6 +788,7 @@ + (void)updateViewController:(UIViewController *)vc
}
}

RNS_IGNORE_SUPER_CALL_BEGIN
- (void)insertReactSubview:(RNSScreenStackHeaderSubview *)subview atIndex:(NSInteger)atIndex
{
[_reactSubviews insertObject:subview atIndex:atIndex];
Expand All @@ -795,6 +799,7 @@ - (void)removeReactSubview:(RNSScreenStackHeaderSubview *)subview
{
[_reactSubviews removeObject:subview];
}
RNS_IGNORE_SUPER_CALL_BEGIN

- (void)didUpdateReactSubviews
{
Expand Down Expand Up @@ -879,6 +884,9 @@ static RCTResizeMode resizeModeFromCppEquiv(react::ImageResizeMode resizeMode)
return RCTResizeModeCenter;
case react::ImageResizeMode::Repeat:
return RCTResizeModeRepeat;
default:
// Both RCTConvert and ImageProps use this as a default as of RN 0.76
return RCTResizeModeStretch;
}
}

Expand Down
4 changes: 4 additions & 0 deletions ios/RNSScreenStackHeaderSubview.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "RNSScreenStackHeaderSubview.h"
#import "RNSConvert.h"
#import "RNSDefines.h"
#import "RNSScreenStackHeaderConfig.h"

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down Expand Up @@ -86,6 +87,8 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
return react::concreteComponentDescriptorProvider<react::RNSScreenStackHeaderSubviewComponentDescriptor>();
}

RNS_IGNORE_SUPER_CALL_BEGIN
// System layouts the subviews.
- (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics
oldLayoutMetrics:(const react::LayoutMetrics &)oldLayoutMetrics
{
Expand All @@ -105,6 +108,7 @@ - (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics
[self layoutNavigationBarIfNeeded];
}
}
RNS_IGNORE_SUPER_CALL_BEGIN

+ (BOOL)shouldBeRecycled
{
Expand Down
7 changes: 7 additions & 0 deletions ios/utils/RNSDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#define RNS_IGNORE_SUPER_CALL_BEGIN \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wobjc-missing-super-calls\"")

#define RNS_IGNORE_SUPER_CALL_END _Pragma("clang diagnostic pop")

0 comments on commit 4614702

Please sign in to comment.