Authored by 张丽霞

RNCamera添加rectOfInterest属性,review by redding

... ... @@ -109,7 +109,13 @@ export default class Camera extends Component {
type: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
])
]),
rectOfCameraInterest: PropTypes.shape({
x: React.PropTypes.number,
y: React.PropTypes.number,
width: React.PropTypes.number,
height: React.PropTypes.number
}),
};
static defaultProps = {
... ...
... ... @@ -72,6 +72,7 @@ typedef NS_ENUM(NSInteger, RCTCameraTorchMode) {
@property (nonatomic, strong) RCTPromiseResolveBlock videoResolve;
@property (nonatomic, strong) RCTPromiseRejectBlock videoReject;
@property (nonatomic, strong) RCTCamera *camera;
@property (nonatomic, assign) CGRect rectOfCameraInterest;
- (void)changeOrientation:(NSInteger)orientation;
... ...
... ... @@ -271,6 +271,10 @@ RCT_CUSTOM_VIEW_PROPERTY(captureAudio, BOOL, RCTCamera) {
}
}
RCT_CUSTOM_VIEW_PROPERTY(rectOfCameraInterest, CGRect, RCTCamera) {
self.rectOfCameraInterest = [RCTConvert CGRect:json];
}
- (NSArray *)customDirectEventTypes
{
return @[
... ... @@ -416,6 +420,7 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej
[metadataOutput setMetadataObjectsDelegate:self queue:self.sessionQueue];
[self.session addOutput:metadataOutput];
[metadataOutput setMetadataObjectTypes:self.barCodeTypes];
metadataOutput.rectOfInterest = self.rectOfCameraInterest;
self.metadataOutput = metadataOutput;
}
... ...