Skip to content

Commit

Permalink
Fix updating props of ScreenStackHeaderConfig on Paper iOS (#4375)
Browse files Browse the repository at this point in the history
## Summary

This PR fixes ScreenStackHeaderConfigBackgroundColor example on iOS with
Paper.

See also
software-mansion/react-native-screens#1760


https://user-images.githubusercontent.com/20516055/233048052-7c35c443-9e89-497d-9aa5-552d57bb1838.mov

## Test plan

Check if the example works
  • Loading branch information
tomekzaw authored Apr 21, 2023
1 parent 58343aa commit bf44b1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ import { StyleSheet, View } from 'react-native';
import React from 'react';

const AnimatedScreenStackHeaderConfig = Animated.createAnimatedComponent(
// @ts-ignore it works in FabricExample
// @ts-ignore will be fixed with https://github.com/software-mansion/react-native-screens/pull/1760
ScreenStackHeaderConfig
);
Animated.addWhitelistedNativeProps({ title: true });

export default function ScreenStackHeaderConfigBackgroundColorExample() {
const isPressed = useSharedValue(false);
const offset = useSharedValue({ x: 0, y: 0 });

// useJSThreadKiller();

const gesture = Gesture.Pan()
.minDistance(0)
.onBegin(() => {
Expand Down
15 changes: 14 additions & 1 deletion ios/REANodesManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#import <stdatomic.h>
#endif

#if __has_include(<RNScreens/RNSScreenStackHeaderConfig.h>)
#import <RNScreens/RNSScreenStackHeaderConfig.h>
#endif

#ifdef RCT_NEW_ARCH_ENABLED
using namespace facebook::react;
#endif
Expand Down Expand Up @@ -368,7 +372,16 @@ - (void)configureUiProps:(nonnull NSSet<NSString *> *)uiPropsSet

- (BOOL)isNativeViewMounted:(NSNumber *)viewTag
{
return _viewRegistry[viewTag].superview != nil;
UIView *view = _viewRegistry[viewTag];
if (view.superview != nil) {
return YES;
}
#if __has_include(<RNScreens/RNSScreenStackHeaderConfig.h>)
if ([view isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
return ((RNSScreenStackHeaderConfig *)view).screenView != nil;
}
#endif
return NO;
}

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down

0 comments on commit bf44b1a

Please sign in to comment.