Browse Source

Rename name prop to filename and add it to README

Victor Calvello 7 years ago
parent
commit
ac723f8dd8

+ 1
- 0
README.md View File

@@ -39,6 +39,7 @@ Returns a Promise of the image URI.
39 39
     - `"file"` (default): save to a temporary file *(that will only exist for as long as the app is running)*.
40 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 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 44
 ## Notes
44 45
 

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

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

+ 1
- 1
index.js View File

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