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

feat: add full width swipe option #1072

Merged
merged 12 commits into from
Sep 1, 2021

Conversation

WoLewicki
Copy link
Member

@WoLewicki WoLewicki commented Aug 24, 2021

Description

PR adding an option on iOS to begin the swipe gesture in any place on the screen. Since it comes with a custom gesture recognizer, the transition animation must be provided, therefore simple_push animation has been chosen as the closest one to the default. Requested in #251.

Be aware that using this option with gestureEnabled set to true will cancel JS recognizers on the screen when using vertical or horizontal swipe gesture.

Changes

Added fullWidthGestureEnabled prop with the described behavior.

Test1072.tsx

Checklist

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left a couple minor comments inline.


#### `gestureEnabled`
#### `fullWidthGestureEnabled` (iOS only)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to sth like fullScreenSwipeEnabled – "width" seem like a weird choice of word as it applies to the area. Also "gesture" is a term that we use for things like sliding down modals, so maybe "swipe" is a better word as it suggest that this only applies to swiping left?

Comment on lines 566 to 567
// we want only `RNSPanGestureRecognizer` to be able to recognize when
// `fullWidthGestureEnabled` is set and only then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rephrase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
[self animateSimplePushWithTransitionContext:transitionContext toVC:toViewController fromVC:fromViewController];
}
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally try to avoid early returns if there exists a more logical structure of the conditions. It appears like it'd suffice to put the remainig code in else block here and that'd result in the same behavior w/o a need of using return here

@WoLewicki WoLewicki merged commit 66b1d97 into master Sep 1, 2021
@WoLewicki WoLewicki deleted the @wolewicki/ios-gesture-response-distance branch September 1, 2021 08:50
@timurridjanovic
Copy link

Is this supposed to work in @react-navigation/native-stack?
Can't seem to make it work

@WoLewicki
Copy link
Member Author

I think that since https://github.com/react-navigation/react-navigation/blob/main/packages/native-stack/src/views/NativeStackView.native.tsx#L176 does not spread all of the props, all of the new ones need to be added there explicitly, so we need new version of @react-navigation/native-stack in order for new props from react-native-screens to work. We would love to accept a PR with such change 🎉 You can ping me and/or @kacperkapusciak in it for faster review.

@ettnn
Copy link

ettnn commented Jan 24, 2022

Any updates on this @WoLewicki ?

@WoLewicki
Copy link
Member Author

Are you asking about v6 version of this? If so, I am afraid there is still no PR with this option there.

@kyang6
Copy link

kyang6 commented Jan 26, 2022

I'd love to help out, is the PR simply adding fullWidthGestureEnabled as a prop to NativeStackView.native.tsx and then passing it down into Screen?

@ettnn
Copy link

ettnn commented Jan 26, 2022

Yeah that's all were looking for!

@WoLewicki
Copy link
Member Author

@kyang6 I believe there should not be much that needs to be done to make it work.

@kyang6
Copy link

kyang6 commented Jan 26, 2022

Gotcha! Quick question, has fullWidthGestureEnabled been added to ScreenProps?
[EDIT] I see, fullScreenSwipeEnabled is added in 3.10.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants