Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Move takeSnapshot from React repo to RN
Browse files Browse the repository at this point in the history
Reviewed By: sophiebits

Differential Revision: D7547298

fbshipit-source-id: 6ab0c0a9e244a2f68d27307b84285b2c8fff1342
  • Loading branch information
sebmarkbage authored and campsafari committed Apr 11, 2018
1 parent 48642c1 commit e4434e5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
48 changes: 48 additions & 0 deletions Libraries/ReactNative/takeSnapshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule takeSnapshot
* @format
* @flow
*/

const ReactNative = require('ReactNative');
const UIManager = require('UIManager');

/**
* Capture an image of the screen, window or an individual view. The image
* will be stored in a temporary file that will only exist for as long as the
* app is running.
*
* The `view` argument can be the literal string `window` if you want to
* capture the entire window, or it can be a reference to a specific
* React Native component.
*
* The `options` argument may include:
* - width/height (number) - the width and height of the image to capture.
* - format (string) - either 'png' or 'jpeg'. Defaults to 'png'.
* - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default).
*
* Returns a Promise.
* @platform ios
*/
module.exports = function takeSnapshot(
view?: 'window' | React$Element<any> | number,
options?: {
width?: number,
height?: number,
format?: 'png' | 'jpeg',
quality?: number,
},
): Promise<any> {
if (typeof view !== 'number' && view !== 'window') {
view = ReactNative.findNodeHandle(view) || 'window';
}
// Call the hidden '__takeSnapshot' method; the main one throws an error to
// prevent accidental backwards-incompatible usage.
return UIManager.__takeSnapshot(view, options);
};
17 changes: 0 additions & 17 deletions Libraries/Renderer/shims/takeSnapshot.js

This file was deleted.

0 comments on commit e4434e5

Please sign in to comment.