Created
January 19, 2016 16:07
-
-
Save jondot/11a84238701fea25990d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// MapView.js | |
var React = require('react-native'); | |
var { View, Text, TouchableOpacity, requireNativeComponent } = React; | |
var RCTMapperManager = require('NativeModules').MapperManager; | |
class MapView extends React.Component { | |
foobar(){ | |
RCTMapperManager.logstuff( | |
React.findNodeHandle(this), | |
"hello" | |
); | |
} | |
render() { | |
return ( | |
<View> | |
<TouchableOpacity onPress={this.foobar.bind(this)} > | |
<Text> Foobarmap </Text> | |
</TouchableOpacity> | |
<RCTMap ref="map" {...this.props} /> | |
</View> | |
) | |
} | |
} | |
MapView.propTypes = { | |
/** | |
* When this property is set to `true` and a valid camera is associated | |
* with the map, the camera’s pitch angle is used to tilt the plane | |
* of the map. When this property is set to `false`, the camera’s pitch | |
* angle is ignored and the map is always displayed as if the user | |
* is looking straight down onto it. | |
*/ | |
pitchEnabled: React.PropTypes.bool, | |
}; | |
var RCTMap = requireNativeComponent('RCTMapper', MapView); | |
module.exports = MapView; |
This file contains hidden or 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
// | |
// RCTMapManager.m | |
// keyboardanim | |
// | |
// Created by Dotan Nahum on 1/19/16. | |
// Copyright © 2016 Facebook. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
// RCTMapManager.m | |
#import <MapKit/MapKit.h> | |
#import "RCTViewManager.h" | |
#import "RCTUIManager.h" | |
@interface RCTMapperManager : RCTViewManager | |
@end | |
@implementation RCTMapperManager | |
RCT_EXPORT_MODULE() | |
- (UIView *)view | |
{ | |
return [[MKMapView alloc] init]; | |
} | |
RCT_EXPORT_VIEW_PROPERTY(pitchEnabled, BOOL) | |
RCT_EXPORT_METHOD(logstuff:(nonnull NSNumber *)reactTag | |
str:(NSString *)str) | |
{ | |
NSLog(@" with tag #%@", reactTag); | |
[self.bridge.uiManager addUIBlock: | |
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){ | |
UIView *view = viewRegistry[reactTag]; | |
NSLog(@" with view #%@", view); | |
}]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment