Skip to content

refactor: move ScreenGestureDetector to ScreenStack#2449

Merged
maciekstosio merged 21 commits intomainfrom
@maciekstosio/refactor-custom-screen-transition
Nov 4, 2024
Merged

refactor: move ScreenGestureDetector to ScreenStack#2449
maciekstosio merged 21 commits intomainfrom
@maciekstosio/refactor-custom-screen-transition

Conversation

@maciekstosio
Copy link
Copy Markdown
Contributor

@maciekstosio maciekstosio commented Oct 25, 2024

Description

This PR moves logic required by Custom Screen Transition to react-native-screens from react-navigation (see react-navigation/react-navigation#11943). Instead of wrapping ScreenStack in NativeStack in react-navigation, we would add it to ScreenStack.

Testing

See Example App > Swipe Back Animation (changes from react-navigation required: react-navigation/react-navigation#12204)

Checklist

Base automatically changed from @maciekstosio/fix-customs-screen-transitions- to main October 30, 2024 15:37
@maciekstosio maciekstosio marked this pull request as ready for review October 31, 2024 11:23
@maciekstosio maciekstosio requested review from alduzy and kkafar and removed request for kkafar October 31, 2024 11:23
Copy link
Copy Markdown
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

  1. Haven't tested the runtime, please ensure screen transitions work.
  2. The code changes look reasonable. I'm glad we stayed with wrapping only screen stack with single gesture detector (in opposition to wrapping every screen).
  3. Few questions & suggestions below.
  4. Great job overall!

Comment thread src/components/ScreenStack.tsx Outdated
Comment on lines +65 to +79
const isGestureDetectorProviderNotDetected =
ScreenGestureDetector.name !== 'GHWrapper' && goBackGesture !== undefined;
const isGestureDetectorNotConfiguredProperly =
goBackGesture !== undefined &&
screensRefs === undefined &&
currentScreenId === undefined;

warnOnce(
isGestureDetectorProviderNotDetected,
'Cannot detect GestureDetectorProvider in a screen that uses `goBackGesture`. Make sure your navigator is wrapped in GestureDetectorProvider.',
);
warnOnce(
isGestureDetectorNotConfiguredProperly,
'Custom Screen Transition require screensRefs and currentScreenId to be provided.',
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extract this to some helper function please

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed in: a875f37

Comment thread src/types.tsx Outdated
Comment on lines +500 to +504
screensRefs?: GestureProviderProps['screensRefs'];
currentScreenId?: GestureProviderProps['currentScreenId'];
goBackGesture?: GestureProviderProps['goBackGesture'];
screenEdgeGesture?: GestureProviderProps['screenEdgeGesture'];
transitionAnimation?: GestureProviderProps['transitionAnimation'];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make something with these being repeated here? keyof ... operator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What about changing into interfaces? Changed in: 79571e2

Comment thread src/types.tsx
@maciekstosio
Copy link
Copy Markdown
Contributor Author

Haven't tested the runtime, please ensure screen transitions work.

iOS Android
CST-iOS.mov
CST-Android.mov

I will test it again once everything merged.

@maciekstosio maciekstosio requested a review from kkafar November 4, 2024 14:21
Copy link
Copy Markdown
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

I think we're good now!

Copy link
Copy Markdown
Contributor

@alduzy alduzy left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants