-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
fix(iOS): push and pop transitions change after full screen back swipe #2234
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a tine remark, other than that - great job!
ios/RNSScreenStack.mm
Outdated
@@ -752,7 +752,7 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer | |||
[self cancelTouchesInParent]; | |||
return YES; | |||
#else | |||
// RNSPanGestureRecognizer will receive events iff topScreen.fullScreenSwipeEnabled == YES; | |||
// RNSPanGestureRecognizer will receive events if topScreen.fullScreenSwipeEnabled == YES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iff
is intentional - it is widely used, especially in mathematics & stands for if and only if
(wtedy i tylko wtedy
) 😄
// RNSPanGestureRecognizer will receive events if topScreen.fullScreenSwipeEnabled == YES; | |
// RNSPanGestureRecognizer will receive events iff topScreen.fullScreenSwipeEnabled == YES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, haven't heard about that one before. That's good to know, thanks for enlightening me! 😃 I will revert that change
@@ -872,6 +872,7 @@ - (void)handleSwipe:(UIPanGestureRecognizer *)gestureRecognizer | |||
[_interactionController cancelInteractiveTransition]; | |||
} | |||
_interactionController = nil; | |||
_isFullWidthSwiping = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so the main issue (change of transition style after popping a screen with swipe for the very first time) was caused by not properly reset state. Great finding!
ios/RNSScreenStackAnimator.mm
Outdated
[UIView animateWithDuration:[self transitionDuration:transitionContext] | ||
animations:^{ | ||
fromViewController.view.transform = leftTransform; | ||
toViewController.view.transform = CGAffineTransformIdentity; | ||
shadowView.alpha = 0.1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only suggestion here would be to extract this target alpha value to a constant, see the top of the RNSScreenStackAnimator.mm
file (maybe use constexpr
instead of static const) & if there is any reasoning behind this value (e.g. "Looked best in experimentation") - leave a comment behind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, I'll extract it and I'll add a comment a comment with explanation
6a729b4
to
34420b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing, and we're good to go.
ios/RNSScreenStackAnimator.mm
Outdated
@@ -9,6 +9,9 @@ | |||
static const float RNSSlideCloseTransitionDurationProportion = 0.25 / 0.35; | |||
static const float RNSFadeCloseTransitionDurationProportion = 0.15 / 0.35; | |||
static const float RNSFadeCloseDelayTransitionDurationProportion = 0.1 / 0.35; | |||
// same value is used in other projects using similar approach for transistions | |||
// and it looks the most similar to the value used by Apple | |||
constexpr float RNSShadowViewMaxAlpha = 0.1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk why I suggested sole constexpr
here, let's make it static
also, so that the definition is visible only in this translation unit.
constexpr float RNSShadowViewMaxAlpha = 0.1; | |
static constexpr float RNSShadowViewMaxAlpha = 0.1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid doing it like this is a breaking change. When people use fullScreenSwipe
right now, they don't have the shadow included. With those changes, it will appear which can be not expected by the users. Shouldn't we make this an optional prop of screen/navigator instead?
34420b2
to
c30c7d3
Compare
I considered it rather a fix, than breaking the behaviour. Although I can see your point. One thing for sure: the change responsible for using default animation for programming push / pop after popping a screen with a gesture is a fix & it should be merged as is. The code responsible for adding a dimming view for swipe-transition might be hidden behind a prop, as opt-in. @maksg @WoLewicki Let's split this PR into two separate ones. Does that sound right? |
c30c7d3
to
37d59ba
Compare
I moved shadow view implementation to #2239 |
I have just played around with this branch and it seems that this issue shows up again randomly. As in, every so often navigation still uses the incorrect transition, it is now very rare. Are there more cases where Sorry I know that's not particularly helpful, I was swiping around a lot in a large app and have seen it a few times. |
@jwoodmansey Can you post a video where you trigger the buggy behaviour? Maybe we can figure out the scenario in which in happens together somehow. Despite the fact, this PR improves the situation. We should proceed @maksg. |
…adow during swipe gesture (#2239) ## Description When using full screen swipe back there was no shadow under the view. Related PR #2234 with discussion about this change. Corresponding PR in `react-navigation`: * react-navigation/react-navigation#12053 ## Changes Added shadow to transition in animateSimplePushWithTransitionContext:toVC:fromVC:. ## Test code and steps to reproduce 1. Run `Test2227` in TestsExample app. 2. Push screen with Go to Details. 3. Swipe back with full screen swipe gesture. 5. Before this fix there would be no shadow during transition with full screen swipe back. ## Checklist - [x] Included code example that can be used to test this change - [ ] Updated TS types - [x] Updated documentation: <!-- For adding new props to native-stack --> - [x] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes
software-mansion#2234) ## Description Doing the swipe also caused programmatic push to use manual transition and have no shadow. Fixes software-mansion#2227. ## Changes Set `_isFullWidthSwiping` to `NO` when swipe gesture ends in `handleSwipe:` so programmatic push and pop can use OS logic by default. ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/11507974/0f710aec-c8f0-4a3a-82df-d3edb5f0fb19 ### After https://github.com/software-mansion/react-native-screens/assets/11507974/51119c74-b2c3-4c32-9202-6954c3c70218 ## Test code and steps to reproduce 1. Run `Test2227` in TestsExample app. 2. Push screen with `Go to Details`. 3. Swipe back with full screen swipe gesture. 4. Push screen with `Go to Details` again. 7. Before this fix there would be no shadow during transition after first full screen swipe back. ## Checklist - [x] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: <!-- For adding new props to native-stack --> - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes
…adow during swipe gesture (software-mansion#2239) ## Description When using full screen swipe back there was no shadow under the view. Related PR software-mansion#2234 with discussion about this change. Corresponding PR in `react-navigation`: * react-navigation/react-navigation#12053 ## Changes Added shadow to transition in animateSimplePushWithTransitionContext:toVC:fromVC:. ## Test code and steps to reproduce 1. Run `Test2227` in TestsExample app. 2. Push screen with Go to Details. 3. Swipe back with full screen swipe gesture. 5. Before this fix there would be no shadow during transition with full screen swipe back. ## Checklist - [x] Included code example that can be used to test this change - [ ] Updated TS types - [x] Updated documentation: <!-- For adding new props to native-stack --> - [x] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes
Description
Doing the swipe also caused programmatic push to use manual transition and have no shadow.
Fixes #2227.
Changes
Set
_isFullWidthSwiping
toNO
when swipe gesture ends inhandleSwipe:
so programmatic push and pop can use OS logic by default.Screenshots / GIFs
Before
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-05.at.16.43.46.mp4
After
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-05.at.16.44.34.mp4
Test code and steps to reproduce
Test2227
in TestsExample app.Go to Details
.Go to Details
again.Checklist