mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix trending video stickerpack thumbnail
This commit is contained in:
parent
0624afd58b
commit
8bd663e908
@ -743,14 +743,18 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
transition.updateFrame(node: strongSelf.statusNode, frame: CGRect(origin: CGPoint(x: leftInset + revealOffset + editingOffset, y: strongSelf.titleNode.frame.maxY + titleSpacing), size: statusLayout.size))
|
transition.updateFrame(node: strongSelf.statusNode, frame: CGRect(origin: CGPoint(x: leftInset + revealOffset + editingOffset, y: strongSelf.titleNode.frame.maxY + titleSpacing), size: statusLayout.size))
|
||||||
|
|
||||||
let boundingSize = CGSize(width: 34.0, height: 34.0)
|
let boundingSize = CGSize(width: 34.0, height: 34.0)
|
||||||
if let thumbnailItem = thumbnailItem, let imageSize = imageSize {
|
let imageFrame: CGRect
|
||||||
let imageFrame = CGRect(origin: CGPoint(x: params.leftInset + revealOffset + editingOffset + 15.0 + floor((boundingSize.width - imageSize.width) / 2.0), y: floor((layout.contentSize.height - imageSize.height) / 2.0)), size: imageSize)
|
if let imageSize = imageSize {
|
||||||
|
imageFrame = CGRect(origin: CGPoint(x: params.leftInset + revealOffset + editingOffset + 15.0 + floor((boundingSize.width - imageSize.width) / 2.0), y: floor((layout.contentSize.height - imageSize.height) / 2.0)), size: imageSize)
|
||||||
|
} else {
|
||||||
|
imageFrame = CGRect()
|
||||||
|
}
|
||||||
|
if let thumbnailItem = thumbnailItem {
|
||||||
transition.updateFrame(node: strongSelf.imageNode, frame: imageFrame)
|
transition.updateFrame(node: strongSelf.imageNode, frame: imageFrame)
|
||||||
|
|
||||||
var thumbnailDimensions = PixelDimensions(width: 512, height: 512)
|
|
||||||
switch thumbnailItem {
|
switch thumbnailItem {
|
||||||
case let .still(representation):
|
case .still:
|
||||||
thumbnailDimensions = representation.dimensions
|
break
|
||||||
case let .animated(resource, _, isVideo):
|
case let .animated(resource, _, isVideo):
|
||||||
let animationNode: AnimatedStickerNode
|
let animationNode: AnimatedStickerNode
|
||||||
if let current = strongSelf.animationNode {
|
if let current = strongSelf.animationNode {
|
||||||
@ -769,12 +773,23 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
transition.updateFrame(node: animationNode, frame: imageFrame)
|
transition.updateFrame(node: animationNode, frame: imageFrame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if let placeholderNode = strongSelf.placeholderNode {
|
|
||||||
placeholderNode.frame = imageFrame
|
if let placeholderNode = strongSelf.placeholderNode {
|
||||||
|
var imageSize = PixelDimensions(width: 512, height: 512)
|
||||||
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: thumbnailDimensions.cgSize)
|
var immediateThumbnailData: Data?
|
||||||
|
if let data = item.packInfo.immediateThumbnailData {
|
||||||
|
if item.packInfo.flags.contains(.isVideo) {
|
||||||
|
imageSize = PixelDimensions(width: 100, height: 100)
|
||||||
|
}
|
||||||
|
immediateThumbnailData = data
|
||||||
|
} else if let data = item.topItem?.file.immediateThumbnailData {
|
||||||
|
immediateThumbnailData = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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: immediateThumbnailData, size: imageFrame.size, imageSize: imageSize.cgSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let updatedImageSignal = updatedImageSignal {
|
if let updatedImageSignal = updatedImageSignal {
|
||||||
|
@ -275,7 +275,6 @@ private final class FeaturedPackItemNode: ListViewItemNode {
|
|||||||
|
|
||||||
if self.currentThumbnailItem != thumbnailItem {
|
if self.currentThumbnailItem != thumbnailItem {
|
||||||
self.currentThumbnailItem = thumbnailItem
|
self.currentThumbnailItem = thumbnailItem
|
||||||
let thumbnailDimensions = PixelDimensions(width: 512, height: 512)
|
|
||||||
if let thumbnailItem = thumbnailItem {
|
if let thumbnailItem = thumbnailItem {
|
||||||
switch thumbnailItem {
|
switch thumbnailItem {
|
||||||
case let .still(representation):
|
case let .still(representation):
|
||||||
@ -298,6 +297,7 @@ private final class FeaturedPackItemNode: ListViewItemNode {
|
|||||||
animatedStickerNode = AnimatedStickerNode()
|
animatedStickerNode = AnimatedStickerNode()
|
||||||
animatedStickerNode.started = { [weak self] in
|
animatedStickerNode.started = { [weak self] in
|
||||||
self?.imageNode.isHidden = true
|
self?.imageNode.isHidden = true
|
||||||
|
self?.removePlaceholder(animated: false)
|
||||||
}
|
}
|
||||||
self.animatedStickerNode = animatedStickerNode
|
self.animatedStickerNode = animatedStickerNode
|
||||||
if let placeholderNode = self.placeholderNode {
|
if let placeholderNode = self.placeholderNode {
|
||||||
@ -313,11 +313,21 @@ private final class FeaturedPackItemNode: ListViewItemNode {
|
|||||||
self.stickerFetchedDisposable.set(fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: resourceReference).start())
|
self.stickerFetchedDisposable.set(fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: resourceReference).start())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if let placeholderNode = self.placeholderNode {
|
|
||||||
let imageSize = boundingImageSize
|
if let placeholderNode = self.placeholderNode {
|
||||||
placeholderNode.update(backgroundColor: theme.chat.inputMediaPanel.stickersBackgroundColor.withAlphaComponent(1.0), foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputMediaPanel.stickersBackgroundColor, alpha: 0.15), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), data: info.immediateThumbnailData, size: imageSize, imageSize: thumbnailDimensions.cgSize)
|
var imageSize = PixelDimensions(width: 512, height: 512)
|
||||||
|
var immediateThumbnailData: Data?
|
||||||
|
if let data = info.immediateThumbnailData {
|
||||||
|
if info.flags.contains(.isVideo) {
|
||||||
|
imageSize = PixelDimensions(width: 100, height: 100)
|
||||||
|
}
|
||||||
|
immediateThumbnailData = data
|
||||||
|
} else if let data = item?.file.immediateThumbnailData {
|
||||||
|
immediateThumbnailData = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
placeholderNode.update(backgroundColor: theme.chat.inputMediaPanel.stickersBackgroundColor.withAlphaComponent(1.0), foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputMediaPanel.stickersBackgroundColor, alpha: 0.15), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), data: immediateThumbnailData, size: boundingImageSize, imageSize: imageSize.cgSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.containerNode.frame = CGRect(origin: CGPoint(), size: boundingSize)
|
self.containerNode.frame = CGRect(origin: CGPoint(), size: boundingSize)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user