MCPcopy Create free account
hub / github.com/PatoSala/react-native-blocks / pickImage

Function pickImage

packages/blocks/src/ImageBlock.tsx:28–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 const [aspectRatio, setAspectRatio] = useState(blocks[blockId]?.format?.block_aspect_ratio || null);
27
28 const pickImage = async () => {
29 let result = await ImagePicker.launchImageLibraryAsync({
30 mediaTypes: ['images'],
31 allowsEditing: false,
32 quality: 1,
33 });
34
35 if (!result.canceled) {
36 setSource(result.assets[0].uri);
37 setAspectRatio(result.assets[0].width / result.assets[0].height);
38
39 const updatedBlock = updateBlockData(blocks[blockId], {
40 properties: {
41 source: result.assets[0].uri
42 },
43 format: {
44 block_width: result.assets[0].width,
45 block_aspect_ratio: result.assets[0].width / result.assets[0].height
46 }
47 });
48
49 updateBlock(updatedBlock);
50 }
51 };
52
53 const handleRemoveBlock = () => {
54 setSelectedBlockId(null);

Callers

nothing calls this directly

Calls 2

updateBlockDataFunction · 0.90
updateBlockFunction · 0.85

Tested by

no test coverage detected