This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move takeSnapshot from React repo to RN
Reviewed By: sophiebits Differential Revision: D7547298 fbshipit-source-id: 6ab0c0a9e244a2f68d27307b84285b2c8fff1342
- Loading branch information
1 parent
48642c1
commit e4434e5
Showing
2 changed files
with
48 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
This file was deleted.
Oops, something went wrong.