Skip to content

Commit e4bc8c4

Browse files
Make "Snapshot/Screenshot" test page works (microsoft#546)
* Add ScreenshotManagerTurboModule, but it is not called. * ... * Update AppDelegate.mm * Fix code due to facebook API rename * Update AppDelegate.mm * [Pods] Expose boost headers to consumer of RCT-Folly (#1) * Update AppDelegate.mm * ScreenshotManagerTurboModule gets called * reject the promise in takeScreenshot * ... * Put TurboModuleRegistry.get call at the right place * ... * Successfully took the screenshot * Remove unnecessary code * Fix code review comments * Fix code review comments * ... * Fix code review comments * Fix build break * Fix build break * Fix build break * Update NativeScreenshotManager.js * Fix build break * Fix yarn lint errors Co-authored-by: Eloy Durán <[email protected]>
1 parent 92b68a5 commit e4bc8c4

File tree

8 files changed

+233
-32
lines changed

8 files changed

+233
-32
lines changed

RNTester/NativeModuleExample/NativeScreenshotManager.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ import * as TurboModuleRegistry from '../../Libraries/TurboModule/TurboModuleReg
1515

1616
export interface Spec extends TurboModule {
1717
+getConstants: () => {||};
18-
takeSnapshot(id: string): Promise<string>;
18+
takeScreenshot(
19+
id: string,
20+
options: {format: string, quality?: number},
21+
): Promise<string>;
1922
}
2023

21-
const NativeModule = TurboModuleRegistry.get<Spec>('ScreenshotManager');
22-
23-
export function takeSnapshot(id: string): Promise<string> {
24-
if (NativeModule != null) {
25-
return NativeModule.takeSnapshot(id);
26-
}
27-
return Promise.reject();
28-
}
24+
export const NativeModule = (TurboModuleRegistry.get<Spec>(
25+
'ScreenshotManager',
26+
): ?Spec);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
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+
8+
#import <React/RCTViewManager.h>
9+
#import <ReactCommon/RCTTurboModuleManager.h>
10+
11+
@interface ScreenshotManagerTurboModuleManagerDelegate : NSObject<RCTTurboModuleManagerDelegate>
12+
- (std::shared_ptr<facebook::react::TurboModule>)
13+
getTurboModule:(const std::string &)name
14+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker;
15+
16+
- (std::shared_ptr<facebook::react::TurboModule>)
17+
getTurboModule:(const std::string &)name
18+
instance:(id<RCTTurboModule>)instance
19+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker;
20+
21+
@end
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
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+
8+
#import "ScreenshotMacOS.h"
9+
#import <React/RCTUIManager.h>
10+
#import <React/RCTUtils.h>
11+
#import <ReactCommon/RCTTurboModuleManager.h>
12+
#import <ReactCommon/TurboModuleUtils.h>
13+
14+
static NSImage* TakeScreenshot()
15+
{
16+
// find the key window
17+
NSWindow* keyWindow;
18+
for (NSWindow* window in NSApp.windows) {
19+
if (window.keyWindow) {
20+
keyWindow = window;
21+
break;
22+
}
23+
}
24+
25+
// take a snapshot of the key window
26+
CGWindowID windowID = (CGWindowID)[keyWindow windowNumber];
27+
CGWindowImageOption imageOptions = kCGWindowImageDefault;
28+
CGWindowListOption listOptions = kCGWindowListOptionIncludingWindow;
29+
CGRect imageBounds = CGRectNull;
30+
CGImageRef windowImage = CGWindowListCreateImage(
31+
imageBounds,
32+
listOptions,
33+
windowID,
34+
imageOptions);
35+
NSImage* image = [[NSImage alloc] initWithCGImage:windowImage size:[keyWindow frame].size];
36+
37+
return image;
38+
}
39+
40+
static NSString* SaveScreenshotToTempFile(NSImage* image)
41+
{
42+
// save to a temp file
43+
NSError *error = nil;
44+
NSString *tempFilePath = RCTTempFilePath(@"jpeg", &error);
45+
NSData* imageData = [image TIFFRepresentation];
46+
NSBitmapImageRep* imageRep = [NSBitmapImageRep imageRepWithData:imageData];
47+
NSDictionary* imageProps =
48+
[NSDictionary
49+
dictionaryWithObject:@0.8
50+
forKey:NSImageCompressionFactor
51+
];
52+
imageData = [imageRep representationUsingType:NSBitmapImageFileTypeJPEG properties:imageProps];
53+
[imageData writeToFile:tempFilePath atomically:NO];
54+
55+
return tempFilePath;
56+
}
57+
58+
class ScreenshotManagerTurboModule : public facebook::react::TurboModule
59+
{
60+
public:
61+
ScreenshotManagerTurboModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker)
62+
:facebook::react::TurboModule("ScreenshotManager", jsInvoker)
63+
{
64+
}
65+
66+
facebook::jsi::Value get(
67+
facebook::jsi::Runtime& runtime,
68+
const facebook::jsi::PropNameID& propName
69+
) override
70+
{
71+
auto jsInvoker = jsInvoker_;
72+
auto key = propName.utf8(runtime);
73+
if (key == "takeScreenshot")
74+
{
75+
return facebook::jsi::Function::createFromHostFunction(
76+
runtime,
77+
propName,
78+
0,
79+
[jsInvoker](
80+
facebook::jsi::Runtime& runtime,
81+
const facebook::jsi::Value& thisVal,
82+
const facebook::jsi::Value *args,
83+
size_t count)
84+
{
85+
return facebook::react::createPromiseAsJSIValue(
86+
runtime,
87+
[jsInvoker](facebook::jsi::Runtime& runtime, std::shared_ptr<facebook::react::Promise> promise)
88+
{
89+
// ignore arguments, assume to be ('window', {format: 'jpeg', quality: 0.8})
90+
91+
dispatch_async(dispatch_get_main_queue(), ^{
92+
NSImage* screenshotImage = TakeScreenshot();
93+
jsInvoker->invokeAsync([screenshotImage, &runtime, promise]()
94+
{
95+
NSString* tempFilePath = SaveScreenshotToTempFile(screenshotImage);
96+
promise->resolve(facebook::jsi::Value(
97+
runtime,
98+
facebook::jsi::String::createFromUtf8(
99+
runtime,
100+
std::string([tempFilePath UTF8String])
101+
)
102+
));
103+
});
104+
});
105+
}
106+
);
107+
}
108+
);
109+
}
110+
else
111+
{
112+
return facebook::jsi::Value::undefined();
113+
}
114+
}
115+
};
116+
117+
@implementation ScreenshotManagerTurboModuleManagerDelegate
118+
119+
- (std::shared_ptr<facebook::react::TurboModule>)
120+
getTurboModule:(const std::string &)name
121+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
122+
{
123+
if (name == "ScreenshotManager")
124+
{
125+
return std::make_shared<ScreenshotManagerTurboModule>(jsInvoker);
126+
}
127+
return nullptr;
128+
}
129+
130+
131+
- (std::shared_ptr<facebook::react::TurboModule>)
132+
getTurboModule:(const std::string &)name
133+
instance:(id<RCTTurboModule>)instance
134+
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
135+
{
136+
if (name == "ScreenshotManager")
137+
{
138+
return std::make_shared<ScreenshotManagerTurboModule>(jsInvoker);
139+
}
140+
return nullptr;
141+
}
142+
143+
@end

RNTester/RNTester-macOS/AppDelegate.m renamed to RNTester/RNTester-macOS/AppDelegate.mm

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
88

99
#import "AppDelegate.h"
1010

11+
#import <React/JSCExecutorFactory.h>
1112
#import <React/RCTBridge.h>
1213
#import <React/RCTBundleURLProvider.h>
14+
#import <React/RCTCxxBridgeDelegate.h>
1315
#import <React/RCTLinkingManager.h>
1416
#import <React/RCTPushNotificationManager.h>
1517
#import <React/RCTTextAttributes.h>
18+
#import <ReactCommon/TurboModule.h>
19+
#import "../NativeModuleExample/ScreenshotMacOS.h"
1620

17-
const NSString *kBundleNameJS = @"RNTesterApp";
18-
19-
@interface AppDelegate () <RCTBridgeDelegate, NSUserNotificationCenterDelegate>
21+
NSString *kBundleNameJS = @"RNTesterApp";
2022

23+
@interface AppDelegate () <RCTCxxBridgeDelegate, NSUserNotificationCenterDelegate>
24+
{
25+
ScreenshotManagerTurboModuleManagerDelegate *_turboModuleManagerDelegate;
26+
RCTTurboModuleManager *_turboModuleManager;
27+
}
2128
@end
2229

2330
@implementation AppDelegate
@@ -71,6 +78,25 @@ - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge
7178
fallbackResource:nil];
7279
}
7380

81+
#pragma mark - RCTCxxBridgeDelegate Methods
82+
83+
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
84+
{
85+
__weak __typeof(self) weakSelf = self;
86+
return std::make_unique<facebook::react::JSCExecutorFactory>([weakSelf, bridge](facebook::jsi::Runtime &runtime) {
87+
if (!bridge) {
88+
return;
89+
}
90+
__typeof(self) strongSelf = weakSelf;
91+
if (strongSelf) {
92+
strongSelf->_turboModuleManagerDelegate = [ScreenshotManagerTurboModuleManagerDelegate new];
93+
strongSelf->_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
94+
delegate:strongSelf->_turboModuleManagerDelegate];
95+
[strongSelf->_turboModuleManager installJSBindingWithRuntime:&runtime];
96+
}
97+
});
98+
}
99+
74100
# pragma mark - Push Notifications
75101

76102
// Required for the remoteNotificationsRegistered event.

RNTester/RNTester-macOS/Base.lproj/Main.storyboard

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16097.2"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<scenes>
@@ -600,7 +600,7 @@
600600
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
601601
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
602602
<connections>
603-
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
603+
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
604604
</connections>
605605
</menuItem>
606606
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
@@ -664,7 +664,7 @@
664664
<scene sceneID="R2V-B0-nI4">
665665
<objects>
666666
<windowController storyboardIdentifier="MainWindow" id="B8D-0N-5wS" sceneMemberID="viewController">
667-
<window key="window" title="RNTester" allowsToolTipsWhenApplicationIsInactive="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
667+
<window key="window" title="RNTester" allowsToolTipsWhenApplicationIsInactive="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
668668
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
669669
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
670670
<rect key="contentRect" x="538" y="299" width="640" height="480"/>

RNTester/RNTesterPods.xcodeproj/project.pbxproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@
6767
7BD4120C2ED6C1CC8686E344 /* libPods-macOSBuild.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FB624ED465B02C53F121EBC8 /* libPods-macOSBuild.a */; };
6868
7C718C7B78F06C4CD1D1771A /* libPods-RNTester-macOSIntegrationTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B8A3294D74D7AC1BE88DC4E /* libPods-RNTester-macOSIntegrationTests.a */; };
6969
8BBFF9F061783A02D50DD2EC /* libPods-RNTesterIntegrationTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8210317F3CE28B1945488740 /* libPods-RNTesterIntegrationTests.a */; };
70-
9F15345F233AB2C4006DFE44 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F15345E233AB2C4006DFE44 /* AppDelegate.m */; };
70+
9F15345F233AB2C4006DFE44 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9F15345E233AB2C4006DFE44 /* AppDelegate.mm */; };
7171
9F153461233AB2C7006DFE44 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9F153460233AB2C7006DFE44 /* Assets.xcassets */; };
7272
9F153467233AB2C7006DFE44 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F153466233AB2C7006DFE44 /* main.m */; };
7373
A13DC98BDCE5EE508FFA7BE7 /* libPods-RNTester-macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A355204268D03CF69ABC11D /* libPods-RNTester-macOS.a */; };
74+
B2F2040A24E76D7600863BE1 /* ScreenshotMacOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2F2040924E76D7600863BE1 /* ScreenshotMacOS.mm */; };
7475
CDFF3988A89A5269C488653F /* libPods-iosDeviceBuild.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 287A4762E82517B7FACCE7D3 /* libPods-iosDeviceBuild.a */; };
7576
E59A0FBD0170A092274A6207 /* libPods-RNTesterUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 72247071A1BF06D54F0FECC7 /* libPods-RNTesterUnitTests.a */; };
7677
E7C1241A22BEC44B00DA25C0 /* RNTesterIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7C1241922BEC44B00DA25C0 /* RNTesterIntegrationTests.m */; };
@@ -218,7 +219,7 @@
218219
9EAC9B16F3BA65B8E1511E5E /* Pods-RNTester-macOSUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester-macOSUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RNTester-macOSUnitTests/Pods-RNTester-macOSUnitTests.release.xcconfig"; sourceTree = "<group>"; };
219220
9F15345B233AB2C4006DFE44 /* RNTester-macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RNTester-macOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
220221
9F15345D233AB2C4006DFE44 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
221-
9F15345E233AB2C4006DFE44 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
222+
9F15345E233AB2C4006DFE44 /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = "<group>"; };
222223
9F153460233AB2C7006DFE44 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
223224
9F153465233AB2C7006DFE44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
224225
9F153466233AB2C7006DFE44 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -230,6 +231,8 @@
230231
9F15347C233AB2C7006DFE44 /* RNTesterIntegrationTests_macOS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNTesterIntegrationTests_macOS.m; sourceTree = "<group>"; };
231232
9F15347E233AB2C7006DFE44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
232233
A112BDF7485AEF790F6D3E26 /* Pods-iosDeviceBuild.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosDeviceBuild.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iosDeviceBuild/Pods-iosDeviceBuild.debug.xcconfig"; sourceTree = "<group>"; };
234+
B2F2040824E76D7600863BE1 /* ScreenshotMacOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScreenshotMacOS.h; path = NativeModuleExample/ScreenshotMacOS.h; sourceTree = SOURCE_ROOT; };
235+
B2F2040924E76D7600863BE1 /* ScreenshotMacOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ScreenshotMacOS.mm; path = NativeModuleExample/ScreenshotMacOS.mm; sourceTree = SOURCE_ROOT; };
233236
C81D39A606858D29861E5930 /* Pods-iosSimulatorBuild.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosSimulatorBuild.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iosSimulatorBuild/Pods-iosSimulatorBuild.debug.xcconfig"; sourceTree = "<group>"; };
234237
E65D2B0329006BC5338BB7D5 /* libPods-iosSimulatorBuild.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iosSimulatorBuild.a"; sourceTree = BUILT_PRODUCTS_DIR; };
235238
E68A0B7D2448B4F300228B0B /* RNTesterUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNTesterUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -532,9 +535,11 @@
532535
9F15345C233AB2C4006DFE44 /* RNTester-macOS */ = {
533536
isa = PBXGroup;
534537
children = (
538+
B2F2040824E76D7600863BE1 /* ScreenshotMacOS.h */,
539+
B2F2040924E76D7600863BE1 /* ScreenshotMacOS.mm */,
535540
5101985523AD9EE600118BF1 /* Main.storyboard */,
536541
9F15345D233AB2C4006DFE44 /* AppDelegate.h */,
537-
9F15345E233AB2C4006DFE44 /* AppDelegate.m */,
542+
9F15345E233AB2C4006DFE44 /* AppDelegate.mm */,
538543
5101985823AD9F5B00118BF1 /* ViewController.h */,
539544
5101985923AD9F5B00118BF1 /* ViewController.m */,
540545
9F153460233AB2C7006DFE44 /* Assets.xcassets */,
@@ -1257,10 +1262,11 @@
12571262
isa = PBXSourcesBuildPhase;
12581263
buildActionMask = 2147483647;
12591264
files = (
1265+
B2F2040A24E76D7600863BE1 /* ScreenshotMacOS.mm in Sources */,
12601266
5101985A23AD9F5B00118BF1 /* ViewController.m in Sources */,
12611267
9F153467233AB2C7006DFE44 /* main.m in Sources */,
12621268
38CB64352445042D009035CC /* RNTesterTurboModuleProvider.mm in Sources */,
1263-
9F15345F233AB2C4006DFE44 /* AppDelegate.m in Sources */,
1269+
9F15345F233AB2C4006DFE44 /* AppDelegate.mm in Sources */,
12641270
38B2630C2444F628006AB4D5 /* FlexibleSizeExampleView.m in Sources */,
12651271
38B2630B2444F5EB006AB4D5 /* UpdatePropertiesExampleView.m in Sources */,
12661272
);

RNTester/js/examples/Snapshot/SnapshotExample.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
1111
'use strict';
1212

1313
const React = require('react');
14-
const {
15-
Alert,
16-
Image,
17-
NativeModules,
18-
StyleSheet,
19-
Text,
20-
View,
21-
} = require('react-native');
22-
const ScreenshotManager = NativeModules.ScreenshotManager;
14+
const {Alert, Image, StyleSheet, Text, View} = require('react-native');
15+
16+
import {NativeModule as ScreenshotManager} from '../../../NativeModuleExample/NativeScreenshotManager';
2317

2418
class ScreenshotExample extends React.Component<{...}, $FlowFixMeState> {
2519
state = {
@@ -37,10 +31,20 @@ class ScreenshotExample extends React.Component<{...}, $FlowFixMeState> {
3731
);
3832
}
3933

34+
// TODO(macOS ISS#2323203): alert needs two string arguments, passing an error results in crashing
4035
takeScreenshot = () => {
41-
ScreenshotManager.takeScreenshot('window', {format: 'jpeg', quality: 0.8}) // See UIManager.js for options
42-
.then(uri => this.setState({uri}))
43-
.catch(error => Alert.alert(error));
36+
if (ScreenshotManager !== undefined && ScreenshotManager !== null) {
37+
ScreenshotManager.takeScreenshot('window', {format: 'jpeg', quality: 0.8}) // See UIManager.js for options
38+
.then(uri => this.setState({uri}))
39+
.catch(error =>
40+
Alert.alert('ScreenshotManager.takeScreenshot', error.message),
41+
);
42+
} else {
43+
Alert.alert(
44+
'ScreenshotManager.takeScreenshot',
45+
'The turbo module is not installed.',
46+
);
47+
}
4448
};
4549
}
4650

third-party-podspecs/RCT-Folly.podspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Pod::Spec.new do |spec|
6060
"CLANG_CXX_LANGUAGE_STANDARD" => "c++14",
6161
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" }
6262

63+
# TODO: The boost spec should really be selecting these files so that dependents of Folly can also access the required headers.
64+
spec.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\"" }
65+
6366
spec.default_subspec = 'Default'
6467

6568
spec.subspec 'Default' do

0 commit comments

Comments
 (0)