mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix shimmering sticker thumbnails
This commit is contained in:
parent
ea73e0b9af
commit
b00f0076f9
@ -671,7 +671,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
if let placeholderNode = strongSelf.placeholderNode {
|
if let placeholderNode = strongSelf.placeholderNode {
|
||||||
placeholderNode.frame = imageFrame
|
placeholderNode.frame = imageFrame
|
||||||
|
|
||||||
placeholderNode.update(backgroundColor: nil, foregroundColor: item.presentationData.theme.list.disclosureArrowColor.blitOver(item.presentationData.theme.list.itemBlocksBackgroundColor, alpha: 0.55), shimmeringColor: item.presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), data: item.packInfo.immediateThumbnailData, size: imageFrame.size, small: true)
|
placeholderNode.update(backgroundColor: nil, foregroundColor: item.presentationData.theme.list.disclosureArrowColor.blitOver(item.presentationData.theme.list.itemBlocksBackgroundColor, alpha: 0.55), shimmeringColor: item.presentationData.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), data: item.packInfo.immediateThumbnailData, size: imageFrame.size, imageSize: CGSize(width: 100.0, height: 100.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ public class StickerShimmerEffectNode: ASDisplayNode {
|
|||||||
self.effectNode.updateAbsoluteRect(rect, within: containerSize)
|
self.effectNode.updateAbsoluteRect(rect, within: containerSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func update(backgroundColor: UIColor?, foregroundColor: UIColor, shimmeringColor: UIColor, data: Data?, size: CGSize, small: Bool = false) {
|
public func update(backgroundColor: UIColor?, foregroundColor: UIColor, shimmeringColor: UIColor, data: Data?, size: CGSize, imageSize: CGSize = CGSize(width: 512.0, height: 512.0)) {
|
||||||
if data == nil {
|
if data == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -199,13 +199,13 @@ public class StickerShimmerEffectNode: ASDisplayNode {
|
|||||||
|
|
||||||
if let data = data {
|
if let data = data {
|
||||||
var path = decodeStickerThumbnailData(data)
|
var path = decodeStickerThumbnailData(data)
|
||||||
if !path.hasPrefix("z") {
|
if !path.hasSuffix("z") {
|
||||||
path = "\(path)z"
|
path = "\(path)z"
|
||||||
}
|
}
|
||||||
let reader = PathDataReader(input: path)
|
let reader = PathDataReader(input: path)
|
||||||
let segments = reader.read()
|
let segments = reader.read()
|
||||||
|
|
||||||
let scale = size.width / (small ? 100.0 : 512.0)
|
let scale = max(size.width, size.height) / max(imageSize.width, imageSize.height)
|
||||||
context.scaleBy(x: scale, y: scale)
|
context.scaleBy(x: scale, y: scale)
|
||||||
renderPath(segments, context: context)
|
renderPath(segments, context: context)
|
||||||
} else {
|
} else {
|
||||||
|
@ -115,7 +115,6 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode {
|
|||||||
self.highlightNode.frame = CGRect(origin: CGPoint(x: floor((boundingSize.width - highlightSize.width) / 2.0) + verticalOffset - UIScreenPixel, y: floor((boundingSize.height - highlightSize.height) / 2.0) - UIScreenPixel), size: highlightSize)
|
self.highlightNode.frame = CGRect(origin: CGPoint(x: floor((boundingSize.width - highlightSize.width) / 2.0) + verticalOffset - UIScreenPixel, y: floor((boundingSize.height - highlightSize.height) / 2.0) - UIScreenPixel), size: highlightSize)
|
||||||
|
|
||||||
self.imageNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
|
self.imageNode.transform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
|
||||||
self.imageNode.contentAnimations = [.firstUpdate]
|
|
||||||
|
|
||||||
super.init(layerBacked: false, dynamicBounce: false)
|
super.init(layerBacked: false, dynamicBounce: false)
|
||||||
|
|
||||||
@ -236,7 +235,7 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode {
|
|||||||
let placeholderFrame = CGRect(origin: CGPoint(x: floor((boundingSize.width - imageSize.width) / 2.0) + verticalOffset, y: floor((boundingSize.height - imageSize.height) / 2.0)), size: imageSize)
|
let placeholderFrame = CGRect(origin: CGPoint(x: floor((boundingSize.width - imageSize.width) / 2.0) + verticalOffset, y: floor((boundingSize.height - imageSize.height) / 2.0)), size: imageSize)
|
||||||
placeholderNode.frame = placeholderFrame
|
placeholderNode.frame = placeholderFrame
|
||||||
|
|
||||||
placeholderNode.update(backgroundColor: nil, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputPanel.panelBackgroundColor, alpha: 0.4), shimmeringColor: theme.chat.inputMediaPanel.panelHighlightedIconBackgroundColor.withMultipliedAlpha(0.2), data: info.immediateThumbnailData, size: imageSize, small: true)
|
placeholderNode.update(backgroundColor: nil, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputPanel.panelBackgroundColor, alpha: 0.4), shimmeringColor: theme.chat.inputMediaPanel.panelHighlightedIconBackgroundColor.withMultipliedAlpha(0.2), data: info.immediateThumbnailData, size: imageSize, imageSize: CGSize(width: 100.0, height: 100.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
self.updateIsHighlighted()
|
self.updateIsHighlighted()
|
||||||
|
@ -243,6 +243,9 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
if image != nil {
|
if image != nil {
|
||||||
strongSelf.removePlaceholder(animated: !firstTime)
|
strongSelf.removePlaceholder(animated: !firstTime)
|
||||||
|
if firstTime {
|
||||||
|
strongSelf.animationNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
firstTime = false
|
firstTime = false
|
||||||
}
|
}
|
||||||
@ -963,10 +966,10 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
file = telegramFile
|
file = telegramFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if let immediateThumbnailData = file?.immediateThumbnailData, let placeholderNode = strongSelf.placeholderNode {
|
if let file = file, let immediateThumbnailData = file.immediateThumbnailData, let placeholderNode = strongSelf.placeholderNode {
|
||||||
let foregroundColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderColor, wallpaper: item.presentationData.theme.wallpaper)
|
let foregroundColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderColor, wallpaper: item.presentationData.theme.wallpaper)
|
||||||
let shimmeringColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderShimmerColor, wallpaper: item.presentationData.theme.wallpaper)
|
let shimmeringColor = bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.stickerPlaceholderShimmerColor, wallpaper: item.presentationData.theme.wallpaper)
|
||||||
placeholderNode.update(backgroundColor: nil, foregroundColor: foregroundColor, shimmeringColor: shimmeringColor, data: immediateThumbnailData, size: animationNodeFrame.size)
|
placeholderNode.update(backgroundColor: nil, foregroundColor: foregroundColor, shimmeringColor: shimmeringColor, data: immediateThumbnailData, size: animationNodeFrame.size, imageSize: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0))
|
||||||
placeholderNode.frame = animationNodeFrame
|
placeholderNode.frame = animationNodeFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,9 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
if image != nil {
|
if image != nil {
|
||||||
strongSelf.removePlaceholder(animated: !firstTime)
|
strongSelf.removePlaceholder(animated: !firstTime)
|
||||||
|
if firstTime {
|
||||||
|
strongSelf.imageNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
firstTime = false
|
firstTime = false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user