Skip to content

Commit 72e6eda

Browse files
authored
Merge pull request #14 from MocanuMarius/master
added README.md example for saving to disk
2 parents 4a94560 + 9a8dc41 commit 72e6eda

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,32 @@ logoBackgroundColor | backgroundColor | The logo gets a filled quadratic
101101
getRef | null | Get SVG ref for further usage
102102

103103

104+
## Saving generated code to gallery
105+
_Note: Experimental only ( not tested on iOS) , uses getRef() and needs [RNFS module](https://github.com/itinance/react-native-fs)_
106+
107+
npm install --save react-native-fs
108+
109+
### Example for Android:
110+
```
111+
import { CameraRoll , ToastAndroid } from "react-native"
112+
import RNFS from "react-native-fs"
113+
.....
114+
115+
saveQrToDisk() {
116+
this.svg.toDataURL((data) => {
117+
RNFS.writeFile(RNFS.CachesDirectoryPath+"/some-name.png", data, 'base64')
118+
.then((success) => {
119+
return CameraRoll.saveToCameraRoll(RNFS.CachesDirectoryPath+"/some-name", 'photo')
120+
})
121+
.then(() => {
122+
this.setState({ busy: false, imageSaved: true })
123+
ToastAndroid.show('Saved to gallery !!', ToastAndroid.SHORT)
124+
})
125+
})
126+
}
127+
```
128+
129+
104130
### Dependencies
105131

106132
* [react-native-svg](https://github.com/magicismight/react-native-svg)

0 commit comments

Comments
 (0)