terrylinla / react-native-sketch-canvas

A React Native component for drawing by touching on both iOS and Android.
MIT License
691 stars 450 forks source link

How to save customized SketchCanvas #239

Open nueza99 opened 9 months ago

nueza99 commented 9 months ago

Hi I am customizing my canvas to be able to add text, sketch, images etc. so this is very short code of it. I have Save button, and need to get the image file path, but I am not sure how to get that. Always getting undefined This is my code

<SketchCanvas ref={sketchCanvasRef} style={{ backgroundColor: 'transparent', flex: 1, position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, }} strokeWidth={5} strokeColor={isStrokeColor} touchEnabled={isPencil || isEraser ? true : false} savePreference={() => { return { folder: 'NiRNSketchCanvas', filename: String(Math.ceil(Math.random() * 100000000)), transparent: false, imageType: 'png', }; }} // onSketchSaved={handleSave} />

and this is my save button

<View> <TouchableOpacity style={styles.functionButton} onPress={handleSave}> <Text style={{color: 'white'}}>Save</Text> </TouchableOpacity> </View>

and this is my save function ` const handleSave = () => {

  //HERE I AM THINKING IT IS SAVED TO CAMERA ROLL AND NEED TO GET THE IMAGE URL PATH

};`

if i use RNSketchCanvas(use saveComponent & savePreferences) it get saved to my camera roll, but if i use Sketch Canvas, not save into my camera roll.