diff --git a/createNativeStackNavigator.js b/createNativeStackNavigator.js index 82438ce5..967874f8 100644 --- a/createNativeStackNavigator.js +++ b/createNativeStackNavigator.js @@ -75,7 +75,7 @@ class StackView extends React.Component { if (options.headerLeft !== undefined) { children.push( - + {options.headerLeft({ scene })} ); @@ -88,7 +88,7 @@ class StackView extends React.Component { }; children.push( - + + {options.headerTitle({ scene })} ); @@ -115,7 +115,7 @@ class StackView extends React.Component { if (options.headerRight) { children.push( - + {options.headerRight({ scene })} ); @@ -180,9 +180,9 @@ function createStackNavigator(routeConfigMap, stackConfig = {}) { // Create a navigator with StackView as the view let Navigator = createNavigator(StackView, router, stackConfig); - if (!stackConfig.disableKeyboardHandling) { - Navigator = createKeyboardAwareNavigator(Navigator, stackConfig); - } + // if (!stackConfig.disableKeyboardHandling) { + // Navigator = createKeyboardAwareNavigator(Navigator, stackConfig); + // } return Navigator; } diff --git a/ios/RNSScreenStack.m b/ios/RNSScreenStack.m index d8cdb8b0..17c67f44 100644 --- a/ios/RNSScreenStack.m +++ b/ios/RNSScreenStack.m @@ -78,6 +78,15 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { + // cancel touches in parent, this is needed to cancel RN touch events. For example when Touchable + // item is close to an edge and we start pulling from edge we want the Touchable to be cancelled. + // Without the below code the Touchable will remain active (highlighted) for the duration of back + // gesture and onPress may fire when we release the finger. + UIView *parent = _controller.view; + while (parent != nil && ![parent isKindOfClass:[RCTRootView class]]) parent = parent.superview; + RCTRootView *rootView = (RCTRootView *)parent; + [rootView cancelTouches]; + return _controller.viewControllers.count > 1; } diff --git a/ios/RNSScreenStackHeaderConfig.m b/ios/RNSScreenStackHeaderConfig.m index da672906..637f8f36 100644 --- a/ios/RNSScreenStackHeaderConfig.m +++ b/ios/RNSScreenStackHeaderConfig.m @@ -188,8 +188,21 @@ if (vc.transitionCoordinator != nil && !wasHidden) { [vc.transitionCoordinator animateAlongsideTransition:^(id _Nonnull context) { - [self setAnimatedConfig:vc]; + } completion:nil]; + [vc.transitionCoordinator animateAlongsideTransition:^(id _Nonnull context) { + [self setAnimatedConfig:vc]; + } completion:^(id _Nonnull context) { + if ([context isCancelled]) { + UIViewController* fromVC = [context viewControllerForKey:UITransitionContextFromViewControllerKey]; + for (UIView *subview in fromVC.view.reactSubviews) { + if ([subview isKindOfClass:[RNSScreenStackHeaderConfig class]]) { + [((RNSScreenStackHeaderConfig*) subview) setAnimatedConfig:fromVC]; + break; + } + } + } + }]; } else { [self setAnimatedConfig:vc]; } diff --git a/src/screens.native.js b/src/screens.native.js index c438d2de..42a4d3a8 100644 --- a/src/screens.native.js +++ b/src/screens.native.js @@ -139,7 +139,7 @@ const styles = StyleSheet.create({ }, }); -export const ScreenStackHeaderRightView = props => ( +const ScreenStackHeaderRightView = props => ( ( /> ); -export const ScreenStackHeaderLeftView = props => ( +const ScreenStackHeaderLeftView = props => ( ( /> ); -export const ScreenStackHeaderTitleView = props => ( +const ScreenStackHeaderTitleView = props => ( ( /> ); -export const ScreenStackHeaderCenterView = props => ( +const ScreenStackHeaderCenterView = props => ( ); + module.exports = { ScreenContainer, Screen, @@ -190,6 +191,10 @@ module.exports = { get ScreenStackHeaderSubview() { return ScreensNativeModules.NativeScreenStackHeaderSubview; }, + ScreenStackHeaderRightView, + ScreenStackHeaderLeftView, + ScreenStackHeaderTitleView, + ScreenStackHeaderCenterView, useScreens, screensEnabled,