import { Circle, Group, Line, vec } from "@shopify/react-native-skia"; import { useDerivedValue } from "react-native-reanimated"; import type { DerivedValue, SharedValue } from "react-native-reanimated"; export interface CursorProps { /** The x position of the cursor */ x: SharedValue; /** The y position of the cursor */ y: DerivedValue; /** The canvas height */ height: number; /** The radius of the cursor */ cursorRadius: number; /** The color of the cursor */ cursorColor: string; /** * The color of the cursor line. * @default "rgba(0, 0, 0, 0.5)" */ cursorLineColor: string; /** * The width of the cursor line. * @default 2 */ cursorLineWidth: number; /** * Whether to hide the cursor line. * @default false */ hideCursorLine: boolean; } type CursorLineProps = Pick; const CursorLine: React.FC = ({ x, height, cursorLineColor, cursorLineWidth }) => { const transform = useDerivedValue(() => { return [{ translateX: x.value }]; }); return ( ); }; export const Cursor: React.FC = ({ x, y, height, cursorRadius, cursorColor, cursorLineColor, cursorLineWidth, hideCursorLine, }) => { const cursorTransform = useDerivedValue(() => { return [{ translateX: x.value }, { translateY: y.value }]; }, []); return ( <> {!hideCursorLine && ( )} ); };