react-native-camera/RCTCamera.m

67 lines
1.3 KiB
Mathematica
Raw Normal View History

#import "RCTBridge.h"
2015-04-01 01:02:57 +00:00
#import "RCTCamera.h"
#import "RCTCameraManager.h"
2015-04-01 01:02:57 +00:00
#import "RCTLog.h"
#import "RCTUtils.h"
2015-04-01 01:02:57 +00:00
#import "ViewfinderView.h"
2015-04-01 01:02:57 +00:00
#import <AVFoundation/AVFoundation.h>
@implementation RCTCamera
- (void)setAspect:(NSString *)aspect
2015-04-01 01:02:57 +00:00
{
[(AVCaptureVideoPreviewLayer *)[_viewfinder layer] setVideoGravity:aspect];
}
- (void)setType:(NSInteger)camera
{
if (self.manager.session.isRunning) {
[self.manager changeCamera:camera];
}
else {
self.manager.presetCamera = camera;
}
}
- (void)setOrientation:(NSInteger)orientation
{
[self.manager changeOrientation:orientation];
2015-04-01 01:02:57 +00:00
}
- (id)initWithManager:(RCTCameraManager*)manager
2015-04-01 01:02:57 +00:00
{
if ((self = [super init])) {
self.manager = manager;
self.viewfinder = [[ViewfinderView alloc] init];
self.viewfinder.session = self.manager.session;
2015-04-01 01:02:57 +00:00
}
return self;
}
- (NSArray *)reactSubviews
{
NSArray *subviews = @[self.viewfinder];
2015-04-01 01:02:57 +00:00
return subviews;
}
- (void)layoutSubviews
{
[super layoutSubviews];
[self.viewfinder setFrame:self.bounds];
2015-04-01 01:02:57 +00:00
}
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
{
[self insertSubview:view atIndex:atIndex + 1];
2015-04-01 01:02:57 +00:00
return;
}
- (void)removeReactSubview:(UIView *)subview
{
[subview removeFromSuperview];
2015-04-01 01:02:57 +00:00
return;
}
@end