react-native-view-shot icon indicating copy to clipboard operation
react-native-view-shot copied to clipboard

captureScreen did not take modal opened

Open MrHazimAli opened this issue 6 years ago • 8 comments

Im open a modal on my app, and when user click on button inside that modal, i trigger capturescreen function but it seems only capture my screen without the modal. is this a bug or anything I did wrong ?

captureScreen({ format: "jpg", quality: 0.8 }) .then( (uri) => { console.log("Image saved to", uri) }, error => console.error("Oops, snapshot failed", error) );

MrHazimAli avatar Apr 13 '18 03:04 MrHazimAli

Can you give us an example?

Taym95 avatar May 02 '18 15:05 Taym95

This is the sample code @Taym95 Thanks!

https://es6console.com/jgpxn4cx/

sorry, could not paste the code directly here.. have trouble of highlighting it.

MrHazimAli avatar May 03 '18 02:05 MrHazimAli

Same problem.

My project run with two jsbundle file, the first was in base controller, which would present a new view controller hold on the second.

In second jsbundle file, calling captureScreen was just captured the first controller's view.

    UIViewController *current = [self getCurrentViewController];
    UIViewController *secondController = [[UIViewController alloc] init];
    NSURL *mainLocation = [[NSBundle mainBundle] URLForResource:@"Demo" withExtension:@"jsbundle"];
    RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:mainLocation
                                              moduleProvider:nil
                                               launchOptions: nil];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge: bridge
                                                     moduleName:@"Demo"
                                              initialProperties:properties];
    secondController.view = rootView;
    [current presentViewController:secondController animated:YES completion:nil];

FaiChou avatar Aug 20 '18 06:08 FaiChou

same problem,this module capture my screen without the modal

nguyenvanphuc2203 avatar Mar 05 '19 04:03 nguyenvanphuc2203

Any update on this issue?

puneet24 avatar Jun 05 '20 06:06 puneet24

Any solution for this?

Crhaj avatar Nov 11 '20 12:11 Crhaj

To capture your modal alone, use CaptureRef instead of CaptureScreen. Then in your code, create a ViewShot element that wraps round your modal. This tells the library where to capture. If anyone is still interested in this, I could modify @MrHazimAli 's snippet to reflect the changes

Ernoff avatar Nov 15 '20 10:11 Ernoff

To capture your modal alone, use CaptureRef instead of CaptureScreen. Then in your code, create a ViewShot element that wraps round your modal. This tells the library where to capture. If anyone is still interested in this, I could modify @MrHazimAli 's snippet to reflect the changes

I am interested, Can you modify the snippet with a functional component? I did what you said and I get the error Argument appears to not be a ReactComponent. Keys: current

Maybe, the functionality I'm looking for is to capture the View of a modal that is hidden.

leojim06 avatar Jan 20 '21 21:01 leojim06