$ git show activity-rings

Activity rings

Intermediate/anim activity-rings

Three concentric progress rings fill up with an ease-out, like the Apple Watch rings.

Inspired by Apple ActivityFrom William Candillon’s “Can it be done in React Native?” series. The code here is a simplified rewrite for Reanimated 4 and 3.
Main · New Architecture only · worklets live in react-native-worklets

This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.

useAnimatedPropsstrokeDashoffsetreact-native-svg
activity-rings.tsx · reanimated 4
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
function Ring({ r, progress, color }) {
  const C = 2 * Math.PI * r;
  const p = useSharedValue(0);
  useEffect(() => {
    p.value = withTiming(progress, { duration: 1200, easing: Easing.out(Easing.cubic) });
  }, [progress]);
  const props = useAnimatedProps(() => ({ strokeDashoffset: C * (1 - p.value) }));
  return (
    <AnimatedCircle cx={SIZE / 2} cy={SIZE / 2} r={r} stroke={color} strokeWidth={STROKE}
      strokeLinecap="round" fill="none" strokeDasharray={C} animatedProps={props} />
  );
}
// <Svg style={{ transform: [{ rotate: '-90deg' }] }}> with three Rings of decreasing r