$ git show emoji-reactions
Emoji reactions
Long-press Like to open a bar of reactions, slide your finger along it to magnify each one, and let go to pick.
👍❤️😂😮😢
👍 Likeimport { scheduleOnRN } from 'react-native-worklets';
// Gesture-driven, so Reanimated 4 keeps shared values; scheduleOnRN replaces runOnJS
const EMOJI = ['👍', '❤️', '😂', '😮', '😢', '😡'];
const SIZE = 44;
const open = useSharedValue(0);
const hovered = useSharedValue(-1);
const pan = Gesture.Pan()
.activateAfterLongPress(300)
.onStart(() => { open.value = withSpring(1, { damping: 14 }); })
.onUpdate((e) => {
const overBar = e.y < 0 && e.y > -BAR_Y - SIZE;
const i = Math.floor((e.x - 8) / SIZE);
hovered.value = overBar && i >= 0 && i < EMOJI.length ? i : -1;
})
.onFinalize(() => {
if (hovered.value >= 0) scheduleOnRN(onReact, EMOJI[hovered.value]);
hovered.value = -1;
open.value = withTiming(0, { duration: 150 });
});
function Emoji({ index, char }) {
const style = useAnimatedStyle(() => {
const on = hovered.value === index;
return {
transform: [
{ translateY: interpolate(open.value, [index * 0.08, index * 0.08 + 0.5], [20, 0], Extrapolation.CLAMP) },
{ translateY: withSpring(on ? -14 : 0) },
{ scale: withSpring(on ? 1.6 : hovered.value >= 0 ? 0.85 : 1) },
],
};
});
return <Animated.Text style={[{ fontSize: 30, width: SIZE, textAlign: 'center', transformOrigin: 'bottom' }, style]}>{char}</Animated.Text>;
}
const bar = useAnimatedStyle(() => ({
opacity: open.value,
transform: [{ scale: interpolate(open.value, [0, 1], [0.6, 1]) }],
}));
<View>
<Animated.View pointerEvents="none" style={[styles.bar, { transformOrigin: 'left bottom' }, bar]}>
{EMOJI.map((ch, i) => <Emoji key={ch} index={i} char={ch} />)}
</Animated.View>
<GestureDetector gesture={Gesture.Exclusive(pan, Gesture.Tap().onEnd(() => scheduleOnRN(onReact, '👍')))}>
<View style={styles.likeButton}><Text>👍 Like</Text></View>
</GestureDetector>
</View>