Skip to content

Commit 713cb04

Browse files
sebmarkbageLukeDurrant
authored andcommitted
Move takeSnapshot from React repo to RN
Reviewed By: sophiebits Differential Revision: D7547298 fbshipit-source-id: 6ab0c0a9e244a2f68d27307b84285b2c8fff1342
1 parent ad3197d commit 713cb04

File tree

2 files changed

+48
-17
lines changed

2 files changed

+48
-17
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @providesModule takeSnapshot
8+
* @format
9+
* @flow
10+
*/
11+
12+
const ReactNative = require('ReactNative');
13+
const UIManager = require('UIManager');
14+
15+
/**
16+
* Capture an image of the screen, window or an individual view. The image
17+
* will be stored in a temporary file that will only exist for as long as the
18+
* app is running.
19+
*
20+
* The `view` argument can be the literal string `window` if you want to
21+
* capture the entire window, or it can be a reference to a specific
22+
* React Native component.
23+
*
24+
* The `options` argument may include:
25+
* - width/height (number) - the width and height of the image to capture.
26+
* - format (string) - either 'png' or 'jpeg'. Defaults to 'png'.
27+
* - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default).
28+
*
29+
* Returns a Promise.
30+
* @platform ios
31+
*/
32+
module.exports = function takeSnapshot(
33+
view?: 'window' | React$Element<any> | number,
34+
options?: {
35+
width?: number,
36+
height?: number,
37+
format?: 'png' | 'jpeg',
38+
quality?: number,
39+
},
40+
): Promise<any> {
41+
if (typeof view !== 'number' && view !== 'window') {
42+
view = ReactNative.findNodeHandle(view) || 'window';
43+
}
44+
45+
// Call the hidden '__takeSnapshot' method; the main one throws an error to
46+
// prevent accidental backwards-incompatible usage.
47+
return UIManager.__takeSnapshot(view, options);
48+
};

Libraries/Renderer/shims/takeSnapshot.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)