mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Web app improvements
This commit is contained in:
@@ -10,7 +10,12 @@ import AccountContext
|
||||
import ChatPresentationInterfaceState
|
||||
|
||||
private final class ChatButtonKeyboardInputButtonNode: ASButtonNode {
|
||||
var button: ReplyMarkupButton?
|
||||
var button: ReplyMarkupButton? {
|
||||
didSet {
|
||||
self.updateIcon()
|
||||
}
|
||||
}
|
||||
var iconNode: ASImageNode?
|
||||
|
||||
private var theme: PresentationTheme?
|
||||
|
||||
@@ -20,12 +25,52 @@ private final class ChatButtonKeyboardInputButtonNode: ASButtonNode {
|
||||
self.updateTheme(theme: theme)
|
||||
}
|
||||
|
||||
private func updateIcon() {
|
||||
guard let theme = self.theme else {
|
||||
return
|
||||
}
|
||||
var iconImage: UIImage?
|
||||
if let button = self.button {
|
||||
switch button.action {
|
||||
case .openWebView:
|
||||
iconImage = PresentationResourcesChat.chatKeyboardActionButtonWebAppIconImage(theme)
|
||||
default:
|
||||
iconImage = nil
|
||||
}
|
||||
}
|
||||
|
||||
if iconImage != nil {
|
||||
if self.iconNode == nil {
|
||||
let iconNode = ASImageNode()
|
||||
iconNode.contentMode = .center
|
||||
self.iconNode = iconNode
|
||||
self.addSubnode(iconNode)
|
||||
}
|
||||
self.iconNode?.image = iconImage
|
||||
} else if let iconNode = self.iconNode {
|
||||
iconNode.removeFromSupernode()
|
||||
self.iconNode = nil
|
||||
}
|
||||
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
|
||||
func updateTheme(theme: PresentationTheme) {
|
||||
if theme !== self.theme {
|
||||
self.theme = theme
|
||||
|
||||
self.setBackgroundImage(PresentationResourcesChat.chatInputButtonPanelButtonImage(theme), for: [])
|
||||
self.setBackgroundImage(PresentationResourcesChat.chatInputButtonPanelButtonHighlightedImage(theme), for: [.highlighted])
|
||||
|
||||
self.updateIcon()
|
||||
}
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
super.layout()
|
||||
|
||||
if let iconNode = self.iconNode {
|
||||
iconNode.frame = CGRect(x: self.frame.width - 16.0, y: 4.0, width: 12.0, height: 12.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,7 +261,7 @@ final class ChatButtonKeyboardInputNode: ChatInputNode {
|
||||
case let .openUserProfile(peerId):
|
||||
self.controllerInteraction.openPeer(peerId, .info, nil, nil)
|
||||
case let .openWebView(url, simple):
|
||||
self.controllerInteraction.openWebView(url, simple)
|
||||
self.controllerInteraction.openWebView(markupButton.title, url, simple)
|
||||
}
|
||||
if dismissIfOnce {
|
||||
if let message = self.message {
|
||||
|
||||
Reference in New Issue
Block a user