Update to react-native@0.10, add APIs to Readme
This commit is contained in:
parent
4456ce4a80
commit
4d5a8ba16b
|
@ -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',
|
||||
});
|
||||
|
|
12
RCTCamera.m
12
RCTCamera.m
|
@ -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];
|
||||
|
|
|
@ -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 {
|
||||
|
|
30
README.md
30
README.md
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue