Update to react-native@0.10, add APIs to Readme

This commit is contained in:
Dmitriy Loktev 2015-08-29 14:24:05 +06:00
parent 4456ce4a80
commit 4d5a8ba16b
4 changed files with 48 additions and 18 deletions

View File

@ -52,7 +52,7 @@ var Camera = React.createClass({
PropTypes.string,
PropTypes.number
]),
defaultTouchToFocus: PropTypes.bool,
defaultOnFocusComponent: PropTypes.bool,
onFocusChanged: PropTypes.func,
onZoomChanged: PropTypes.func
},
@ -211,7 +211,7 @@ var RCTCamera = createReactNativeComponentClass({
torchMode: true,
onFocusChanged: true,
onZoomChanged: true,
defaultTouchToFocus: true
defaultOnFocusComponent: true
}),
uiViewClassName: 'RCTCamera',
});

View File

@ -14,7 +14,7 @@
{
BOOL _multipleTouches;
BOOL _onFocusChanged;
BOOL _defaultTouchToFocus;
BOOL _defaultOnFocusComponent;
BOOL _onZoomChanged;
}
@ -76,10 +76,10 @@
}
}
- (void)setDefaultTouchToFocus:(BOOL)enabled
- (void)setDefaultOnFocusComponent:(BOOL)enabled
{
if (_defaultTouchToFocus != enabled) {
_defaultTouchToFocus = enabled;
if (_defaultOnFocusComponent != enabled) {
_defaultOnFocusComponent = enabled;
}
}
@ -102,7 +102,7 @@
[self.manager startSession];
_multipleTouches = NO;
_onFocusChanged = NO;
_defaultTouchToFocus = YES;
_defaultOnFocusComponent = YES;
_onZoomChanged = NO;
}
return self;
@ -177,7 +177,7 @@
[self.bridge.eventDispatcher sendInputEventWithName:@"focusChanged" body:event];
// Show animated rectangle on the touched area
if (_defaultTouchToFocus) {
if (_defaultOnFocusComponent) {
self.camFocus = [[RCTCameraFocusSquare alloc]initWithFrame:CGRectMake(touchPoint.x-40, touchPoint.y-40, 80, 80)];
[self.camFocus setBackgroundColor:[UIColor clearColor]];
[self addSubview:self.camFocus];

View File

@ -93,16 +93,16 @@ RCT_EXPORT_VIEW_PROPERTY(torchMode, NSInteger);
];
}
RCT_EXPORT_VIEW_PROPERTY(defaultTouchToFocus, BOOL);
RCT_EXPORT_VIEW_PROPERTY(defaultOnFocusComponent, BOOL);
RCT_EXPORT_VIEW_PROPERTY(onFocusChanged, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onZoomChanged, BOOL)
- (NSDictionary *)customDirectEventTypes
- (NSArray *)customDirectEventTypes
{
return @{
@"focusChanged": @{ @"registrationName": @"onFocusChanged" },
@"zoomChanged": @{ @"registrationName": @"onZoomChanged" },
};
return @[
@"focusChanged",
@"zoomChanged",
];
}
- (id)init {

View File

@ -186,6 +186,36 @@ Values:
Use the `torchMode` property to specify the camera torch mode.
#### `onFocusChanged`
Args:
```
e: {
nativeEvent: {
touchPoint: { x, y }
}
}
```
Will call when touch to focus has been made.
#### `defaultOnFocusComponent`
Values:
`true` (default)
`false`
#### `onFocusChanged`
Args:
```
e: {
nativeEvent: {
velocity, zoomFactor
}
}
```
Will call when focus has changed.
## Component methods
You can access component methods by adding a `ref` (ie. `ref="camera"`) prop to your `<Camera>` element, then you can use `this.refs.camera.capture(cb)`, etc. inside your component.