mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 09:48:17 +00:00
51 lines
1.3 KiB
Objective-C
51 lines
1.3 KiB
Objective-C
#import "RCTCameraManager.h"
|
|
#import "RCTCamera.h"
|
|
#import "RCTBridge.h"
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
@implementation RCTCameraManager
|
|
|
|
@synthesize bridge = _bridge;
|
|
|
|
- (UIView *)view
|
|
{
|
|
return [[RCTCamera alloc] init];
|
|
}
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(aspect, NSString);
|
|
RCT_EXPORT_VIEW_PROPERTY(camera, NSInteger);
|
|
RCT_EXPORT_VIEW_PROPERTY(orientation, NSInteger);
|
|
|
|
- (NSDictionary *)constantsToExport
|
|
{
|
|
return @{
|
|
@"aspects": @{
|
|
@"Stretch": AVLayerVideoGravityResize,
|
|
@"Fit": AVLayerVideoGravityResizeAspect,
|
|
@"Fill": AVLayerVideoGravityResizeAspectFill
|
|
},
|
|
@"cameras": @{
|
|
@"Front": @(AVCaptureDevicePositionFront),
|
|
@"Back": @(AVCaptureDevicePositionBack)
|
|
},
|
|
@"orientations": @{
|
|
@"LandscapeLeft": @(AVCaptureVideoOrientationLandscapeLeft),
|
|
@"LandscapeRight": @(AVCaptureVideoOrientationLandscapeRight),
|
|
@"Portrait": @(AVCaptureVideoOrientationPortrait),
|
|
@"PortraitUpsideDown": @(AVCaptureVideoOrientationPortraitUpsideDown)
|
|
}
|
|
};
|
|
}
|
|
|
|
- (void)checkDeviceAuthorizationStatus:(RCTResponseSenderBlock) callback
|
|
{
|
|
RCT_EXPORT();
|
|
NSString *mediaType = AVMediaTypeVideo;
|
|
|
|
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
|
callback(@[[NSNull null], @(granted)]);
|
|
}];
|
|
}
|
|
|
|
@end
|