Skip to content

Commit

Permalink
Update for Torch Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraskelton committed Apr 8, 2015
1 parent b415567 commit 4485746
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 16 deletions.
48 changes: 48 additions & 0 deletions Example/Example/ExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ @interface ExampleViewController () <FastttCameraDelegate, ConfirmControllerDele
@property (nonatomic, strong) FastttCamera *fastCamera;
@property (nonatomic, strong) UIButton *takePhotoButton;
@property (nonatomic, strong) UIButton *flashButton;
@property (nonatomic, strong) UIButton *torchButton;
@property (nonatomic, strong) UIButton *switchCameraButton;
@property (nonatomic, strong) ConfirmViewController *confirmController;

Expand Down Expand Up @@ -67,6 +68,8 @@ - (void)viewDidLoad
}];

_flashButton = [UIButton new];
self.flashButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.flashButton.titleLabel.numberOfLines = 0;
[self.flashButton addTarget:self
action:@selector(flashButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
Expand All @@ -83,6 +86,8 @@ - (void)viewDidLoad
}];

_switchCameraButton = [UIButton new];
self.switchCameraButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.switchCameraButton.titleLabel.numberOfLines = 0;
[self.switchCameraButton addTarget:self
action:@selector(switchCameraButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
Expand All @@ -96,6 +101,26 @@ - (void)viewDidLoad
[self.switchCameraButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view).offset(20.f);
make.right.equalTo(self.view).offset(-20.f);
make.size.equalTo(self.flashButton);
}];

_torchButton = [UIButton new];
self.torchButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.torchButton.titleLabel.numberOfLines = 0;
[self.torchButton addTarget:self
action:@selector(torchButtonPressed)
forControlEvents:UIControlEventTouchUpInside];

[self.torchButton setTitle:@"Torch Off"
forState:UIControlStateNormal];

[self.fastCamera setCameraTorchMode:FastttCameraTorchModeOff];
[self.view addSubview:self.torchButton];
[self.torchButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view).offset(20.f);
make.left.equalTo(self.flashButton.mas_right).offset(20.f);
make.right.equalTo(self.switchCameraButton.mas_left).offset(-20.f);
make.size.equalTo(self.flashButton);
}];
}

Expand Down Expand Up @@ -135,6 +160,29 @@ - (void)flashButtonPressed
}
}

- (void)torchButtonPressed
{
NSLog(@"torch button pressed");

FastttCameraTorchMode torchMode;
NSString *torchTitle;
switch (self.fastCamera.cameraTorchMode) {
case FastttCameraTorchModeOn:
torchMode = FastttCameraTorchModeOff;
torchTitle = @"Torch Off";
break;
case FastttCameraTorchModeOff:
default:
torchMode = FastttCameraTorchModeOn;
torchTitle = @"Torch On";
break;
}
if ([self.fastCamera isTorchAvailableForCurrentDevice]) {
[self.fastCamera setCameraTorchMode:torchMode];
[self.torchButton setTitle:torchTitle forState:UIControlStateNormal];
}
}

- (void)switchCameraButtonPressed
{
NSLog(@"switch camera button pressed");
Expand Down
10 changes: 5 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ PODS:
- Expecta+Snapshots (1.3.1):
- Expecta
- FBSnapshotTestCase
- FastttCamera (0.2.8):
- FastttCamera/Default (= 0.2.8)
- FastttCamera/Default (0.2.8)
- FastttCamera (0.2.9):
- FastttCamera/Default (= 0.2.9)
- FastttCamera/Default (0.2.9)
- FBSnapshotTestCase (1.5)
- Masonry (0.6.1)
- OCMock (3.1.2)
Expand All @@ -26,10 +26,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Expecta: 8c507baf13211207b1e9d0a741480600e6b4ed15
Expecta+Snapshots: 4a0b46d3ba755bd43dffa7d53e4585fc6cbfe8cd
FastttCamera: e935b9085f58989286deb3ba06c4f9eed62913bc
FastttCamera: bd173337377bcf4f1fb698bab3362fcf2914039c
FBSnapshotTestCase: 26f32d8fa9eb30e9f09712ecfb097808bc79b898
Masonry: 4972309f2f134de9dd312f4dc4a21359b50e6caa
OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92
Specta: a353759f073ffcc0a365b782fe4aaeac064c03c6

COCOAPODS: 0.36.0
COCOAPODS: 0.36.3
2 changes: 1 addition & 1 deletion FastttCamera.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "FastttCamera"
s.version = "0.2.8"
s.version = "0.2.9"
s.summary = "A fast, straightforward implementation of AVFoundation camera with customizable real-time photo filters."
s.homepage = "https://github.com/IFTTT/FastttCamera"
s.license = 'MIT'
Expand Down
1 change: 0 additions & 1 deletion FastttCamera/AVCaptureDevice+FastttCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*/
+ (BOOL)isFlashAvailableForCameraDevice:(FastttCameraDevice)cameraDevice;


/**
* Checks whether torch is available for the given FastttCameraDevice.
*
Expand Down
2 changes: 1 addition & 1 deletion FastttCamera/FastttCameraTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ typedef NS_ENUM(NSInteger, FastttCameraTorchMode) {
FastttCameraTorchModeOff,
FastttCameraTorchModeOn,
FastttCameraTorchModeAuto
};
};
9 changes: 6 additions & 3 deletions FiltersExample/Example/ExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ - (void)viewDidLoad
}];

_flashButton = [UIButton new];
self.flashButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.flashButton.titleLabel.numberOfLines = 0;
[self.flashButton addTarget:self
action:@selector(flashButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
Expand All @@ -87,9 +89,9 @@ - (void)viewDidLoad
make.left.equalTo(self.view).offset(20.f);
}];



_switchCameraButton = [UIButton new];
self.switchCameraButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.switchCameraButton.titleLabel.numberOfLines = 0;
[self.switchCameraButton addTarget:self
action:@selector(switchCameraButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
Expand All @@ -107,6 +109,8 @@ - (void)viewDidLoad
}];

_torchButton = [UIButton new];
self.torchButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.torchButton.titleLabel.numberOfLines = 0;
[self.torchButton addTarget:self
action:@selector(torchButtonPressed)
forControlEvents:UIControlEventTouchUpInside];
Expand All @@ -123,7 +127,6 @@ - (void)viewDidLoad
make.size.equalTo(self.flashButton);
}];


_changeFilterButton = [UIButton new];
[self.changeFilterButton addTarget:self
action:@selector(switchFilterButtonPressed)
Expand Down
8 changes: 4 additions & 4 deletions FiltersExample/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ PODS:
- Expecta+Snapshots (1.3.1):
- Expecta
- FBSnapshotTestCase
- FastttCamera/Default (0.2.8)
- FastttCamera/Filters (0.2.8):
- FastttCamera/Default (0.2.9)
- FastttCamera/Filters (0.2.9):
- FastttCamera/Default
- GPUImage (~> 0.1.0)
- FBSnapshotTestCase (1.5)
Expand All @@ -28,11 +28,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Expecta: 8c507baf13211207b1e9d0a741480600e6b4ed15
Expecta+Snapshots: 4a0b46d3ba755bd43dffa7d53e4585fc6cbfe8cd
FastttCamera: e935b9085f58989286deb3ba06c4f9eed62913bc
FastttCamera: bd173337377bcf4f1fb698bab3362fcf2914039c
FBSnapshotTestCase: 26f32d8fa9eb30e9f09712ecfb097808bc79b898
GPUImage: 4675ce4a5370ca92fcea8623b2a08b8f0c51b940
Masonry: 4972309f2f134de9dd312f4dc4a21359b50e6caa
OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92
Specta: a353759f073ffcc0a365b782fe4aaeac064c03c6

COCOAPODS: 0.36.0
COCOAPODS: 0.36.3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Set the camera's torch mode.
```objc
if ([FastttCamera isTorchAvailableForCameraDevice:self.fastCamera.cameraDevice]) {
[self.fastCamera setCameraTorchMode:torchMode];
[self.fastCamera setCameraTorchMode:torchMode];
}
```
Tell `FastttCamera` to take a photo.
Expand Down

0 comments on commit 4485746

Please sign in to comment.