diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGModernConversationInputMicButton.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGModernConversationInputMicButton.h index 51de64059c..8f0c4434de 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGModernConversationInputMicButton.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGModernConversationInputMicButton.h @@ -12,6 +12,7 @@ - (void)updateLevel:(CGFloat)level; - (void)tick:(CGFloat)level; +- (void)setColor:(UIColor *)color; @end diff --git a/submodules/TelegramUI/Sources/BlobView.swift b/submodules/TelegramUI/Sources/BlobView.swift index d4af62730a..37b84db05a 100644 --- a/submodules/TelegramUI/Sources/BlobView.swift +++ b/submodules/TelegramUI/Sources/BlobView.swift @@ -13,9 +13,9 @@ final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration private let smallBlob = BlobView( pointsCount: 8, minRandomness: 0.1, - maxRandomness: 1, + maxRandomness: 0.5, minSpeed: 0.2, - maxSpeed: 1, + maxSpeed: 0.6, minScale: 0.56, maxScale: 0.56, scaleSpeed: 0 @@ -27,8 +27,8 @@ final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration minSpeed: 3, maxSpeed: 8, minScale: 0.67, - maxScale: 0.9, - scaleSpeed: 0.1 + maxScale: 0.8, + scaleSpeed: 0.2 ) private let bigBlob = BlobView( pointsCount: 8, @@ -38,7 +38,7 @@ final class VoiceBlobView: UIView, TGModernConversationInputMicButtonDecoration maxSpeed: 8, minScale: 0.67, maxScale: 1, - scaleSpeed: 0.1 + scaleSpeed: 0.2 ) override init(frame: CGRect) { diff --git a/submodules/TelegramUI/Sources/ChatTextInputAudioRecordingCancelIndicator.swift b/submodules/TelegramUI/Sources/ChatTextInputAudioRecordingCancelIndicator.swift index c6c23367d0..7e0dcdb4c1 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputAudioRecordingCancelIndicator.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputAudioRecordingCancelIndicator.swift @@ -12,6 +12,7 @@ final class ChatTextInputAudioRecordingCancelIndicator: ASDisplayNode { private let arrowNode: ASImageNode private let labelNode: TextNode private let cancelButton: HighlightableButtonNode + private let strings: PresentationStrings private(set) var isDisplayingCancel = false @@ -32,6 +33,8 @@ final class ChatTextInputAudioRecordingCancelIndicator: ASDisplayNode { self.cancelButton.setTitle(strings.Common_Cancel, with: cancelFont, with: theme.chat.inputPanel.panelControlAccentColor, for: []) self.cancelButton.alpha = 0.0 + self.strings = strings + super.init() self.addSubnode(self.arrowNode) @@ -56,6 +59,10 @@ final class ChatTextInputAudioRecordingCancelIndicator: ASDisplayNode { func updateTheme(theme: PresentationTheme) { self.arrowNode.image = PresentationResourcesChat.chatInputPanelMediaRecordingCancelArrowImage(theme) + self.cancelButton.setTitle(self.strings.Common_Cancel, with: cancelFont, with: theme.chat.inputPanel.panelControlAccentColor, for: []) + let makeLayout = TextNode.asyncLayout(self.labelNode) + let (_, labelApply) = makeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: strings.Conversation_SlideToCancel, font: Font.regular(14.0), textColor: theme.chat.inputPanel.panelControlColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: 200.0, height: 100.0), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + let _ = labelApply() } func updateIsDisplayingCancel(_ isDisplayingCancel: Bool, animated: Bool) { diff --git a/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift b/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift index 2924c7e158..4077474668 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift @@ -237,6 +237,18 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto } } + private lazy var micDecoration: (UIView & TGModernConversationInputMicButtonDecoration) = { + let blobView = VoiceBlobView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 180.0, height: 180.0))) + blobView.setColor(self.theme.chat.inputPanel.actionControlFillColor) + return blobView + }() + + private lazy var micLock: (UIView & TGModernConversationInputMicButtonLock) = { + let lockView = LockView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 40.0, height: 60.0)), theme: self.theme, strings: self.strings) + lockView.addTarget(self, action: #selector(handleStopTap), for: .touchUpInside) + return lockView + }() + init(theme: PresentationTheme, strings: PresentationStrings, presentController: @escaping (ViewController) -> Void) { self.theme = theme self.strings = strings @@ -317,6 +329,8 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto } self.pallete = legacyInputMicPalette(from: theme) + self.micDecoration.setColor(self.theme.chat.inputPanel.actionControlFillColor) + (self.micLock as? LockView)?.updateTheme(theme) } deinit { @@ -397,15 +411,11 @@ final class ChatTextInputMediaRecordingButton: TGModernConversationInputMicButto } func micButtonDecoration() -> (UIView & TGModernConversationInputMicButtonDecoration)! { - let blobView = VoiceBlobView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 180.0, height: 180.0))) - blobView.setColor(self.theme.chat.inputPanel.actionControlFillColor) - return blobView + return micDecoration } func micButtonLock() -> (UIView & TGModernConversationInputMicButtonLock)! { - let lockView = LockView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 40.0, height: 60.0)), theme: self.theme, strings: self.strings) - lockView.addTarget(self, action: #selector(handleStopTap), for: .touchUpInside) - return lockView + return micLock } @objc private func handleStopTap() { diff --git a/submodules/TelegramUI/Sources/LockView.swift b/submodules/TelegramUI/Sources/LockView.swift index 44ae5da37f..8e281bbecd 100644 --- a/submodules/TelegramUI/Sources/LockView.swift +++ b/submodules/TelegramUI/Sources/LockView.swift @@ -43,6 +43,29 @@ final class LockView: UIButton, TGModernConversationInputMicButtonLock { addSubview(lockingView) lockingView.frame = bounds + updateTheme(theme) + updateLockness(0) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func updateLockness(_ lockness: CGFloat) { + idleView.isHidden = lockness > 0 + if lockness > 0 && idleView.isAnimationPlaying { + idleView.stop() + } else if lockness == 0 && !idleView.isAnimationPlaying { + idleView.play() + } + lockingView.isHidden = !idleView.isHidden + + lockingView.animationProgress = lockness + } + + func updateTheme(_ theme: PresentationTheme) { + colorCallbacks.removeAll() + [ "Rectangle.Заливка 1": theme.chat.inputPanel.panelBackgroundColor, "Rectangle.Rectangle.Обводка 1": theme.chat.inputPanel.panelControlAccentColor, @@ -65,24 +88,6 @@ final class LockView: UIButton, TGModernConversationInputMicButtonLock { self.colorCallbacks.append(colorCallback) lockingView.setValueDelegate(colorCallback, for: LOTKeypath(string: "\(key).Color")) } - - updateLockness(0) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - func updateLockness(_ lockness: CGFloat) { - idleView.isHidden = lockness > 0 - if lockness > 0 && idleView.isAnimationPlaying { - idleView.stop() - } else if lockness == 0 && !idleView.isAnimationPlaying { - idleView.play() - } - lockingView.isHidden = !idleView.isHidden - - lockingView.animationProgress = lockness } override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { diff --git a/submodules/TelegramUI/Sources/WaveButtonNode.swift b/submodules/TelegramUI/Sources/WaveButtonNode.swift index cba1dbeb45..fb0f816246 100644 --- a/submodules/TelegramUI/Sources/WaveButtonNode.swift +++ b/submodules/TelegramUI/Sources/WaveButtonNode.swift @@ -26,7 +26,7 @@ private struct Constants { static let idleRotationDiff: CGFloat = 0.1 * idleRotationSpeed } -class CombinedWaveView: UIView, TGModernConversationInputMicButtonDecoration { +class CombinedWaveView: UIView { private let bigWaveView: WaveView private let smallWaveView: WaveView