Browse Source

Rename name prop to filename and add it to README

Victor Calvello 8 years ago
parent
commit
ac723f8dd8

+ 1
- 0
README.md View File

39
     - `"file"` (default): save to a temporary file *(that will only exist for as long as the app is running)*.
39
     - `"file"` (default): save to a temporary file *(that will only exist for as long as the app is running)*.
40
     - `"base64"`: encode as base64 and returns the raw string. Use only with small images as this may result of lags (the string is sent over the bridge). *N.B. This is not a data uri, use `data-uri` instead*.
40
     - `"base64"`: encode as base64 and returns the raw string. Use only with small images as this may result of lags (the string is sent over the bridge). *N.B. This is not a data uri, use `data-uri` instead*.
41
     - `"data-uri"`: same as `base64` but also includes the [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme) header.
41
     - `"data-uri"`: same as `base64` but also includes the [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme) header.
42
+ - **`filename`** *(string)*: the name of the generated file if any (Android only). Defaults to `ReactNative_snapshot_image_${timestamp}`.
42
 
43
 
43
 ## Notes
44
 ## Notes
44
 
45
 

+ 1
- 1
android/src/main/java/fr/greweb/reactnativeviewshot/RNViewShotModule.java View File

65
         Integer height = options.hasKey("height") ? (int)(displayMetrics.density * options.getDouble("height")) : null;
65
         Integer height = options.hasKey("height") ? (int)(displayMetrics.density * options.getDouble("height")) : null;
66
         String result = options.hasKey("result") ? options.getString("result") : "file";
66
         String result = options.hasKey("result") ? options.getString("result") : "file";
67
         try {
67
         try {
68
-            String name = options.hasKey("name") ? options.getString("name") : null;
68
+            String name = options.hasKey("filename") ? options.getString("filename") : null;
69
             File tmpFile = "file".equals(result) ? createTempFile(getReactApplicationContext(), format, name) : null;
69
             File tmpFile = "file".equals(result) ? createTempFile(getReactApplicationContext(), format, name) : null;
70
             UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
70
             UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
71
             uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, tmpFile, result, promise));
71
             uiManager.addUIBlock(new ViewShot(tag, format, compressFormat, quality, width, height, tmpFile, result, promise));

+ 1
- 1
index.js View File

12
     format ?: "png" | "jpg" | "jpeg" | "webm";
12
     format ?: "png" | "jpg" | "jpeg" | "webm";
13
     quality ?: number;
13
     quality ?: number;
14
     base64 ?: bool;
14
     base64 ?: bool;
15
-    name ?: string;
15
+    filename ?: string;
16
   }
16
   }
17
 ): Promise<string> {
17
 ): Promise<string> {
18
   if (typeof view !== "number") {
18
   if (typeof view !== "number") {