Apply patch

This commit is contained in:
Ali 2020-06-16 21:42:07 +04:00
parent c79bbad083
commit a00cfa349d
6 changed files with 53 additions and 30 deletions

View File

@ -12,6 +12,7 @@
- (void)updateLevel:(CGFloat)level;
- (void)tick:(CGFloat)level;
- (void)setColor:(UIColor *)color;
@end

View File

@ -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) {

View File

@ -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) {

View File

@ -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() {

View File

@ -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? {

View File

@ -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