Skip to content

Conversation

@akwasniewski
Copy link
Contributor

@akwasniewski akwasniewski commented Dec 2, 2025

Description

Made a new PR, as it is easier than attempt to merge the old one with next.

This PR adds a toggle in the example app to switch between Legacy and V3 api examples. In the new api section I added split into few sections. Most of them are rewritten old V2 examples with more consistent styling.
I also added a Feedback component to showcase features console free.
The new examples are:

  • basic examples for every gestures
  • lock to showcase combining gestures
  • sharedValue, nestedText, svg - to showcase VirtualDetector
  • animated - to showcase cooperation with animated

Test plan

See if the examples in new api section from common-example work

@akwasniewski akwasniewski changed the base branch from main to next December 2, 2025 10:18
@akwasniewski akwasniewski mentioned this pull request Dec 2, 2025
9 tasks
@akwasniewski akwasniewski changed the title examples V3 examples Dec 2, 2025
Copy link
Member

@j-piasecki j-piasecki left a comment

Choose a reason for hiding this comment

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

I've been seeing

[Worklets] Tried to modify key current of an object which has been already passed to a worklet. See
https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-modify-key-of-an-object-which-has-been-converted-to-a-shareable
for more details.

when running the examples (Svg for example). Could you investigate it?

</View>
<Text style={styles.instructions}>
The ball has simultanous pan and longPress gestures. Upon update pan
changes minDistanceof longPress, such that longPress will fail if is
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
changes minDistanceof longPress, such that longPress will fail if is
changes maxDistance of longPress, such that longPress will fail if it's

Copy link
Contributor Author

Choose a reason for hiding this comment

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

});
},
minDuration: 1000,
maxDistance: maxLongPressDistance,
Copy link
Member

Choose a reason for hiding this comment

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

On iOS, maxDistance doesn't seem to do anything. Could you investigate that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #3906

return (
<View style={styles.container}>
<GestureDetector gesture={panGesture}>
<Animated.View
Copy link
Member

Choose a reason for hiding this comment

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

I like this one! Can it also change background color on onBegin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I also made it turn red/green on tilt 68893ad

Comment on lines 35 to 37
<ButtonWrapper ButtonComponent={BaseButton} color={COLORS.KINDA_BLUE} />
<ButtonWrapper ButtonComponent={RectButton} color={COLORS.NAVY} />
<ButtonWrapper ButtonComponent={BorderlessButton} color={COLORS.PURPLE} />
Copy link
Member

Choose a reason for hiding this comment

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

They only console.log when pressed, should they also show some message on screen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They should 6b70961

SHOW_LEGACY_EXAMPLES_KEY,
]).then(([openLastExample, lastExample, showLegacyExamples]) => {
const showLegacy = showLegacyExamples[1] === 'true';
if (showLegacyExamples[1]) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (showLegacyExamples[1]) {
if (showLegacyExamples[1] != null) {

I'm not sure whether this is what this check was supposed to do, or whether it should check showLegacy - imo it should be explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, b16d4f1

onActivate: () => {
'worklet';
runOnJS(startRecording)();
captureProgress.value = withTiming(1, { duration: VIDEO_DURATION });
Copy link
Member

Choose a reason for hiding this comment

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

I think this is missing easing: Easing.linear - the animation speeds up and slows down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// Tap to lock
const tap = useTapGesture({
onDeactivate: () => {
'worklet';
Copy link
Member

Choose a reason for hiding this comment

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

If you use the latest react-native-worklets, this directive should be auto-included. Maybe it's worth it to update worklets and remove the directive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, great. Thank you, removed in de7371a

@@ -0,0 +1,156 @@
import { COLORS, Feedback } from '../../../common';
Copy link
Member

Choose a reason for hiding this comment

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

This is not platform-specific, it just requires additional hardware on mobile (mouse, stylus).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, i was trying to group the examples more logically then before. I think they should grouped together, but could not find a good section name. For now renamed it to 'Hover and mouse' 1679ca6. Let me now if you have a better name. Do you have better ideas, for grouping in general? cc @m-bert

<View style={styles.subcontainer}>
<View style={styles.row}>
<Text style={styles.text}>Overlap Siblings</Text>
<InterceptingGestureDetector>
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why InterceptingGestureDetector here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then it won't change which square is on top, as overlap only supports this for siblings. We cannot apply elevated on the GestureDetector, thus I decided VirtualDetector works best here.

<View style={styles.row}>
<Text style={styles.text}>Overlap Child</Text>

<InterceptingGestureDetector>
Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link
Contributor

@m-bert m-bert left a comment

Choose a reason for hiding this comment

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

Okay, here are mu findings 🫨 I'm not sure if any of them will be fixed when we merge next, but hopefully there are a few like this 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

I also thought about splitting this file into multiple files, as it contains quite a lot elements. Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split somewhat in d700fbd. I don't think further splitting makes sense as the gestures are preety intertwined. Let me know what you think.

Comment on lines +21 to +22
x: Animated.SharedValue<number>;
y: Animated.SharedValue<number>;
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can see, importing SharedValue form Animated namespace is deprecated.

Image

this part is not special :(
</Text>
</GestureDetector>
<Feedback ref={feedbackRef} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like it is not shown:

Screen.Recording.2026-01-07.at.13.57.21.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The legacy detector one only works on web, I left it there to highlight that it did not work in v2. I can remove the bottom part if you wish.

Copy link
Contributor

Choose a reason for hiding this comment

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

Beside color blinking at entering, it seems to be broken on android.

Screen.Recording.2026-01-07.at.14.00.12.mov

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll just leave a comment - it seems that it doesn't work, but I'm not sure if this is because next has not been merged yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not for this PR, as it only changed colors, but it breaks when type is changed to back:

Screen.Recording.2026-01-07.at.14.11.13.mov

// eslint-disable-next-line import-x/no-commonjs, @typescript-eslint/no-var-requires
const SCREENS = require('../../../common_assets/hoverable_icons/screens.png');

const images = [GH, REA, SCREENS, SVG, FREEZE];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should change how those are displayed 🫨

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 0232a84

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.

4 participants