2015-04-02 09:40:03 +00:00
|
|
|
#import "RCTBridge.h"
|
2015-04-01 01:02:57 +00:00
|
|
|
#import "RCTCamera.h"
|
2015-04-02 09:40:03 +00:00
|
|
|
#import "RCTCameraManager.h"
|
2015-04-01 01:02:57 +00:00
|
|
|
#import "RCTLog.h"
|
2015-04-08 20:51:31 +00:00
|
|
|
#import "RCTUtils.h"
|
2015-04-01 01:02:57 +00:00
|
|
|
#import "ViewfinderView.h"
|
2015-04-11 02:56:30 +00:00
|
|
|
|
2015-04-01 01:02:57 +00:00
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
|
|
|
|
@implementation RCTCamera
|
|
|
|
|
2015-04-01 17:32:53 +00:00
|
|
|
- (void)setAspect:(NSString *)aspect
|
2015-04-01 01:02:57 +00:00
|
|
|
{
|
2015-04-11 02:56:30 +00:00
|
|
|
[(AVCaptureVideoPreviewLayer *)[_viewfinder layer] setVideoGravity:aspect];
|
2015-04-01 02:27:18 +00:00
|
|
|
}
|
|
|
|
|
2015-04-08 20:51:31 +00:00
|
|
|
- (void)setType:(NSInteger)camera
|
2015-04-01 02:27:18 +00:00
|
|
|
{
|
2015-04-11 02:56:30 +00:00
|
|
|
if (self.manager.session.isRunning) {
|
|
|
|
[self.manager changeCamera:camera];
|
2015-04-08 20:51:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-04-11 02:56:30 +00:00
|
|
|
self.manager.presetCamera = camera;
|
2015-04-08 20:51:31 +00:00
|
|
|
}
|
2015-04-01 17:32:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setOrientation:(NSInteger)orientation
|
|
|
|
{
|
2015-04-11 02:56:30 +00:00
|
|
|
[self.manager changeOrientation:orientation];
|
2015-04-01 01:02:57 +00:00
|
|
|
}
|
|
|
|
|
2015-04-11 02:56:30 +00:00
|
|
|
- (id)initWithManager:(RCTCameraManager*)manager
|
2015-04-01 01:02:57 +00:00
|
|
|
{
|
|
|
|
if ((self = [super init])) {
|
2015-04-11 02:56:30 +00:00
|
|
|
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
|
|
|
|
{
|
2015-04-11 02:56:30 +00:00
|
|
|
NSArray *subviews = @[self.viewfinder];
|
2015-04-01 01:02:57 +00:00
|
|
|
return subviews;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)layoutSubviews
|
|
|
|
{
|
|
|
|
[super layoutSubviews];
|
2015-04-11 02:56:30 +00:00
|
|
|
[self.viewfinder setFrame:self.bounds];
|
2015-04-01 01:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
|
|
|
|
{
|
2015-04-08 20:51:31 +00:00
|
|
|
[self insertSubview:view atIndex:atIndex + 1];
|
2015-04-01 01:02:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeReactSubview:(UIView *)subview
|
|
|
|
{
|
2015-04-03 01:07:22 +00:00
|
|
|
[subview removeFromSuperview];
|
2015-04-01 01:02:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|