-
-
Save gwendall/219728ae019cc10a03b3a408363d955c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function Stickers({ stickers = [] }: { stickers: Sticker[] }) { | |
const [matrixes, setMatrixes] = React.useState<SharedValue<SkMatrix>[]>([]); | |
React.useEffect(() => { | |
setMatrixes(stickers.map(() => makeMutable(Skia.Matrix()))); | |
}, [stickers]); | |
return ( | |
<> | |
<Canvas> | |
{stickers.map((sticker, index) => ( | |
<Group key={sticker.id} matrix={matrixes[index]}> | |
<Image | |
image={image} | |
/> | |
</Group> | |
))} | |
</Canvas> | |
{stickers.map((sticker, index) => { | |
const dimensions = rect( | |
sticker.x, | |
sticker.y, | |
sticker.width, | |
sticker.width, | |
); | |
if (matrixes[index]) { | |
return ( | |
<GestureHandler | |
key={`gesture-handler-${sticker.id}`} | |
matrix={matrixes[index]} | |
dimensions={dimensions} | |
/> | |
); | |
} | |
return null; | |
})} | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment