Web app improvements

This commit is contained in:
Ilya Laktyushin 2022-04-07 12:19:21 +04:00
parent b7a9165d28
commit 517df89e9a
6 changed files with 32 additions and 24 deletions

View File

@ -221,9 +221,9 @@ private final class AttachButtonComponent: CombinedComponent {
animation: AnimatedStickerComponent.Animation( animation: AnimatedStickerComponent.Animation(
source: .file(media: animationFile), source: .file(media: animationFile),
scale: UIScreenScale, scale: UIScreenScale,
loop: false, loop: false
tintColor: tintColor
), ),
tintColor: tintColor,
isAnimating: component.isSelected, isAnimating: component.isSelected,
size: CGSize(width: iconSize.width, height: iconSize.height) size: CGSize(width: iconSize.width, height: iconSize.height)
), ),
@ -361,23 +361,26 @@ public struct AttachmentMainButtonState {
let textColor: UIColor let textColor: UIColor
let isVisible: Bool let isVisible: Bool
let isLoading: Bool let isLoading: Bool
let isEnabled: Bool
public init( public init(
text: String?, text: String?,
backgroundColor: UIColor, backgroundColor: UIColor,
textColor: UIColor, textColor: UIColor,
isVisible: Bool, isVisible: Bool,
isLoading: Bool isLoading: Bool,
isEnabled: Bool
) { ) {
self.text = text self.text = text
self.backgroundColor = backgroundColor self.backgroundColor = backgroundColor
self.textColor = textColor self.textColor = textColor
self.isVisible = isVisible self.isVisible = isVisible
self.isLoading = isLoading self.isLoading = isLoading
self.isEnabled = isEnabled
} }
static var initial: AttachmentMainButtonState { static var initial: AttachmentMainButtonState {
return AttachmentMainButtonState(text: nil, backgroundColor: .clear, textColor: .clear, isVisible: false, isLoading: false) return AttachmentMainButtonState(text: nil, backgroundColor: .clear, textColor: .clear, isVisible: false, isLoading: false, isEnabled: false)
} }
} }
@ -401,7 +404,7 @@ private final class MainButtonNode: HighlightTrackingButtonNode {
self.addSubnode(self.statusNode) self.addSubnode(self.statusNode)
self.highligthedChanged = { [weak self] highlighted in self.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self { if let strongSelf = self, strongSelf.state.isEnabled {
if highlighted { if highlighted {
strongSelf.layer.removeAnimation(forKey: "opacity") strongSelf.layer.removeAnimation(forKey: "opacity")
strongSelf.alpha = 0.65 strongSelf.alpha = 0.65
@ -899,7 +902,7 @@ final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate {
func updateMainButtonState(_ mainButtonState: AttachmentMainButtonState?) { func updateMainButtonState(_ mainButtonState: AttachmentMainButtonState?) {
var currentButtonState = self.mainButtonState var currentButtonState = self.mainButtonState
if mainButtonState == nil { if mainButtonState == nil {
currentButtonState = AttachmentMainButtonState(text: currentButtonState.text, backgroundColor: currentButtonState.backgroundColor, textColor: currentButtonState.textColor, isVisible: false, isLoading: false) currentButtonState = AttachmentMainButtonState(text: currentButtonState.text, backgroundColor: currentButtonState.backgroundColor, textColor: currentButtonState.textColor, isVisible: false, isLoading: false, isEnabled: currentButtonState.isEnabled)
} }
self.mainButtonState = mainButtonState ?? currentButtonState self.mainButtonState = mainButtonState ?? currentButtonState
} }

View File

@ -16,24 +16,24 @@ public final class AnimatedStickerComponent: Component {
public var source: Source public var source: Source
public var scale: CGFloat public var scale: CGFloat
public var loop: Bool public var loop: Bool
public var tintColor: UIColor?
public init(source: Source, scale: CGFloat = 2.0, loop: Bool, tintColor: UIColor? = nil) { public init(source: Source, scale: CGFloat = 2.0, loop: Bool) {
self.source = source self.source = source
self.scale = scale self.scale = scale
self.loop = loop self.loop = loop
self.tintColor = tintColor
} }
} }
public let account: Account public let account: Account
public let animation: Animation public let animation: Animation
public var tintColor: UIColor?
public let isAnimating: Bool public let isAnimating: Bool
public let size: CGSize public let size: CGSize
public init(account: Account, animation: Animation, isAnimating: Bool = true, size: CGSize) { public init(account: Account, animation: Animation, tintColor: UIColor? = nil, isAnimating: Bool = true, size: CGSize) {
self.account = account self.account = account
self.animation = animation self.animation = animation
self.tintColor = tintColor
self.isAnimating = isAnimating self.isAnimating = isAnimating
self.size = size self.size = size
} }
@ -45,6 +45,9 @@ public final class AnimatedStickerComponent: Component {
if lhs.animation != rhs.animation { if lhs.animation != rhs.animation {
return false return false
} }
if lhs.tintColor != rhs.tintColor {
return false
}
if lhs.isAnimating != rhs.isAnimating { if lhs.isAnimating != rhs.isAnimating {
return false return false
} }
@ -100,7 +103,6 @@ public final class AnimatedStickerComponent: Component {
case let .file(media): case let .file(media):
source = AnimatedStickerResourceSource(account: component.account, resource: media.resource, fitzModifier: nil, isVideo: false) source = AnimatedStickerResourceSource(account: component.account, resource: media.resource, fitzModifier: nil, isVideo: false)
} }
animationNode.setOverlayColor(component.animation.tintColor, replace: true, animated: false)
var playbackMode: AnimatedStickerPlaybackMode = .still(.start) var playbackMode: AnimatedStickerPlaybackMode = .still(.start)
if component.animation.loop { if component.animation.loop {
@ -115,6 +117,8 @@ public final class AnimatedStickerComponent: Component {
self.addSubnode(animationNode) self.addSubnode(animationNode)
} }
self.animationNode?.setOverlayColor(component.tintColor, replace: true, animated: false)
if !component.animation.loop && component.isAnimating != self.component?.isAnimating { if !component.animation.loop && component.isAnimating != self.component?.isAnimating {
if component.isAnimating { if component.isAnimating {
let _ = self.animationNode?.playIfNeeded() let _ = self.animationNode?.playIfNeeded()

View File

@ -714,7 +714,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
override init() { override init() {
self.backgroundNode = NavigationBackgroundNode(color: .clear, enableBlur: false) self.backgroundNode = NavigationBackgroundNode(color: .clear, enableBlur: false)
self.parentShadowNode = ASImageNode() self.parentShadowNode = ASImageNode()
self.parentShadowNode.image = UIImage(bundleImageName: "Components/Context Menu/Shadow")?.stretchableImage(withLeftCapWidth: 60, topCapHeight: 60) self.parentShadowNode.image = UIImage(bundleImageName: "Components/Context Menu/Shadow")?.stretchableImage(withLeftCapWidth: 60, topCapHeight: 48)
super.init() super.init()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -907,6 +907,17 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
} }
} }
let buttonTitle: String
if case let .webView(title, _) = interfaceState.botMenuButton {
buttonTitle = title
} else {
buttonTitle = interfaceState.strings.Conversation_InputMenu
}
self.menuButtonTextNode.attributedText = NSAttributedString(string: buttonTitle, font: Font.with(size: 16.0, design: .round, weight: .medium, traits: []), textColor: interfaceState.theme.chat.inputPanel.actionControlForegroundColor)
self.menuButton.accessibilityLabel = self.menuButtonTextNode.attributedText?.string
menuTextSize = self.menuButtonTextNode.updateLayout(CGSize(width: width, height: 44.0))
var updateSendButtonIcon = false var updateSendButtonIcon = false
if (previousState?.interfaceState.editMessage != nil) != (interfaceState.interfaceState.editMessage != nil) { if (previousState?.interfaceState.editMessage != nil) != (interfaceState.interfaceState.editMessage != nil) {
updateSendButtonIcon = true updateSendButtonIcon = true
@ -945,17 +956,6 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
self.menuButtonBackgroundNode.backgroundColor = interfaceState.theme.chat.inputPanel.actionControlFillColor self.menuButtonBackgroundNode.backgroundColor = interfaceState.theme.chat.inputPanel.actionControlFillColor
let buttonTitle: String
if case let .webView(title, _) = interfaceState.botMenuButton {
buttonTitle = title
} else {
buttonTitle = interfaceState.strings.Conversation_InputMenu
}
self.menuButtonTextNode.attributedText = NSAttributedString(string: buttonTitle, font: Font.with(size: 16.0, design: .round, weight: .medium, traits: []), textColor: interfaceState.theme.chat.inputPanel.actionControlForegroundColor)
self.menuButton.accessibilityLabel = interfaceState.strings.Conversation_InputMenu
menuTextSize = self.menuButtonTextNode.updateLayout(CGSize(width: width, height: 44.0))
if isEditingMedia { if isEditingMedia {
self.attachmentButton.setImage(PresentationResourcesChat.chatInputPanelEditAttachmentButtonImage(interfaceState.theme), for: []) self.attachmentButton.setImage(PresentationResourcesChat.chatInputPanelEditAttachmentButtonImage(interfaceState.theme), for: [])
} else { } else {

View File

@ -372,7 +372,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
let textColor = textColorString.flatMap({ UIColor(hexString: $0) }) ?? self.presentationData.theme.list.itemCheckColors.foregroundColor let textColor = textColorString.flatMap({ UIColor(hexString: $0) }) ?? self.presentationData.theme.list.itemCheckColors.foregroundColor
let isLoading = json["is_progress_visible"] as? Bool let isLoading = json["is_progress_visible"] as? Bool
let state = AttachmentMainButtonState(text: text, backgroundColor: backgroundColor, textColor: textColor, isVisible: isVisible, isLoading: isLoading ?? false) let isEnabled = json["is_active"] as? Bool
let state = AttachmentMainButtonState(text: text, backgroundColor: backgroundColor, textColor: textColor, isVisible: isVisible, isLoading: isLoading ?? false, isEnabled: isEnabled ?? true)
self.mainButtonStatePromise.set(.single(state)) self.mainButtonStatePromise.set(.single(state))
} }
} }