Skip to content

Commit

Permalink
Minor stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Jun 28, 2024
1 parent 3bf94d2 commit d42aad2
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions iOS/GBViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

// Use a discovery session to gather the capture devices (all back cameras as well as the front camera)
AVCaptureDeviceDiscoverySession *cameraDiscoverySession = [AVCaptureDeviceDiscoverySession
discoverySessionWithDeviceTypes:deviceTypes
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
AVCaptureDeviceDiscoverySession *cameraDiscoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:deviceTypes
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
_allCaptureDevices = cameraDiscoverySession.devices;

// Filter only the back cameras into a list used for switching between them
Expand Down Expand Up @@ -306,8 +305,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
else {
UIImage *rotateImage = [[UIImage imageNamed:@"CameraRotateTemplate"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[_cameraPositionButton setImage:rotateImage
forState:UIControlStateNormal];
[_cameraPositionButton setImage:rotateImage
forState:UIControlStateNormal];
_cameraPositionButton.backgroundColor = [UIColor whiteColor];
}

Expand Down Expand Up @@ -743,7 +742,7 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO
_backgroundView.bounds.size.height - 8 - insets.bottom - 32,
32,
32);
if (_changeCameraButton != nil) {
if (_changeCameraButton) {
_changeCameraButton.frame = CGRectMake(insets.left + 8,
_backgroundView.bounds.size.height - 8 - insets.bottom - 32 - 32 - 8,
32,
Expand Down Expand Up @@ -1250,12 +1249,14 @@ - (void)cameraRequestUpdate
_cameraPositionButton.alpha = 1;
}];
}
if (_changeCameraButton != nil) {
if (_changeCameraButton) {
// The change camera button is only available when we are using a capture device on the back of the device
int changeCameraButtonAlpha = (_cameraPosition == AVCaptureDevicePositionFront) ? 0 : 1;
[UIView animateWithDuration:0.25 animations:^{
_changeCameraButton.alpha = changeCameraButtonAlpha;
}];
double changeCameraButtonAlpha = (_cameraPosition == AVCaptureDevicePositionFront) ? 0 : 1;
if (changeCameraButtonAlpha != _changeCameraButton.alpha) {
[UIView animateWithDuration:0.25 animations:^{
_changeCameraButton.alpha = changeCameraButtonAlpha;
}];
}
}

_disableCameraTimer = [NSTimer scheduledTimerWithTimeInterval:1
Expand All @@ -1266,12 +1267,10 @@ - (void)cameraRequestUpdate
_cameraPositionButton.alpha = 0;
}];
}
if (_changeCameraButton != nil) {
if (_changeCameraButton.alpha) {
[UIView animateWithDuration:0.25 animations:^{
_changeCameraButton.alpha = 0;
}];
}
if (_changeCameraButton.alpha) {
[UIView animateWithDuration:0.25 animations:^{
_changeCameraButton.alpha = 0;
}];
}
dispatch_async(_cameraQueue, ^{
[_cameraSession stopRunning];
Expand Down

0 comments on commit d42aad2

Please sign in to comment.