mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
161cad3f0a
commit
7d3cf6031e
@ -2,6 +2,8 @@
|
||||
|
||||
@interface TGCameraTimeCodeView : UIView
|
||||
|
||||
@property (nonatomic, assign) UIInterfaceOrientation interfaceOrientation;
|
||||
|
||||
@property (nonatomic, copy) NSTimeInterval(^requestedRecordingDuration)(void);
|
||||
|
||||
- (void)startRecording;
|
||||
|
@ -36,6 +36,8 @@
|
||||
|
||||
@interface TGCameraZoomWheelView : UIView
|
||||
|
||||
@property (nonatomic, assign) UIInterfaceOrientation interfaceOrientation;
|
||||
|
||||
@property (copy, nonatomic) void(^panGesture)(UIPanGestureRecognizer *gestureRecognizer);
|
||||
|
||||
@property (nonatomic, assign) CGFloat zoomLevel;
|
||||
|
@ -229,7 +229,9 @@
|
||||
strongSelf.zoomChanged(zoomLevel, animated);
|
||||
};
|
||||
[_zoomModeView setZoomLevel:1.0];
|
||||
[self addSubview:_zoomModeView];
|
||||
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];
|
||||
@ -240,7 +242,17 @@
|
||||
return;
|
||||
[strongSelf->_zoomModeView panGesture:gestureRecognizer];
|
||||
};
|
||||
[self addSubview:_zoomWheelView];
|
||||
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];
|
||||
@ -298,9 +310,7 @@
|
||||
|
||||
_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)];
|
||||
@ -566,6 +576,8 @@
|
||||
{
|
||||
bool hasDoneButton = _hasResults;
|
||||
|
||||
_zoomWheelView.clipsToBounds = !hidden;
|
||||
|
||||
if (animated)
|
||||
{
|
||||
if (!hidden)
|
||||
@ -577,6 +589,11 @@
|
||||
_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;
|
||||
@ -619,6 +636,9 @@
|
||||
_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;
|
||||
@ -647,13 +667,13 @@
|
||||
{
|
||||
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;
|
||||
} completion:^(__unused BOOL finished)
|
||||
{
|
||||
if (_modeControl.cameraMode == PGCameraModeVideo)
|
||||
@ -674,8 +694,6 @@
|
||||
{
|
||||
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||
_videoLandscapePanelView.alpha = 1.0f;
|
||||
else
|
||||
_topPanelView.alpha = 1.0f;
|
||||
}
|
||||
} completion:nil];
|
||||
}];
|
||||
@ -699,7 +717,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);
|
||||
@ -708,7 +725,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);
|
||||
@ -718,20 +734,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;
|
||||
}
|
||||
@ -749,7 +763,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)
|
||||
|
@ -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);
|
||||
|
||||
@ -363,10 +367,10 @@
|
||||
{
|
||||
_zoomLevel = zoomLevel;
|
||||
if (zoomLevel < 1.0) {
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
NSString *value = [NSString stringWithFormat:@"%.1f×", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
if ([value isEqual:@"1,0x"] || [value isEqual:@"1x"]) {
|
||||
value = @"0,9x";
|
||||
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];
|
||||
@ -374,13 +378,13 @@
|
||||
} else if (zoomLevel < 2.0) {
|
||||
[_leftItem setValue:@"0,5" selected:false animated:animated];
|
||||
if ((zoomLevel - 1.0) < 0.025) {
|
||||
[_centerItem setValue:@"1x" selected:true animated:animated];
|
||||
[_centerItem setValue:@"1×" selected:true animated:animated];
|
||||
} else {
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
NSString *value = [NSString stringWithFormat:@"%.1f×", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0x" withString:@"x"];
|
||||
if ([value isEqual:@"2x"]) {
|
||||
value = @"1,9x";
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0×" withString:@"×"];
|
||||
if ([value isEqual:@"2×"]) {
|
||||
value = @"1,9×";
|
||||
}
|
||||
[_centerItem setValue:value selected:true animated:animated];
|
||||
}
|
||||
@ -388,8 +392,8 @@
|
||||
} else {
|
||||
[_leftItem setValue:@"0,5" selected:false animated:animated];
|
||||
|
||||
NSString *value = [[NSString stringWithFormat:@"%.1fx", zoomLevel] stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0x" withString:@"x"];
|
||||
NSString *value = [[NSString stringWithFormat:@"%.1f×", zoomLevel] stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0×" withString:@"×"];
|
||||
|
||||
if (_rightItem.superview != nil) {
|
||||
[_centerItem setValue:@"1" selected:false animated:animated];
|
||||
@ -607,9 +611,7 @@
|
||||
|
||||
_hasUltrawideCamera = hasUltrawideCamera;
|
||||
_hasTelephotoCamera = hasTelephotoCamera;
|
||||
|
||||
self.clipsToBounds = true;
|
||||
|
||||
|
||||
CGFloat side = floor(frame.size.width * 1.1435);
|
||||
CGFloat length = 17.0;
|
||||
CGFloat smallWidth = MAX(0.5, 1.0 - TGScreenPixel);
|
||||
@ -814,21 +816,34 @@
|
||||
|
||||
_scaleView.transform = CGAffineTransformMakeRotation(finalAngle);
|
||||
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
NSString *value = [NSString stringWithFormat:@"%.1f×", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0x" withString:@"x"];
|
||||
value = [value stringByReplacingOccurrencesOfString:@",0×" withString:@"×"];
|
||||
|
||||
NSString *previousValue = _valueLabel.text;
|
||||
_valueLabel.text = value;
|
||||
[_valueLabel sizeToFit];
|
||||
|
||||
if (panning && ![previousValue isEqualToString:value] && ([value isEqualToString:@"0,5x"] || ![value containsString:@","])) {
|
||||
if (panning && ![previousValue isEqualToString:value] && ([value isEqualToString:@"0,5×"] || ![value containsString:@","])) {
|
||||
[_feedbackGenerator selectionChanged];
|
||||
}
|
||||
|
||||
_valueLabel.frame = CGRectMake(TGScreenPixelFloor((self.frame.size.width - _valueLabel.frame.size.width) / 2.0), 30.0, _valueLabel.frame.size.width, _valueLabel.frame.size.height);
|
||||
}
|
||||
|
||||
- (void)setInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
_interfaceOrientation = interfaceOrientation;
|
||||
|
||||
switch (interfaceOrientation) {
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
break;
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
{
|
||||
self.alpha = hidden ? 0.0f : 1.0f;
|
||||
|
@ -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