Skip to content

Commit

Permalink
Merge branch 'main' into @kkafar/fix-header-animation
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Nov 13, 2024
2 parents 7846bdd + 4614702 commit e2e24ee
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 39 deletions.
3 changes: 3 additions & 0 deletions android/src/main/cpp/jni-adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Java_com_swmansion_rnscreens_ScreensModule_nativeInstall(
return;
}
jsi::Runtime &rt = *runtime;
if (globalThis) {
env->DeleteGlobalRef(globalThis);
}
globalThis = env->NewGlobalRef(thiz);
JavaVM *jvm;
env->GetJavaVM(&jvm);
Expand Down
10 changes: 9 additions & 1 deletion apps/src/tests/TestModalNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ function HomeScreen({
title="Navigate to Screen 1"
onPress={() => navigation.navigate('NestedStack')}
/>
<Button
title="Navigate to Screen (same stack)"
onPress={() => navigation.navigate('MainStackScreen')}
/>
</View>
);
}

function MainStackScreen() {
function MainStackScreen({ navigation }: NativeStackScreenProps<StackParamList, 'MainStackScreen'>) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Main stack screen</Text>
<Button
title="goBack"
onPress={() => navigation.goBack()}
/>
</View>
);
}
Expand Down
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
4 changes: 2 additions & 2 deletions docs/src/components/Hero/ScreenSequence/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

@media (min-width: 3000px) and (min-height: 2000px) {
.screens {
top: -3vh;
min-height: 50%;
top: 3vh;
min-height: 35%;
}
}

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
9 changes: 8 additions & 1 deletion 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 Expand Up @@ -1288,7 +1295,7 @@ - (void)invalidate
// with modal presentation or foreign modal presented from inside a Screen.
- (void)dismissAllRelatedModals
{
[_controller dismissViewControllerAnimated:NO completion:nil];
[_controller dismissViewControllerAnimated:YES completion:nil];

// This loop seems to be excessive. Above message send to `_controller` should
// be enough, because system dismisses the controllers recursively,
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")
2 changes: 1 addition & 1 deletion react-navigation
Submodule react-navigation updated 55 files
+2 −2 .github/ISSUE_TEMPLATE/bug-report.yml
+8 −1 README.md
+1 −1 example/package.json
+7 −13 example/src/Screens/TabView/AutoWidthTabBar.tsx
+3 −1 example/src/Screens/TabView/Coverflow.tsx
+12 −16 example/src/Screens/TabView/CustomIndicator.tsx
+5 −10 example/src/Screens/TabView/CustomTabBar.tsx
+7 −13 example/src/Screens/TabView/ScrollableTabBar.tsx
+8 −16 example/src/Screens/TabView/TabBarIcon.tsx
+0 −2 lerna.json
+30 −0 packages/bottom-tabs/CHANGELOG.md
+3 −3 packages/bottom-tabs/package.json
+2 −2 packages/bottom-tabs/src/navigators/createBottomTabNavigator.tsx
+5 −4 packages/bottom-tabs/src/types.tsx
+2 −2 packages/bottom-tabs/src/views/BottomTabView.tsx
+4 −0 packages/core/CHANGELOG.md
+2 −2 packages/core/package.json
+10 −0 packages/devtools/CHANGELOG.md
+1 −1 packages/devtools/package.json
+19 −5 packages/devtools/src/useLogger.tsx
+28 −0 packages/drawer/CHANGELOG.md
+3 −3 packages/drawer/package.json
+1 −1 packages/drawer/src/types.tsx
+2 −2 packages/drawer/src/views/DrawerView.tsx
+4 −0 packages/elements/CHANGELOG.md
+1 −1 packages/elements/package.json
+28 −0 packages/material-top-tabs/CHANGELOG.md
+3 −3 packages/material-top-tabs/package.json
+5 −0 packages/material-top-tabs/src/types.tsx
+51 −29 packages/material-top-tabs/src/views/MaterialTopTabBar.tsx
+26 −8 packages/material-top-tabs/src/views/MaterialTopTabView.tsx
+10 −0 packages/native-stack/CHANGELOG.md
+3 −3 packages/native-stack/package.json
+2 −9 packages/native-stack/src/types.tsx
+0 −43 packages/native-stack/src/views/DebugContainer.native.tsx
+0 −14 packages/native-stack/src/views/DebugContainer.tsx
+10 −15 packages/native-stack/src/views/NativeStackView.native.tsx
+0 −121 packages/native-stack/src/views/ScreenStackContent.tsx
+4 −0 packages/native/CHANGELOG.md
+1 −1 packages/native/package.json
+10 −0 packages/react-native-drawer-layout/CHANGELOG.md
+1 −1 packages/react-native-drawer-layout/package.json
+4 −0 packages/react-native-drawer-layout/src/views/Drawer.native.tsx
+28 −0 packages/react-native-tab-view/CHANGELOG.md
+1 −1 packages/react-native-tab-view/package.json
+1 −10 packages/react-native-tab-view/src/TabBar.tsx
+1 −3 packages/react-native-tab-view/src/TabBarItem.tsx
+3 −3 packages/react-native-tab-view/src/TabBarItemLabel.tsx
+24 −4 packages/react-native-tab-view/src/TabView.tsx
+5 −3 packages/react-native-tab-view/src/types.tsx
+4 −0 packages/routers/CHANGELOG.md
+1 −1 packages/routers/package.json
+10 −0 packages/stack/CHANGELOG.md
+3 −3 packages/stack/package.json
+61 −704 yarn.lock

0 comments on commit e2e24ee

Please sign in to comment.