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(
source: .file(media: animationFile),
scale: UIScreenScale,
loop: false,
tintColor: tintColor
loop: false
),
tintColor: tintColor,
isAnimating: component.isSelected,
size: CGSize(width: iconSize.width, height: iconSize.height)
),
@ -361,23 +361,26 @@ public struct AttachmentMainButtonState {
let textColor: UIColor
let isVisible: Bool
let isLoading: Bool
let isEnabled: Bool
public init(
text: String?,
backgroundColor: UIColor,
textColor: UIColor,
isVisible: Bool,
isLoading: Bool
isLoading: Bool,
isEnabled: Bool
) {
self.text = text
self.backgroundColor = backgroundColor
self.textColor = textColor
self.isVisible = isVisible
self.isLoading = isLoading
self.isEnabled = isEnabled
}
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.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self {
if let strongSelf = self, strongSelf.state.isEnabled {
if highlighted {
strongSelf.layer.removeAnimation(forKey: "opacity")
strongSelf.alpha = 0.65
@ -899,7 +902,7 @@ final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate {
func updateMainButtonState(_ mainButtonState: AttachmentMainButtonState?) {
var currentButtonState = self.mainButtonState
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
}

View File

@ -16,24 +16,24 @@ public final class AnimatedStickerComponent: Component {
public var source: Source
public var scale: CGFloat
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.scale = scale
self.loop = loop
self.tintColor = tintColor
}
}
public let account: Account
public let animation: Animation
public var tintColor: UIColor?
public let isAnimating: Bool
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.animation = animation
self.tintColor = tintColor
self.isAnimating = isAnimating
self.size = size
}
@ -45,6 +45,9 @@ public final class AnimatedStickerComponent: Component {
if lhs.animation != rhs.animation {
return false
}
if lhs.tintColor != rhs.tintColor {
return false
}
if lhs.isAnimating != rhs.isAnimating {
return false
}
@ -100,7 +103,6 @@ public final class AnimatedStickerComponent: Component {
case let .file(media):
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)
if component.animation.loop {
@ -115,6 +117,8 @@ public final class AnimatedStickerComponent: Component {
self.addSubnode(animationNode)
}
self.animationNode?.setOverlayColor(component.tintColor, replace: true, animated: false)
if !component.animation.loop && component.isAnimating != self.component?.isAnimating {
if component.isAnimating {
let _ = self.animationNode?.playIfNeeded()

View File

@ -714,7 +714,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
override init() {
self.backgroundNode = NavigationBackgroundNode(color: .clear, enableBlur: false)
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()

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
if (previousState?.interfaceState.editMessage != nil) != (interfaceState.interfaceState.editMessage != nil) {
updateSendButtonIcon = true
@ -945,17 +956,6 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
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 {
self.attachmentButton.setImage(PresentationResourcesChat.chatInputPanelEditAttachmentButtonImage(interfaceState.theme), for: [])
} 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 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))
}
}