mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +00:00
Merge commit 'f0f340fdc578ee3492a6f998a30bc6d2a58859b8' into experiments/channel-swipe-navigation
This commit is contained in:
commit
80679a38a4
@ -1,12 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_cam_flashoff (1).pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -1,12 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_cam_flashon.pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -6,6 +6,12 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface TGCameraSmallFlipButton : TGModernButton
|
||||
|
||||
- (void)setHidden:(bool)hidden animated:(bool)animated;
|
||||
|
||||
@end
|
||||
|
||||
@interface TGCameraCancelButton : TGModernButton
|
||||
|
||||
- (void)setHidden:(bool)hidden animated:(bool)animated;
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
@interface TGCameraTimeCodeView : UIView
|
||||
|
||||
@property (nonatomic, assign) UIInterfaceOrientation interfaceOrientation;
|
||||
|
||||
@property (nonatomic, copy) NSTimeInterval(^requestedRecordingDuration)(void);
|
||||
|
||||
- (void)startRecording;
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
|
||||
- (void)setHidden:(bool)hidden animated:(bool)animated;
|
||||
|
||||
- (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame hasUltrawideCamera:(bool)hasUltrawideCamera hasTelephotoCamera:(bool)hasTelephotoCamera minZoomLevel:(CGFloat)minZoomLevel maxZoomLevel:(CGFloat)maxZoomLevel;
|
||||
|
||||
@end
|
||||
@ -34,7 +36,12 @@
|
||||
|
||||
@interface TGCameraZoomWheelView : UIView
|
||||
|
||||
@property (nonatomic, assign) UIInterfaceOrientation interfaceOrientation;
|
||||
|
||||
@property (copy, nonatomic) void(^panGesture)(UIPanGestureRecognizer *gestureRecognizer);
|
||||
|
||||
@property (nonatomic, assign) CGFloat zoomLevel;
|
||||
- (void)setZoomLevel:(CGFloat)zoomLevel panning:(bool)panning;
|
||||
|
||||
- (void)setHidden:(bool)hidden animated:(bool)animated;
|
||||
|
||||
|
||||
@ -537,7 +537,7 @@ const NSInteger PGCameraFrameRate = 30;
|
||||
return;
|
||||
|
||||
CGFloat level = zoomLevel;
|
||||
CGFloat backingLevel = 1.0;
|
||||
CGFloat backingLevel = zoomLevel;
|
||||
if (iosMajorVersion() >= 13.0 && device.isVirtualDevice) {
|
||||
NSArray *marks = device.virtualDeviceSwitchOverVideoZoomFactors;
|
||||
if (marks.count == 2) {
|
||||
@ -830,6 +830,9 @@ const NSInteger PGCameraFrameRate = 30;
|
||||
if (device == nil) {
|
||||
device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInDualCamera mediaType:AVMediaTypeVideo position:position];
|
||||
}
|
||||
if (device == nil) {
|
||||
device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInDualWideCamera mediaType:AVMediaTypeVideo position:position];
|
||||
}
|
||||
if (device != nil) {
|
||||
return device;
|
||||
}
|
||||
|
||||
@ -455,7 +455,9 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
}
|
||||
|
||||
[_autorotationCorrectionView addSubview:_interfaceView];
|
||||
[_autorotationCorrectionView addSubview:_cornersView];
|
||||
if ((int)self.view.frame.size.width > 320 || [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
||||
[_autorotationCorrectionView addSubview:_cornersView];
|
||||
}
|
||||
|
||||
_photoSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
|
||||
_photoSwipeGestureRecognizer.delegate = self;
|
||||
@ -594,7 +596,8 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
TGDispatchOnMainThread(^
|
||||
{
|
||||
[strongSelf->_previewView endTransitionAnimated:true];
|
||||
|
||||
[strongSelf->_interfaceView setZoomLevel:1.0f displayNeeded:false];
|
||||
|
||||
if (!strongSelf->_dismissing)
|
||||
{
|
||||
strongSelf.view.userInteractionEnabled = true;
|
||||
@ -803,7 +806,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
{
|
||||
[strongSelf->_previewView beginTransitionWithSnapshotImage:image animated:false];
|
||||
|
||||
TGDispatchAfter(0.05, dispatch_get_main_queue(), ^{
|
||||
TGDispatchAfter(0.15, dispatch_get_main_queue(), ^{
|
||||
[strongSelf->_previewView endTransitionAnimated:true];
|
||||
strongSelf->_crossfadingForZoom = false;
|
||||
});
|
||||
@ -2659,6 +2662,8 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
|
||||
default:
|
||||
{
|
||||
if (widescreenWidth == 926.0f)
|
||||
return CGRectMake(0, 154, screenSize.width, screenSize.height - 154 - 249);
|
||||
if (widescreenWidth == 896.0f)
|
||||
return CGRectMake(0, 121, screenSize.width, screenSize.height - 121 - 223);
|
||||
else if (widescreenWidth == 844.0f)
|
||||
|
||||
@ -27,6 +27,8 @@ const CGFloat TGCameraFlashControlHeight = 44.0f;
|
||||
self = [super initWithFrame:frame];
|
||||
if (self != nil) {
|
||||
self.contentMode = UIViewContentModeRedraw;
|
||||
self.opaque = false;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -102,7 +104,8 @@ const CGFloat TGCameraFlashControlHeight = 44.0f;
|
||||
CGPathRelease(strokedPath);
|
||||
CGPathRelease(path);
|
||||
|
||||
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
|
||||
CGContextSetBlendMode(context, kCGBlendModeCopy);
|
||||
CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor);
|
||||
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
|
||||
CGContextDrawPath(context, kCGPathFillStroke);
|
||||
}
|
||||
|
||||
@ -64,6 +64,53 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation TGCameraSmallFlipButton
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self != nil)
|
||||
{
|
||||
self.exclusiveTouch = true;
|
||||
UIImage *image = TGTintedImage(TGComponentsImageNamed(@"CameraFlipButton"), [UIColor whiteColor]);
|
||||
[self setImage:image forState:UIControlStateNormal];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
{
|
||||
self.alpha = hidden ? 0.0f : 1.0f;
|
||||
super.hidden = hidden;
|
||||
}
|
||||
|
||||
- (void)setHidden:(bool)hidden animated:(bool)animated
|
||||
{
|
||||
if (animated)
|
||||
{
|
||||
super.hidden = false;
|
||||
self.userInteractionEnabled = false;
|
||||
|
||||
[UIView animateWithDuration:0.25f animations:^
|
||||
{
|
||||
self.alpha = hidden ? 0.0f : 1.0f;
|
||||
} completion:^(BOOL finished)
|
||||
{
|
||||
self.userInteractionEnabled = true;
|
||||
|
||||
if (finished)
|
||||
self.hidden = hidden;
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.alpha = hidden ? 0.0f : 1.0f;
|
||||
super.hidden = hidden;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TGCameraCancelButton
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ static NSString *TGCameraEncodeText(NSString *string, int key)
|
||||
|
||||
+ (UIColor *)accentColor
|
||||
{
|
||||
return UIColorRGB(0xffd60a);
|
||||
return UIColorRGB(0xf8d74a);
|
||||
}
|
||||
|
||||
+ (UIColor *)redColor
|
||||
|
||||
@ -64,7 +64,8 @@
|
||||
UIView *_videoLandscapePanelView;
|
||||
|
||||
TGCameraFlashControl *_flashControl;
|
||||
TGCameraFlashActiveView *_flashActiveView;
|
||||
|
||||
TGCameraSmallFlipButton *_topFlipButton;
|
||||
|
||||
bool _hasResults;
|
||||
|
||||
@ -137,7 +138,7 @@
|
||||
_topPanelOffset = 33.0f;
|
||||
_topPanelHeight = 44.0f;
|
||||
_bottomPanelOffset = 63.0f;
|
||||
_bottomPanelHeight = 123.0f;
|
||||
_bottomPanelHeight = 128.0f;
|
||||
_modeControlOffset = 3.0f;
|
||||
_modeControlHeight = 40.0f;
|
||||
_counterOffset = 7.0f;
|
||||
@ -198,6 +199,62 @@
|
||||
_topPanelBackgroundView.backgroundColor = [TGCameraInterfaceAssets transparentPanelBackgroundColor];
|
||||
[_topPanelView addSubview:_topPanelBackgroundView];
|
||||
|
||||
_zoomModeView = [[TGCameraZoomModeView alloc] initWithFrame:CGRectMake(floor((frame.size.width - 129.0) / 2.0), frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 18 - 43, 129, 43) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera minZoomLevel:hasUltrawideCamera ? 0.5 : 1.0 maxZoomLevel:8.0];
|
||||
_zoomModeView.zoomChanged = ^(CGFloat zoomLevel, bool done, bool animated) {
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
|
||||
if (done) {
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false];
|
||||
|
||||
if (!strongSelf->_zoomWheelView.isHidden) {
|
||||
strongSelf->_dismissingWheel = true;
|
||||
|
||||
TGDispatchAfter(0.6, dispatch_get_main_queue(), ^{
|
||||
if (strongSelf->_dismissingWheel) {
|
||||
[strongSelf->_zoomModeView setHidden:false animated:true];
|
||||
[strongSelf->_zoomWheelView setHidden:true animated:true];
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
strongSelf->_dismissingWheel = false;
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel panning:true];
|
||||
[strongSelf->_zoomModeView setHidden:true animated:true];
|
||||
[strongSelf->_zoomWheelView setHidden:false animated:true];
|
||||
}
|
||||
|
||||
if (strongSelf.zoomChanged != nil)
|
||||
strongSelf.zoomChanged(zoomLevel, animated);
|
||||
};
|
||||
[_zoomModeView setZoomLevel:1.0];
|
||||
if (hasTelephotoCamera || hasUltrawideCamera) {
|
||||
[self addSubview:_zoomModeView];
|
||||
}
|
||||
|
||||
_zoomWheelView = [[TGCameraZoomWheelView alloc] initWithFrame:CGRectMake(0.0, frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 132, frame.size.width, 132) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera];
|
||||
[_zoomWheelView setHidden:true animated:false];
|
||||
[_zoomWheelView setZoomLevel:1.0];
|
||||
_zoomWheelView.panGesture = ^(UIPanGestureRecognizer *gestureRecognizer) {
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
[strongSelf->_zoomModeView panGesture:gestureRecognizer];
|
||||
};
|
||||
if (hasTelephotoCamera || hasUltrawideCamera) {
|
||||
[self addSubview:_zoomWheelView];
|
||||
}
|
||||
|
||||
_zoomView = [[TGCameraZoomView alloc] initWithFrame:CGRectMake(10, frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 18, frame.size.width - 20, 1.5f)];
|
||||
_zoomView.activityChanged = ^(bool active)
|
||||
{
|
||||
};
|
||||
if (!hasTelephotoCamera && !hasUltrawideCamera) {
|
||||
[self addSubview:_zoomView];
|
||||
}
|
||||
|
||||
_bottomPanelView = [[UIView alloc] init];
|
||||
[self addSubview:_bottomPanelView];
|
||||
|
||||
@ -239,6 +296,11 @@
|
||||
_flashControl = [[TGCameraFlashControl alloc] initWithFrame:CGRectMake(3.0, 0, TGCameraFlashControlHeight, TGCameraFlashControlHeight)];
|
||||
[_topPanelView addSubview:_flashControl];
|
||||
|
||||
_topFlipButton = [[TGCameraSmallFlipButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
|
||||
_topFlipButton.hidden = true;
|
||||
[_topFlipButton addTarget:self action:@selector(flipButtonPressed) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_topPanelView addSubview:_topFlipButton];
|
||||
|
||||
_timecodeView = [[TGCameraTimeCodeView alloc] initWithFrame:CGRectMake((frame.size.width - 120) / 2, 12, 120, 28)];
|
||||
_timecodeView.alpha = 0.0;
|
||||
_timecodeView.requestedRecordingDuration = ^NSTimeInterval
|
||||
@ -254,54 +316,13 @@
|
||||
|
||||
_videoLandscapePanelView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 274, 44)];
|
||||
_videoLandscapePanelView.alpha = 0.0f;
|
||||
_videoLandscapePanelView.backgroundColor = [TGCameraInterfaceAssets transparentPanelBackgroundColor];
|
||||
_videoLandscapePanelView.hidden = true;
|
||||
_videoLandscapePanelView.layer.cornerRadius = 3.5f;
|
||||
[self addSubview:_videoLandscapePanelView];
|
||||
|
||||
_toastView = [[TGCameraToastView alloc] initWithFrame:CGRectMake(0, frame.size.height - _bottomPanelHeight - 42, frame.size.width, 32)];
|
||||
_toastView.userInteractionEnabled = false;
|
||||
[self addSubview:_toastView];
|
||||
|
||||
_zoomModeView = [[TGCameraZoomModeView alloc] initWithFrame:CGRectMake(floor((frame.size.width - 129.0) / 2.0), frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 18 - 43, 129, 43) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera minZoomLevel:hasUltrawideCamera ? 0.5 : 1.0 maxZoomLevel:8.0];
|
||||
_zoomModeView.zoomChanged = ^(CGFloat zoomLevel, bool done, bool animated) {
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
|
||||
if (done) {
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false];
|
||||
|
||||
if (!strongSelf->_zoomWheelView.isHidden) {
|
||||
strongSelf->_dismissingWheel = true;
|
||||
|
||||
TGDispatchAfter(0.6, dispatch_get_main_queue(), ^{
|
||||
if (strongSelf->_dismissingWheel) {
|
||||
[strongSelf->_zoomModeView setHidden:false animated:true];
|
||||
// [strongSelf->_zoomWheelView setHidden:true animated:true];
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
strongSelf->_dismissingWheel = false;
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setHidden:true animated:true];
|
||||
// [strongSelf->_zoomWheelView setHidden:false animated:true];
|
||||
}
|
||||
|
||||
if (strongSelf.zoomChanged != nil)
|
||||
strongSelf.zoomChanged(zoomLevel, animated);
|
||||
};
|
||||
[_zoomModeView setZoomLevel:1.0];
|
||||
[self addSubview:_zoomModeView];
|
||||
|
||||
_zoomWheelView = [[TGCameraZoomWheelView alloc] initWithFrame:CGRectMake(0.0, frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 132, frame.size.width, 132) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera];
|
||||
[_zoomWheelView setHidden:true animated:false];
|
||||
[_zoomWheelView setZoomLevel:1.0];
|
||||
_zoomWheelView.userInteractionEnabled = false;
|
||||
[self addSubview:_zoomWheelView];
|
||||
|
||||
_flashControl.modeChanged = ^(PGCameraFlashMode mode)
|
||||
{
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
@ -379,13 +400,15 @@
|
||||
if (results.count == 0)
|
||||
{
|
||||
_hasResults = false;
|
||||
_topFlipButton.hidden = true;
|
||||
_flipButton.hidden = false;
|
||||
_doneButton.hidden = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasResults = true;
|
||||
_flipButton.hidden = false;
|
||||
_topFlipButton.hidden = _modeControl.cameraMode == PGCameraModePhotoScan;
|
||||
_flipButton.hidden = true;
|
||||
_doneButton.hidden = false;
|
||||
if (_modeControl.cameraMode == PGCameraModePhotoScan) {
|
||||
_modeControl.hidden = true;
|
||||
@ -444,7 +467,7 @@
|
||||
{
|
||||
UIView *view = [super hitTest:point withEvent:event];
|
||||
|
||||
if ([view isDescendantOfView:_topPanelView] || [view isDescendantOfView:_bottomPanelView] || [view isDescendantOfView:_videoLandscapePanelView] || [view isDescendantOfView:_tooltipContainerView] || [view isDescendantOfView:_selectedPhotosView] || [view isDescendantOfView:_zoomModeView] || view == _zoomModeView)
|
||||
if ([view isDescendantOfView:_topPanelView] || [view isDescendantOfView:_bottomPanelView] || [view isDescendantOfView:_videoLandscapePanelView] || [view isDescendantOfView:_tooltipContainerView] || [view isDescendantOfView:_selectedPhotosView] || [view isDescendantOfView:_zoomModeView] || view == _zoomModeView || (view == _zoomWheelView && !_zoomWheelView.isHidden))
|
||||
return view;
|
||||
|
||||
return nil;
|
||||
@ -561,6 +584,8 @@
|
||||
{
|
||||
bool hasDoneButton = _hasResults;
|
||||
|
||||
_zoomWheelView.clipsToBounds = !hidden;
|
||||
|
||||
if (animated)
|
||||
{
|
||||
if (!hidden)
|
||||
@ -568,10 +593,16 @@
|
||||
_modeControl.hidden = false;
|
||||
_cancelButton.hidden = false;
|
||||
_flashControl.hidden = false;
|
||||
_flipButton.hidden = false;
|
||||
_flipButton.hidden = hasDoneButton;
|
||||
_topFlipButton.hidden = !hasDoneButton;
|
||||
_bottomPanelBackgroundView.hidden = false;
|
||||
}
|
||||
|
||||
[UIView animateWithDuration:0.2 delay:0.0 options:7 << 16 animations:^{
|
||||
CGFloat offset = hidden ? 19 : 18 + 43;
|
||||
_zoomModeView.frame = CGRectMake(floor((self.bounds.size.width - 129.0) / 2.0), self.bounds.size.height - _bottomPanelHeight - _bottomPanelOffset - offset, 129, 43);
|
||||
} completion:nil];
|
||||
|
||||
[UIView animateWithDuration:0.25 animations:^
|
||||
{
|
||||
CGFloat alpha = hidden ? 0.0f : 1.0f;
|
||||
@ -579,6 +610,7 @@
|
||||
_cancelButton.alpha = alpha;
|
||||
_flashControl.alpha = alpha;
|
||||
_flipButton.alpha = alpha;
|
||||
_topFlipButton.alpha = alpha;
|
||||
_bottomPanelBackgroundView.alpha = alpha;
|
||||
|
||||
if (hasDoneButton)
|
||||
@ -590,7 +622,8 @@
|
||||
_modeControl.hidden = hidden;
|
||||
_cancelButton.hidden = hidden;
|
||||
_flashControl.hidden = hidden;
|
||||
_flipButton.hidden = hidden;
|
||||
_flipButton.hidden = hidden || hasDoneButton;
|
||||
_topFlipButton.hidden = hidden || !hasDoneButton;
|
||||
_bottomPanelBackgroundView.hidden = hidden;
|
||||
|
||||
if (hasDoneButton)
|
||||
@ -609,11 +642,16 @@
|
||||
_cancelButton.alpha = alpha;
|
||||
_flashControl.hidden = hidden;
|
||||
_flashControl.alpha = alpha;
|
||||
_flipButton.hidden = hidden;
|
||||
_flipButton.hidden = hidden || hasDoneButton;
|
||||
_flipButton.alpha = alpha;
|
||||
_topFlipButton.hidden = hidden || !hasDoneButton;
|
||||
_topFlipButton.alpha = alpha;
|
||||
_bottomPanelBackgroundView.hidden = hidden;
|
||||
_bottomPanelBackgroundView.alpha = alpha;
|
||||
|
||||
CGFloat offset = hidden ? 19 : 18 + 43;
|
||||
_zoomModeView.frame = CGRectMake(floor((self.bounds.size.width - 129.0) / 2.0), self.bounds.size.height - _bottomPanelHeight - _bottomPanelOffset - offset, 129, 43);
|
||||
|
||||
if (hasDoneButton)
|
||||
{
|
||||
_doneButton.hidden = hidden;
|
||||
@ -642,13 +680,15 @@
|
||||
{
|
||||
if (_modeControl.cameraMode == PGCameraModeVideo)
|
||||
{
|
||||
_topPanelView.alpha = 0.0f;
|
||||
_videoLandscapePanelView.alpha = 0.0f;
|
||||
}
|
||||
|
||||
_flipButton.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||
_flashControl.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||
_zoomModeView.interfaceOrientation = orientation;
|
||||
_timecodeView.interfaceOrientation = orientation;
|
||||
_zoomWheelView.interfaceOrientation = orientation;
|
||||
_topFlipButton.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||
} completion:^(__unused BOOL finished)
|
||||
{
|
||||
if (_modeControl.cameraMode == PGCameraModeVideo)
|
||||
@ -669,8 +709,6 @@
|
||||
{
|
||||
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||
_videoLandscapePanelView.alpha = 1.0f;
|
||||
else
|
||||
_topPanelView.alpha = 1.0f;
|
||||
}
|
||||
} completion:nil];
|
||||
}];
|
||||
@ -680,6 +718,9 @@
|
||||
_flipButton.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||
_flashControl.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||
_zoomModeView.interfaceOrientation = orientation;
|
||||
_timecodeView.interfaceOrientation = orientation;
|
||||
_zoomWheelView.interfaceOrientation = orientation;
|
||||
_topFlipButton.transform = CGAffineTransformMakeRotation(TGRotationForInterfaceOrientation(orientation));
|
||||
|
||||
[self _layoutTopPanelSubviewsForInterfaceOrientation:orientation];
|
||||
}
|
||||
@ -694,7 +735,6 @@
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
{
|
||||
_videoLandscapePanelView.hidden = false;
|
||||
_topPanelView.hidden = true;
|
||||
|
||||
_videoLandscapePanelView.transform = transform;
|
||||
_videoLandscapePanelView.frame = CGRectMake(3, (self.frame.size.height - _videoLandscapePanelView.frame.size.height) / 2, _videoLandscapePanelView.frame.size.width, _videoLandscapePanelView.frame.size.height);
|
||||
@ -703,7 +743,6 @@
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
{
|
||||
_videoLandscapePanelView.hidden = false;
|
||||
_topPanelView.hidden = true;
|
||||
|
||||
_videoLandscapePanelView.transform = transform;
|
||||
_videoLandscapePanelView.frame = CGRectMake(self.frame.size.width - _videoLandscapePanelView.frame.size.width - 3, (self.frame.size.height - _videoLandscapePanelView.frame.size.height) / 2, _videoLandscapePanelView.frame.size.width, _videoLandscapePanelView.frame.size.height);
|
||||
@ -713,20 +752,18 @@
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
{
|
||||
_videoLandscapePanelView.hidden = true;
|
||||
_topPanelView.hidden = false;
|
||||
|
||||
_topPanelView.transform = transform;
|
||||
_topPanelView.frame = CGRectMake(0, 0, _topPanelView.frame.size.width, _topPanelView.frame.size.height);
|
||||
_topPanelView.frame = CGRectMake(0, _topPanelOffset, _topPanelView.frame.size.width, _topPanelView.frame.size.height);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
_videoLandscapePanelView.hidden = true;
|
||||
_topPanelView.hidden = false;
|
||||
|
||||
_topPanelView.transform = transform;
|
||||
_topPanelView.frame = CGRectMake(0, 0, _topPanelView.frame.size.width, _topPanelView.frame.size.height);
|
||||
_topPanelView.frame = CGRectMake(0, _topPanelOffset, _topPanelView.frame.size.width, _topPanelView.frame.size.height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -744,7 +781,7 @@
|
||||
|
||||
- (void)_layoutTopPanelSubviewsForInterfaceOrientation:(UIInterfaceOrientation)orientation
|
||||
{
|
||||
UIView *superview = _flashControl.superview;
|
||||
UIView *superview = _timecodeView.superview;
|
||||
CGSize superviewSize = superview.frame.size;
|
||||
|
||||
if (superview == _videoLandscapePanelView && superviewSize.width < superviewSize.height)
|
||||
@ -777,6 +814,8 @@
|
||||
|
||||
_flipButton.frame = CGRectMake(self.frame.size.width - _flipButton.frame.size.width - 20.0f, round(_shutterButton.center.y - _flipButton.frame.size.height / 2.0f), _flipButton.frame.size.width, _flipButton.frame.size.height);
|
||||
|
||||
_topFlipButton.frame = CGRectMake(self.frame.size.width - _topFlipButton.frame.size.width - 4.0f, 0.0f, _topFlipButton.frame.size.width, _topFlipButton.frame.size.height);
|
||||
|
||||
_toastView.frame = CGRectMake(0, self.frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 32 - 16, self.frame.size.width, 32);
|
||||
|
||||
CGFloat photosViewSize = TGPhotoThumbnailSizeForCurrentScreen().height + 4 * 2;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
@interface TGCameraTimeCodeView ()
|
||||
{
|
||||
UIView *_backgroundView;
|
||||
UIView *_recordingBackgroundView;
|
||||
UILabel *_timeLabel;
|
||||
|
||||
NSUInteger _recordingDurationSeconds;
|
||||
@ -25,10 +26,17 @@
|
||||
_backgroundView = [[UIView alloc] init];
|
||||
_backgroundView.clipsToBounds = true;
|
||||
_backgroundView.layer.cornerRadius = 4.0;
|
||||
_backgroundView.backgroundColor = [TGCameraInterfaceAssets redColor];
|
||||
_backgroundView.backgroundColor = [TGCameraInterfaceAssets transparentPanelBackgroundColor];
|
||||
_backgroundView.alpha = 0.0;
|
||||
[self addSubview:_backgroundView];
|
||||
|
||||
_recordingBackgroundView = [[UIView alloc] init];
|
||||
_recordingBackgroundView.clipsToBounds = true;
|
||||
_recordingBackgroundView.layer.cornerRadius = 4.0;
|
||||
_recordingBackgroundView.backgroundColor = [TGCameraInterfaceAssets redColor];
|
||||
_recordingBackgroundView.alpha = 0.0;
|
||||
[self addSubview:_recordingBackgroundView];
|
||||
|
||||
_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
|
||||
_timeLabel.backgroundColor = [UIColor clearColor];
|
||||
_timeLabel.font = [TGCameraInterfaceAssets regularFontOfSize:21];
|
||||
@ -45,6 +53,12 @@
|
||||
[self stopRecording];
|
||||
}
|
||||
|
||||
- (void)setInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
_interfaceOrientation = interfaceOrientation;
|
||||
|
||||
_backgroundView.alpha = UIInterfaceOrientationIsLandscape(interfaceOrientation) ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
- (void)_updateRecordingTime
|
||||
{
|
||||
if (_recordingDurationSeconds > 60 * 60) {
|
||||
@ -57,6 +71,7 @@
|
||||
CGFloat inset = 8.0f;
|
||||
CGFloat backgroundWidth = _timeLabel.frame.size.width + inset * 2.0;
|
||||
_backgroundView.frame = CGRectMake(floor((self.frame.size.width - backgroundWidth) / 2.0), 0.0, backgroundWidth, 28.0);
|
||||
_recordingBackgroundView.frame = _backgroundView.frame;
|
||||
|
||||
_timeLabel.frame = CGRectMake(floor((self.frame.size.width - _timeLabel.frame.size.width) / 2.0), floor((28 - _timeLabel.frame.size.height) / 2.0), _timeLabel.frame.size.width, _timeLabel.frame.size.height);
|
||||
}
|
||||
@ -68,7 +83,7 @@
|
||||
_recordingTimer = [TGTimerTarget scheduledMainThreadTimerWithTarget:self action:@selector(recordingTimerEvent) interval:1.0 repeat:false];
|
||||
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
_backgroundView.alpha = 1.0;
|
||||
_recordingBackgroundView.alpha = 1.0;
|
||||
}];
|
||||
}
|
||||
|
||||
@ -78,7 +93,7 @@
|
||||
_recordingTimer = nil;
|
||||
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
_backgroundView.alpha = 0.0;
|
||||
_recordingBackgroundView.alpha = 0.0;
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetStrokeColorWithColor(context, [TGCameraInterfaceAssets accentColor].CGColor);
|
||||
CGContextSetLineWidth(context, 1.5f);
|
||||
CGContextSetLineWidth(context, 1.0f);
|
||||
CGContextStrokeEllipseInRect(context, CGRectMake(0.75f, 0.75f, 12.5f - 1.5f, 12.5f - 1.5f));
|
||||
|
||||
knobImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
@ -170,7 +170,11 @@
|
||||
{
|
||||
_clipView.frame = CGRectMake(22, (self.frame.size.height - 12.5f) / 2, self.frame.size.width - 44, 12.5f);
|
||||
|
||||
CGFloat position = (_clipView.frame.size.width - _knobView.frame.size.width) * self.zoomLevel;
|
||||
CGFloat zoomLevel = self.zoomLevel;
|
||||
zoomLevel = MAX(1.0, zoomLevel);
|
||||
CGFloat factor = zoomLevel / 8.0;
|
||||
|
||||
CGFloat position = (_clipView.frame.size.width - _knobView.frame.size.width) * factor;
|
||||
if (self.zoomLevel < 1.0f - FLT_EPSILON)
|
||||
position = CGFloor(position);
|
||||
|
||||
@ -196,6 +200,7 @@
|
||||
|
||||
_label = [[UILabel alloc] initWithFrame:self.bounds];
|
||||
_label.textAlignment = NSTextAlignmentCenter;
|
||||
_label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
|
||||
[self addSubview:_backgroundView];
|
||||
[self addSubview:_label];
|
||||
@ -209,7 +214,6 @@
|
||||
|
||||
_label.text = value;
|
||||
_label.textColor = selected ? [TGCameraInterfaceAssets accentColor] : [UIColor whiteColor];
|
||||
_label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
|
||||
if (animated) {
|
||||
[UIView animateWithDuration:0.3f animations:^
|
||||
@ -225,7 +229,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface TGCameraZoomModeView ()
|
||||
@interface TGCameraZoomModeView () <UIGestureRecognizerDelegate>
|
||||
{
|
||||
CGFloat _minZoomLevel;
|
||||
CGFloat _maxZoomLevel;
|
||||
@ -276,14 +280,24 @@
|
||||
}
|
||||
|
||||
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
|
||||
panGestureRecognizer.delegate = self;
|
||||
[self addGestureRecognizer:panGestureRecognizer];
|
||||
|
||||
UILongPressGestureRecognizer *pressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pressGesture:)];
|
||||
pressGestureRecognizer.delegate = self;
|
||||
[self addGestureRecognizer:pressGestureRecognizer];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
||||
if (gestureRecognizer.view == self && otherGestureRecognizer.view == self) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pressGesture:(UILongPressGestureRecognizer *)gestureRecognizer {
|
||||
switch (gestureRecognizer.state) {
|
||||
case UIGestureRecognizerStateBegan:
|
||||
@ -305,8 +319,23 @@
|
||||
|
||||
switch (gestureRecognizer.state) {
|
||||
case UIGestureRecognizerStateChanged:
|
||||
_zoomLevel = MAX(0.5, MIN(10.0, _zoomLevel - translation.x / 100.0));
|
||||
{
|
||||
CGFloat delta = -translation.x / 100.0;
|
||||
if (_zoomLevel > 2.0) {
|
||||
delta *= 2.2;
|
||||
}
|
||||
|
||||
_zoomLevel = MAX(_minZoomLevel, MIN(_maxZoomLevel, _zoomLevel + delta));
|
||||
self.zoomChanged(_zoomLevel, false, false);
|
||||
}
|
||||
break;
|
||||
case UIGestureRecognizerStateEnded:
|
||||
case UIGestureRecognizerStateCancelled:
|
||||
{
|
||||
if (gestureRecognizer.view != self) {
|
||||
self.zoomChanged(_zoomLevel, true, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -338,40 +367,39 @@
|
||||
{
|
||||
_zoomLevel = zoomLevel;
|
||||
if (zoomLevel < 1.0) {
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
if ([value isEqual:@"1,0x"]) {
|
||||
value = @"0,9x";
|
||||
}
|
||||
NSString *value = [NSString stringWithFormat:@"%.1f×", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
if ([value isEqual:@"1,0×"] || [value isEqual:@"1×"]) {
|
||||
value = @"0,9×";
|
||||
}
|
||||
[_leftItem setValue:value selected:true animated:animated];
|
||||
[_centerItem setValue:@"1" selected:false animated:animated];
|
||||
[_rightItem setValue:@"2" selected:false animated:animated];
|
||||
} else if (zoomLevel < 2.0) {
|
||||
[_leftItem setValue:@"0,5" selected:false animated:animated];
|
||||
if ((zoomLevel - 1.0) < 0.1) {
|
||||
[_centerItem setValue:@"1x" selected:true animated:animated];
|
||||
if ((zoomLevel - 1.0) < 0.025) {
|
||||
[_centerItem setValue:@"1×" selected:true animated:animated];
|
||||
} else {
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
NSString *value = [NSString stringWithFormat:@"%.1f×", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
if ([value isEqual:@"1,0x"]) {
|
||||
value = @"1x";
|
||||
} else if ([value isEqual:@"2,0x"]) {
|
||||
value = @"1,9x";
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0×" withString:@"×"];
|
||||
if ([value isEqual:@"2×"]) {
|
||||
value = @"1,9×";
|
||||
}
|
||||
[_centerItem setValue:value selected:true animated:animated];
|
||||
}
|
||||
[_rightItem setValue:@"2" selected:false animated:animated];
|
||||
} else {
|
||||
[_leftItem setValue:@"0,5" selected:false animated:animated];
|
||||
[_centerItem setValue:@"1" selected:false animated:animated];
|
||||
|
||||
NSString *value = [[NSString stringWithFormat:@"%.1f×", zoomLevel] stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0×" withString:@"×"];
|
||||
|
||||
CGFloat near = round(zoomLevel);
|
||||
if (ABS(zoomLevel - near) < 0.1) {
|
||||
[_rightItem setValue:[NSString stringWithFormat:@"%dx", (int)zoomLevel] selected:true animated:animated];
|
||||
} else {
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
if (_rightItem.superview != nil) {
|
||||
[_centerItem setValue:@"1" selected:false animated:animated];
|
||||
[_rightItem setValue:value selected:true animated:animated];
|
||||
} else {
|
||||
[_centerItem setValue:value selected:true animated:animated];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,9 +437,13 @@
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
if (_rightItem.superview == nil) {
|
||||
if (_leftItem.superview == nil && _rightItem.superview == nil) {
|
||||
_backgroundView.frame = CGRectMake(43, 0, 43, 43);
|
||||
} else if (_leftItem.superview == nil) {
|
||||
} else if (_leftItem.superview != nil && _rightItem.superview == nil) {
|
||||
_backgroundView.frame = CGRectMake(21 + TGScreenPixel, 0, 86, 43);
|
||||
_leftItem.frame = CGRectMake(21 + TGScreenPixel, 0, 43, 43);
|
||||
_centerItem.frame = CGRectMake(21 + TGScreenPixel + 43, 0, 43, 43);
|
||||
} else if (_leftItem.superview == nil && _rightItem.superview != nil) {
|
||||
_backgroundView.frame = CGRectMake(21 + TGScreenPixel, 0, 86, 43);
|
||||
_centerItem.frame = CGRectMake(21 + TGScreenPixel, 0, 43, 43);
|
||||
_rightItem.frame = CGRectMake(21 + TGScreenPixel + 43, 0, 43, 43);
|
||||
@ -437,7 +469,21 @@
|
||||
{
|
||||
bool _hasUltrawideCamera;
|
||||
bool _hasTelephotoCamera;
|
||||
UIView *_containerView;
|
||||
UIImageView *_backgroundView;
|
||||
UIImageView *_scaleView;
|
||||
UIImageView *_maskView;
|
||||
UIImageView *_arrowView;
|
||||
|
||||
UILabel *_valueLabel;
|
||||
UILabel *_05Label;
|
||||
UILabel *_1Label;
|
||||
UILabel *_2Label;
|
||||
UILabel *_8Label;
|
||||
|
||||
UIPanGestureRecognizer *_gestureRecognizer;
|
||||
|
||||
UISelectionFeedbackGenerator *_feedbackGenerator;
|
||||
}
|
||||
@end
|
||||
|
||||
@ -459,84 +505,355 @@
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
- (NSArray *)ultraLines {
|
||||
return @[
|
||||
@[@0.5, @-19.6, @3],
|
||||
@[@0.6, @-14.4, @1],
|
||||
@[@0.7, @-10.0, @1],
|
||||
@[@0.8, @-6.3, @1],
|
||||
@[@0.9, @-3.0, @1]
|
||||
];
|
||||
}
|
||||
|
||||
- (NSArray *)lines {
|
||||
return @[
|
||||
@[@1.0, @0.0, @3],
|
||||
|
||||
@[@1.1, @2.7, @1],
|
||||
@[@1.2, @5.2, @1],
|
||||
@[@1.3, @7.4, @1],
|
||||
@[@1.4, @9.6, @1],
|
||||
@[@1.5, @11.5, @1],
|
||||
@[@1.6, @13.3, @1],
|
||||
@[@1.7, @15.0, @1],
|
||||
@[@1.8, @16.7, @1],
|
||||
@[@1.9, @18.2, @1],
|
||||
@[@2.0, @19.6, _hasTelephotoCamera ? @3 : @2],
|
||||
|
||||
@[@2.1, @21.0, @1],
|
||||
@[@2.2, @22.4, @1],
|
||||
@[@2.3, @23.7, @1],
|
||||
@[@2.4, @24.8, @1],
|
||||
@[@2.5, @26.0, @1],
|
||||
@[@2.6, @27.1, @1],
|
||||
@[@2.7, @28.2, @1],
|
||||
@[@2.8, @29.2, @1],
|
||||
@[@2.9, @30.2, @1],
|
||||
@[@3.0, @31.1, @2],
|
||||
|
||||
@[@3.1, @32.0, @1],
|
||||
@[@3.2, @32.9, @1],
|
||||
@[@3.3, @33.8, @1],
|
||||
@[@3.4, @34.7, @1],
|
||||
@[@3.5, @35.5, @1],
|
||||
@[@3.6, @36.34, @1],
|
||||
@[@3.7, @37.1, @1],
|
||||
@[@3.8, @37.85, @1],
|
||||
@[@3.9, @38.55, @1],
|
||||
@[@4.0, @39.3, @2],
|
||||
|
||||
@[@4.1, @40.0, @1],
|
||||
@[@4.2, @40.77, @1],
|
||||
@[@4.3, @41.4, @1],
|
||||
@[@4.4, @42.05, @1],
|
||||
@[@4.5, @42.63, @1],
|
||||
@[@4.6, @43.3, @1],
|
||||
@[@4.7, @43.89, @1],
|
||||
@[@4.8, @44.42, @1],
|
||||
@[@4.9, @45.05, @1],
|
||||
@[@5.0, @45.6, @2],
|
||||
|
||||
@[@5.1, @46.17, @1],
|
||||
@[@5.2, @46.77, @1],
|
||||
@[@5.3, @47.31, @1],
|
||||
@[@5.4, @47.78, @1],
|
||||
@[@5.5, @48.34, @1],
|
||||
@[@5.6, @48.8, @1],
|
||||
@[@5.7, @49.31, @1],
|
||||
@[@5.8, @49.85, @1],
|
||||
@[@5.9, @50.3, @1],
|
||||
@[@6.0, @50.8, @2],
|
||||
|
||||
@[@6.1, @51.25, @1],
|
||||
@[@6.2, @51.7, @1],
|
||||
@[@6.3, @52.18, @1],
|
||||
@[@6.4, @52.63, @1],
|
||||
@[@6.5, @53.12, @1],
|
||||
@[@6.6, @53.49, @1],
|
||||
@[@6.7, @53.88, @1],
|
||||
@[@6.8, @54.28, @1],
|
||||
@[@6.9, @54.71, @1],
|
||||
@[@7.0, @55.15, @2],
|
||||
|
||||
@[@7.1, @55.53, @1],
|
||||
@[@7.2, @55.91, @1],
|
||||
@[@7.3, @56.36, @1],
|
||||
@[@7.4, @56.74, @1],
|
||||
@[@7.5, @57.09, @1],
|
||||
@[@7.6, @57.52, @1],
|
||||
@[@7.7, @57.89, @1],
|
||||
@[@7.8, @58.19, @1],
|
||||
@[@7.9, @58.56, @1],
|
||||
@[@8.0, @58.93, @3],
|
||||
];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame hasUltrawideCamera:(bool)hasUltrawideCamera hasTelephotoCamera:(bool)hasTelephotoCamera
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self != nil)
|
||||
{
|
||||
_hasUltrawideCamera = true;// hasUltrawideCamera;
|
||||
_hasTelephotoCamera = true;//hasTelephotoCamera;
|
||||
TGIsRetina();
|
||||
|
||||
self.clipsToBounds = true;
|
||||
|
||||
if (iosMajorVersion() >= 10) {
|
||||
_feedbackGenerator = [[UISelectionFeedbackGenerator alloc] init];
|
||||
}
|
||||
|
||||
_hasUltrawideCamera = hasUltrawideCamera;
|
||||
_hasTelephotoCamera = hasTelephotoCamera;
|
||||
|
||||
CGFloat side = floor(frame.size.width * 1.1435);
|
||||
CGFloat length = 17.0;
|
||||
CGFloat smallWidth = MAX(0.5, 1.0 - TGScreenPixel);
|
||||
CGFloat mediumWidth = 1.0;
|
||||
CGFloat bigWidth = 1.0 + TGScreenPixel;
|
||||
|
||||
CGFloat smallAngle = M_PI * 0.12;
|
||||
CGFloat finalAngle = 1.08;
|
||||
CGFloat mediumWidth = smallWidth;
|
||||
CGFloat bigWidth = 1.0;
|
||||
|
||||
_backgroundView = [[UIImageView alloc] initWithImage:TGCircleImage(side, [UIColor colorWithWhite:0.0 alpha:0.5])];
|
||||
_backgroundView.frame = CGRectMake(TGScreenPixelFloor((frame.size.width - side) / 2.0), 0.0, side, side);
|
||||
[self addSubview:_backgroundView];
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(side, side), false, 0.0f);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:0.0 alpha:0.75].CGColor);
|
||||
CGContextFillEllipseInRect(context, CGRectMake(0, 0, side, side));
|
||||
|
||||
[self _drawLineInContext:context side:side atAngle:0.0 lineLength:length lineWidth:bigWidth opaque:true];
|
||||
NSArray *ultraLines = [self ultraLines];
|
||||
NSArray *lines = [self lines];
|
||||
|
||||
if (_hasUltrawideCamera) {
|
||||
for (NSInteger i = 0; i < 4; i++) {
|
||||
CGFloat angle = (smallAngle / 5.0) * (i + 1) + (0.007 * (i - 1));
|
||||
[self _drawLineInContext:context side:side atAngle:-angle lineLength:length lineWidth:smallWidth opaque:false];
|
||||
for (NSArray *values in ultraLines) {
|
||||
CGFloat angle = [values[1] floatValue];
|
||||
CGFloat width = [values[2] intValue];
|
||||
|
||||
CGFloat lineWidth = smallWidth;
|
||||
if (width == 2) {
|
||||
lineWidth = mediumWidth;
|
||||
} else if (width == 3) {
|
||||
lineWidth = bigWidth;
|
||||
}
|
||||
[self _drawLineInContext:context side:side atAngle:TGDegreesToRadians(angle) lineLength:length lineWidth:lineWidth opaque:width > 1];
|
||||
}
|
||||
[self _drawLineInContext:context side:side atAngle:-smallAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
}
|
||||
if (_hasTelephotoCamera) {
|
||||
[self _drawLineInContext:context side:side atAngle:smallAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
for (NSArray *values in lines) {
|
||||
CGFloat angle = [values[1] floatValue];
|
||||
CGFloat width = [values[2] intValue];
|
||||
|
||||
for (NSInteger i = 0; i < 4; i++) {
|
||||
CGFloat angle = (smallAngle / 5.0) * (i + 1) + (0.01 * (i - 1));
|
||||
[self _drawLineInContext:context side:side atAngle:angle lineLength:length lineWidth:smallWidth opaque:false];
|
||||
CGFloat lineWidth = smallWidth;
|
||||
if (width == 2) {
|
||||
lineWidth = mediumWidth;
|
||||
} else if (width == 3) {
|
||||
lineWidth = bigWidth;
|
||||
}
|
||||
|
||||
[self _drawLineInContext:context side:side atAngle:finalAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
} else {
|
||||
[self _drawLineInContext:context side:side atAngle:smallAngle lineLength:length lineWidth:mediumWidth opaque:true];
|
||||
|
||||
[self _drawLineInContext:context side:side atAngle:finalAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
[self _drawLineInContext:context side:side atAngle:TGDegreesToRadians(angle) lineLength:length lineWidth:lineWidth opaque:width > 1];
|
||||
}
|
||||
|
||||
|
||||
UIImage *image = [UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:25 topCapHeight:25];
|
||||
|
||||
UIImage *scaleImage = [UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:25 topCapHeight:25];
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
_backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(TGScreenPixelFloor((frame.size.width - side) / 2.0), 0.0, side, side)];
|
||||
_backgroundView.image = image;
|
||||
_containerView = [[UIView alloc] initWithFrame:CGRectMake(TGScreenPixelFloor((frame.size.width - side) / 2.0), 0.0, side, frame.size.height)];
|
||||
_containerView.userInteractionEnabled = false;
|
||||
[self addSubview:_containerView];
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(side, frame.size.height), false, 0.0f);
|
||||
context = UIGraphicsGetCurrentContext();
|
||||
|
||||
[self addSubview:_backgroundView];
|
||||
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
|
||||
CGContextFillEllipseInRect(context, CGRectMake(0, 0, side, side));
|
||||
|
||||
CGContextSetBlendMode(context, kCGBlendModeClear);
|
||||
CGContextMoveToPoint(context, side / 2.0 - 7.0, 0);
|
||||
CGContextAddLineToPoint(context, side / 2.0 + 7.0, 0);
|
||||
CGContextAddLineToPoint(context, side / 2.0 + 2.0, 22);
|
||||
CGContextAddLineToPoint(context, side / 2.0 - 2.0, 22);
|
||||
CGContextClosePath(context);
|
||||
CGContextFillPath(context);
|
||||
|
||||
CGContextFillRect(context, CGRectMake(side / 2.0 - 1.0, 20, 2.0, 7.0));
|
||||
CGContextFillEllipseInRect(context, CGRectMake(side / 2.0 - 17.0, 21.0, 34.0, 34.0));
|
||||
|
||||
UIImage *maskImage = [UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:25 topCapHeight:25];
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
_maskView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, side, frame.size.height)];
|
||||
_maskView.image = maskImage;
|
||||
_containerView.maskView = _maskView;
|
||||
|
||||
_scaleView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, side, side)];
|
||||
_scaleView.image = scaleImage;
|
||||
[_containerView addSubview:_scaleView];
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(4, 10), false, 0.0f);
|
||||
context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetFillColorWithColor(context, [TGCameraInterfaceAssets accentColor].CGColor);
|
||||
CGContextMoveToPoint(context, 0, 0);
|
||||
CGContextAddLineToPoint(context, 4, 0);
|
||||
CGContextAddLineToPoint(context, 2 + TGScreenPixel, 10);
|
||||
CGContextAddLineToPoint(context, 2 - TGScreenPixel, 10);
|
||||
CGContextClosePath(context);
|
||||
CGContextFillPath(context);
|
||||
|
||||
UIImage *arrowImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
_arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(floor((frame.size.width - 4) / 2.0), 4, 4, 10)];
|
||||
_arrowView.image = arrowImage;
|
||||
_arrowView.userInteractionEnabled = false;
|
||||
[self addSubview:_arrowView];
|
||||
|
||||
_valueLabel = [[UILabel alloc] init];
|
||||
_valueLabel.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_valueLabel.textColor = [TGCameraInterfaceAssets accentColor];
|
||||
_valueLabel.userInteractionEnabled = false;
|
||||
[self addSubview:_valueLabel];
|
||||
|
||||
CGFloat radius = side / 2.0;
|
||||
if (_hasUltrawideCamera) {
|
||||
_05Label = [[UILabel alloc] init];
|
||||
_05Label.text = @"0,5";
|
||||
_05Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_05Label.textColor = [UIColor whiteColor];
|
||||
[_05Label sizeToFit];
|
||||
[_scaleView addSubview:_05Label];
|
||||
|
||||
_05Label.center = CGPointMake(radius - sin(TGDegreesToRadians(19.6)) * (radius - 38.0), radius - cos(TGDegreesToRadians(19.6)) * (radius - 38.0));
|
||||
_05Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(-19.6));
|
||||
}
|
||||
|
||||
_1Label = [[UILabel alloc] init];
|
||||
_1Label.text = @"1";
|
||||
_1Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_1Label.textColor = [UIColor whiteColor];
|
||||
[_1Label sizeToFit];
|
||||
_1Label.frame = CGRectMake(TGScreenPixelFloor((_scaleView.bounds.size.width - _1Label.frame.size.width) / 2.0), 30.0, _1Label.frame.size.width, _1Label.frame.size.height);
|
||||
[_scaleView addSubview:_1Label];
|
||||
|
||||
if (_hasTelephotoCamera) {
|
||||
_2Label = [[UILabel alloc] init];
|
||||
_2Label.text = @"2";
|
||||
_2Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_2Label.textColor = [UIColor whiteColor];
|
||||
[_2Label sizeToFit];
|
||||
[_scaleView addSubview:_2Label];
|
||||
|
||||
_2Label.center = CGPointMake(radius - sin(TGDegreesToRadians(-19.6)) * (radius - 38.0), radius - cos(TGDegreesToRadians(-19.6)) * (radius - 38.0));
|
||||
_2Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(19.6));
|
||||
}
|
||||
|
||||
_8Label = [[UILabel alloc] init];
|
||||
_8Label.text = @"8";
|
||||
_8Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_8Label.textColor = [UIColor whiteColor];
|
||||
[_8Label sizeToFit];
|
||||
[_scaleView addSubview:_8Label];
|
||||
|
||||
_8Label.center = CGPointMake(radius - sin(TGDegreesToRadians(-58.93)) * (radius - 38.0), radius - cos(TGDegreesToRadians(-58.93)) * (radius - 38.0));
|
||||
_8Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(58.93));
|
||||
|
||||
_gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
|
||||
[self addGestureRecognizer:_gestureRecognizer];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer {
|
||||
if (self.panGesture != nil) {
|
||||
self.panGesture(gestureRecognizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setZoomLevel:(CGFloat)zoomLevel {
|
||||
[self setZoomLevel:zoomLevel panning:false];
|
||||
}
|
||||
|
||||
- (void)setZoomLevel:(CGFloat)zoomLevel panning:(bool)panning {
|
||||
zoomLevel = MAX(0.5, zoomLevel);
|
||||
_zoomLevel = zoomLevel;
|
||||
|
||||
CGFloat angle = 0.0;
|
||||
if (zoomLevel < 1.0) {
|
||||
CGFloat delta = (zoomLevel - 0.5) / 0.5;
|
||||
angle = TGDegreesToRadians(20.8) * (1.0 - delta);
|
||||
} else if (zoomLevel < 2.0) {
|
||||
CGFloat delta = zoomLevel - 1.0;
|
||||
angle = TGDegreesToRadians(-22.0) * delta;
|
||||
} else if (zoomLevel < 10.0) {
|
||||
CGFloat delta = (zoomLevel - 2.0) / 8.0;
|
||||
angle = TGDegreesToRadians(-22.0) + TGDegreesToRadians(-68.0) * delta;
|
||||
NSArray *ultraLines = [self ultraLines];
|
||||
NSArray *lines = [self lines];
|
||||
|
||||
CGFloat finalAngle = 0.0;
|
||||
NSArray *allLines = [ultraLines arrayByAddingObjectsFromArray:lines];
|
||||
NSArray *previous = nil;
|
||||
for (NSArray *values in allLines) {
|
||||
CGFloat value = [values[0] floatValue];
|
||||
CGFloat angle = [values[1] floatValue];
|
||||
|
||||
if (previous == nil && zoomLevel <= value) {
|
||||
finalAngle = angle;
|
||||
break;
|
||||
}
|
||||
|
||||
if (previous != nil && zoomLevel <= value) {
|
||||
if (zoomLevel == value) {
|
||||
finalAngle = angle;
|
||||
break;
|
||||
} else {
|
||||
CGFloat previousValue = [previous[0] floatValue];
|
||||
CGFloat previousAngle = [previous[1] floatValue];
|
||||
|
||||
if (zoomLevel > previousValue) {
|
||||
CGFloat factor = (zoomLevel - previousValue) / (value - previousValue);
|
||||
finalAngle = previousAngle + (angle - previousAngle) * factor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
previous = values;
|
||||
}
|
||||
finalAngle = -TGDegreesToRadians(finalAngle);
|
||||
|
||||
_scaleView.transform = CGAffineTransformMakeRotation(finalAngle);
|
||||
|
||||
NSString *value = [NSString stringWithFormat:@"%.1f×", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0×" withString:@"×"];
|
||||
|
||||
NSString *previousValue = _valueLabel.text;
|
||||
_valueLabel.text = value;
|
||||
[_valueLabel sizeToFit];
|
||||
|
||||
if (panning && ![previousValue isEqualToString:value] && ([value isEqualToString:@"0,5×"] || ![value containsString:@","])) {
|
||||
[_feedbackGenerator selectionChanged];
|
||||
}
|
||||
|
||||
_backgroundView.transform = CGAffineTransformMakeRotation(angle);
|
||||
CGRect valueLabelFrame = CGRectMake(TGScreenPixelFloor((self.frame.size.width - _valueLabel.frame.size.width) / 2.0), 30.0, _valueLabel.frame.size.width, _valueLabel.frame.size.height);
|
||||
_valueLabel.bounds = CGRectMake(0, 0, valueLabelFrame.size.width, valueLabelFrame.size.height);
|
||||
_valueLabel.center = CGPointMake(valueLabelFrame.origin.x + valueLabelFrame.size.width / 2.0, valueLabelFrame.origin.y + valueLabelFrame.size.height / 2.0);
|
||||
}
|
||||
|
||||
- (void)setInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
_interfaceOrientation = interfaceOrientation;
|
||||
|
||||
CGFloat delta = 0.0f;
|
||||
switch (interfaceOrientation) {
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
delta = -90.0f;
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
delta = 90.0f;
|
||||
break;
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
delta = 180.0f;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_valueLabel.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(delta));
|
||||
_05Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(-19.6 + delta));
|
||||
_1Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(delta));
|
||||
_2Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(19.6 + delta));
|
||||
_8Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(58.93 + delta));
|
||||
}
|
||||
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
|
||||
@ -300,7 +300,7 @@ typedef enum
|
||||
}
|
||||
|
||||
CGFloat minSide = MIN(_wrapperView.frame.size.width, _wrapperView.frame.size.height);
|
||||
CGFloat diameter = MIN(404.0, minSide - 24.0f);
|
||||
CGFloat diameter = minSide == 320.0 ? 216.0 : MIN(404.0, minSide - 24.0f);
|
||||
CGFloat shadowSize = 21.0f;
|
||||
|
||||
CGFloat circleWrapperViewLength = diameter + shadowSize * 2.0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user