From da80ab648d7098da9ab58a8d2a80175c4961fe50 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Mon, 6 Jul 2020 13:34:39 +0400 Subject: [PATCH] Apply patch --- .../TGModernConversationInputMicButton.m | 16 ++++++++------ submodules/TelegramUI/Sources/BlobView.swift | 21 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/submodules/LegacyComponents/Sources/TGModernConversationInputMicButton.m b/submodules/LegacyComponents/Sources/TGModernConversationInputMicButton.m index 3b24ac7c61..a6b92c6eb7 100644 --- a/submodules/LegacyComponents/Sources/TGModernConversationInputMicButton.m +++ b/submodules/LegacyComponents/Sources/TGModernConversationInputMicButton.m @@ -124,7 +124,9 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius CGFloat _currentScale; CGFloat _currentTranslation; CGFloat _targetTranslation; + CGFloat _cancelTranslation; + CGFloat _cancelTargetTranslation; CFAbsoluteTime _animationStartTime; @@ -505,6 +507,8 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius _currentLevel = 0.0f; _currentTranslation = 0.0f; _targetTranslation = 0.0f; + _cancelTranslation = 0; + _cancelTargetTranslation = 0; _currentScale = 1.0f; [UIView animateWithDuration:0.18 animations:^{ _innerIconWrapperView.transform = CGAffineTransformMakeScale(0.2f, 0.2f); @@ -531,10 +535,9 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius [_presentation dismiss]; _presentation = nil; - _cancelTranslation = 0; id delegate = _delegate; if ([delegate respondsToSelector:@selector(micButtonInteractionUpdateCancelTranslation:)]) - [delegate micButtonInteractionUpdateCancelTranslation:-_cancelTranslation]; + [delegate micButtonInteractionUpdateCancelTranslation:-_cancelTargetTranslation]; } if (_previousIcon != nil) @@ -565,10 +568,10 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius [self setIcon:TGTintedImage(TGComponentsImageNamed(@"RecordSendIcon"), _pallete != nil ? _pallete.iconColor : [UIColor whiteColor])]; _currentScale = 1; - _cancelTranslation = 0; + _cancelTargetTranslation = 0; id delegate = _delegate; if ([delegate respondsToSelector:@selector(micButtonInteractionUpdateCancelTranslation:)]) - [delegate micButtonInteractionUpdateCancelTranslation:-_cancelTranslation]; + [delegate micButtonInteractionUpdateCancelTranslation:-_cancelTargetTranslation]; _innerIconView.transform = CGAffineTransformMakeScale(0.3f, 0.3f); _innerIconView.alpha = 0.0f; @@ -694,7 +697,7 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius _currentScale = scale; _targetTranslation = distanceY; - _cancelTranslation = distanceX; + _cancelTargetTranslation = distanceX; CGFloat targetLockness = _locked ? 1.0f : MIN(1.0f, fabs(_targetTranslation) / 105.0f); [_lock updateLockness:targetLockness]; _lockView.lockness = targetLockness; @@ -712,7 +715,7 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius id delegate = _delegate; if ([delegate respondsToSelector:@selector(micButtonInteractionUpdateCancelTranslation:)]) - [delegate micButtonInteractionUpdateCancelTranslation:-_cancelTranslation]; + [delegate micButtonInteractionUpdateCancelTranslation:-_cancelTargetTranslation]; if (distanceX < -150.0f) { id delegate = _delegate; @@ -841,6 +844,7 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius [_decoration tick:_currentLevel]; _currentTranslation = MIN(0.0, _currentTranslation * 0.7f + _targetTranslation * 0.3f); + _cancelTranslation = MIN(0.0, _cancelTranslation * 0.7f + _cancelTargetTranslation * 0.3f); if (t > _animationStartTime) { CGFloat outerScale = outerCircleMinScale + _currentLevel * (1.0f - outerCircleMinScale); diff --git a/submodules/TelegramUI/Sources/BlobView.swift b/submodules/TelegramUI/Sources/BlobView.swift index 96c6809f49..72bb99564b 100644 --- a/submodules/TelegramUI/Sources/BlobView.swift +++ b/submodules/TelegramUI/Sources/BlobView.swift @@ -5,7 +5,7 @@ import LegacyComponents private enum Constants { - static let maxLevel: CGFloat = 5 + static let maxLevel: CGFloat = 4 } final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration { @@ -25,10 +25,10 @@ final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration pointsCount: 8, minRandomness: 1, maxRandomness: 1, - minSpeed: 1, + minSpeed: 1.5, maxSpeed: 7, - minScale: 0.55, - maxScale: 0.9, + minScale: 0.52, + maxScale: 0.87, scaleSpeed: 0.2, isCircle: false ) @@ -36,9 +36,9 @@ final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration pointsCount: 8, minRandomness: 1, maxRandomness: 1, - minSpeed: 1, + minSpeed: 1.5, maxSpeed: 7, - minScale: 0.55, + minScale: 0.57, maxScale: 1, scaleSpeed: 0.2, isCircle: false @@ -127,6 +127,8 @@ final class BlobView: UIView { private var speedLevel: CGFloat = 0 private var scaleLevel: CGFloat = 0 + + private var lastSpeedLevel: CGFloat = 0 private var lastScaleLevel: CGFloat = 0 private let shapeLayer: CAShapeLayer = { @@ -199,6 +201,10 @@ final class BlobView: UIView { func updateSpeedLevel(to newSpeedLevel: CGFloat) { speedLevel = max(speedLevel, newSpeedLevel) + + if abs(lastSpeedLevel - newSpeedLevel) > 0.5 { + animateToNewShape() + } } func startAnimating() { @@ -238,7 +244,7 @@ final class BlobView: UIView { if pop_animation(forKey: "blob") != nil { fromPoints = currentPoints toPoints = nil - pop_removeAllAnimations() + shapeLayer.pop_removeAnimation(forKey: "blob") } if fromPoints == nil { @@ -274,6 +280,7 @@ final class BlobView: UIView { animation.toValue = 1 pop_add(animation, forKey: "blob") + lastSpeedLevel = speedLevel speedLevel = 0 }