mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-07 05:25:12 +00:00
Various improvements
This commit is contained in:
@@ -9,12 +9,15 @@ import ChatPresentationInterfaceState
|
||||
import ComponentFlow
|
||||
import AccountContext
|
||||
import AnimatedCountLabelNode
|
||||
import GlassBackgroundComponent
|
||||
|
||||
final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessageActionSheetControllerSourceSendButtonNode {
|
||||
private let strings: PresentationStrings
|
||||
private let glass: Bool
|
||||
|
||||
let sendContainerNode: ASDisplayNode
|
||||
let backgroundNode: ASDisplayNode
|
||||
let backgroundView: GlassBackgroundView?
|
||||
let backgroundNode: ASDisplayNode?
|
||||
let sendButton: HighlightTrackingButtonNode
|
||||
var sendButtonHasApplyIcon = false
|
||||
var animatingSendButton = false
|
||||
@@ -35,16 +38,24 @@ final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessage
|
||||
|
||||
private var validLayout: CGSize?
|
||||
|
||||
init(presentationInterfaceState: ChatPresentationInterfaceState, presentController: @escaping (ViewController) -> Void) {
|
||||
init(presentationInterfaceState: ChatPresentationInterfaceState, glass: Bool, presentController: @escaping (ViewController) -> Void) {
|
||||
self.theme = presentationInterfaceState.theme
|
||||
self.strings = presentationInterfaceState.strings
|
||||
self.glass = glass
|
||||
|
||||
self.sendContainerNode = ASDisplayNode()
|
||||
self.sendContainerNode.layer.allowsGroupOpacity = true
|
||||
|
||||
self.backgroundNode = ASDisplayNode()
|
||||
self.backgroundNode.backgroundColor = theme.chat.inputPanel.actionControlFillColor
|
||||
self.backgroundNode.clipsToBounds = true
|
||||
if glass {
|
||||
self.backgroundView = GlassBackgroundView()
|
||||
self.backgroundNode = nil
|
||||
} else {
|
||||
self.backgroundNode = ASDisplayNode()
|
||||
self.backgroundNode?.backgroundColor = theme.chat.inputPanel.actionControlFillColor
|
||||
self.backgroundNode?.clipsToBounds = true
|
||||
self.backgroundView = nil
|
||||
}
|
||||
|
||||
self.sendButton = HighlightTrackingButtonNode(pointerStyle: nil)
|
||||
|
||||
self.textNode = ImmediateAnimatedCountLabelNode()
|
||||
@@ -78,7 +89,11 @@ final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessage
|
||||
}
|
||||
|
||||
self.addSubnode(self.sendContainerNode)
|
||||
self.sendContainerNode.addSubnode(self.backgroundNode)
|
||||
if let backgroundView = self.backgroundView {
|
||||
self.sendContainerNode.view.addSubview(backgroundView)
|
||||
} else if let backgroundNode = self.backgroundNode {
|
||||
self.sendContainerNode.addSubnode(backgroundNode)
|
||||
}
|
||||
self.sendContainerNode.addSubnode(self.sendButton)
|
||||
self.sendContainerNode.addSubnode(self.textNode)
|
||||
}
|
||||
@@ -99,11 +114,13 @@ final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessage
|
||||
}
|
||||
}
|
||||
|
||||
self.sendButtonPointerInteraction = PointerInteraction(view: self.sendButton.view, customInteractionView: self.backgroundNode.view, style: .lift)
|
||||
if let backgroundNode = self.backgroundNode {
|
||||
self.sendButtonPointerInteraction = PointerInteraction(view: self.sendButton.view, customInteractionView: backgroundNode.view, style: .lift)
|
||||
}
|
||||
}
|
||||
|
||||
func updateTheme(theme: PresentationTheme, wallpaper: TelegramWallpaper) {
|
||||
self.backgroundNode.backgroundColor = theme.chat.inputPanel.actionControlFillColor
|
||||
self.backgroundNode?.backgroundColor = theme.chat.inputPanel.actionControlFillColor
|
||||
}
|
||||
|
||||
private var absoluteRect: (CGRect, CGSize)?
|
||||
@@ -141,7 +158,7 @@ final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessage
|
||||
|
||||
let textSize = self.textNode.updateLayout(size: CGSize(width: 100.0, height: 100.0), animated: transition.isAnimated)
|
||||
if minimized {
|
||||
width = 44.0
|
||||
width = 53.0
|
||||
} else {
|
||||
width = textSize.width + buttonInset * 2.0
|
||||
}
|
||||
@@ -155,9 +172,16 @@ final class AttachmentTextInputActionButtonsNode: ASDisplayNode, ChatSendMessage
|
||||
transition.updateFrame(layer: self.sendButton.layer, frame: CGRect(origin: CGPoint(), size: buttonSize))
|
||||
transition.updateFrame(node: self.sendContainerNode, frame: CGRect(origin: CGPoint(), size: buttonSize))
|
||||
|
||||
let backgroundSize = CGSize(width: width - 11.0, height: 33.0)
|
||||
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((width - backgroundSize.width) / 2.0), y: floorToScreenPixels((size.height - backgroundSize.height) / 2.0)), size: backgroundSize))
|
||||
self.backgroundNode.cornerRadius = backgroundSize.height / 2.0
|
||||
if let backgroundView = self.backgroundView {
|
||||
let backgroundSize = CGSize(width: width - 13.0, height: 40.0)
|
||||
let backgroundFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((width - backgroundSize.width) / 2.0), y: floorToScreenPixels((size.height - backgroundSize.height) / 2.0)), size: backgroundSize)
|
||||
transition.updateFrame(view: backgroundView, frame: backgroundFrame)
|
||||
backgroundView.update(size: backgroundSize, cornerRadius: backgroundSize.height * 0.5, isDark: false, tintColor: .init(kind: .custom, color: self.theme.chat.inputPanel.actionControlFillColor), transition: ComponentTransition(transition))
|
||||
} else if let backgroundNode {
|
||||
let backgroundSize = CGSize(width: width - 11.0, height: 33.0)
|
||||
transition.updateFrame(node: backgroundNode, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((width - backgroundSize.width) / 2.0), y: floorToScreenPixels((size.height - backgroundSize.height) / 2.0)), size: backgroundSize))
|
||||
backgroundNode.cornerRadius = backgroundSize.height / 2.0
|
||||
}
|
||||
|
||||
return buttonSize
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user