Created
July 31, 2015 20:36
-
-
Save akaila/e11131eb744a0c8f80f0 to your computer and use it in GitHub Desktop.
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
//React/Views/RCTViewSnapshotManager.h | |
// | |
// RCTViewSnapshot.h | |
// React | |
// | |
// Created by Kaila, Ashish on 7/30/15. | |
// Copyright (c) 2015 Facebook. All rights reserved. | |
// | |
#import "RCTViewManager.h" | |
@interface RCTViewSnapshotManager : RCTViewManager | |
@property (nonatomic, strong) NSNumber* sourceViewRef; | |
@end |
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
React/Views/RCTViewSnapshotManager.m | |
// | |
// RCTViewSnapshot.m | |
// React | |
// | |
// Created by Kaila, Ashish on 7/30/15. | |
// Copyright (c) 2015 Facebook. All rights reserved. | |
// | |
#import "RCTViewSnapshotManager.h" | |
#import "RCTUIManager.h" | |
@implementation RCTViewSnapshotManager | |
RCT_EXPORT_MODULE() | |
@synthesize bridge = _bridge; | |
@synthesize methodQueue = _methodQueue; | |
- (UIView *)view | |
{ | |
UIView* sourceView; | |
if ((!self.bridge) || (!(sourceView = [self.bridge.uiManager viewForReactTag:self.sourceViewRef]))) { | |
return [super view]; | |
} | |
UIView* snapshot = [sourceView snapshotViewAfterScreenUpdates:NO]; | |
snapshot.frame = sourceView.bounds; | |
return snapshot; | |
} | |
RCT_EXPORT_VIEW_PROPERTY(sourceViewRef, NSNumber) | |
@end |
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
//Lbraries/react-native/react-native.js | |
SegmentedControlIOS: require('SegmentedControlIOS'), | |
SliderIOS: require('SliderIOS'), | |
SwitchIOS: require('SwitchIOS'), | |
+ SnapshotView: require('SnapshotView'), | |
TabBarIOS: require('TabBarIOS'), | |
Text: require('Text'), | |
TextInput: require('TextInput'), |
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
//Libraries/Components/SnapshotView/SnapshotView.js | |
"use strict"; | |
var React = require("React"); | |
var requireNativeComponent = require("requireNativeComponent"); | |
class SnapshotView extends React.Component { | |
render() { | |
return <RCTViewSnapshot {...this.props} />; | |
} | |
} | |
SnapshotView.propTypes = { | |
/** | |
* Reference tag of the source view that is to be snapshot | |
*/ | |
sourceViewRef: React.PropTypes.number, | |
}; | |
var RCTViewSnapshot = requireNativeComponent("RCTViewSnapshot", SnapshotView); | |
module.exports = SnapshotView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment