mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix non-square animated sticker display in various places
This commit is contained in:
parent
e06783d725
commit
9b322d19c3
@ -364,7 +364,9 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode {
|
|||||||
scalingNode.addSubnode(imageNode)
|
scalingNode.addSubnode(imageNode)
|
||||||
|
|
||||||
snapshotImageNode = imageNode
|
snapshotImageNode = imageNode
|
||||||
case let .animated(resource, _, isVideo):
|
case let .animated(resource, dimensions, isVideo):
|
||||||
|
imageSize = dimensions.cgSize.aspectFitted(boundingImageSize)
|
||||||
|
|
||||||
let animatedStickerNode = AnimatedStickerNode()
|
let animatedStickerNode = AnimatedStickerNode()
|
||||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: account, resource: resource, isVideo: isVideo), width: 128, height: 128, mode: .cached)
|
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: account, resource: resource, isVideo: isVideo), width: 128, height: 128, mode: .cached)
|
||||||
animatedStickerNode.visibility = self.visibilityStatus && loopAnimatedStickers
|
animatedStickerNode.visibility = self.visibilityStatus && loopAnimatedStickers
|
||||||
|
@ -283,7 +283,8 @@ private final class FeaturedPackItemNode: ListViewItemNode {
|
|||||||
let imageApply = self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets()))
|
let imageApply = self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets()))
|
||||||
imageApply()
|
imageApply()
|
||||||
self.imageNode.setSignal(chatMessageStickerPackThumbnail(postbox: account.postbox, resource: representation.resource, nilIfEmpty: true))
|
self.imageNode.setSignal(chatMessageStickerPackThumbnail(postbox: account.postbox, resource: representation.resource, nilIfEmpty: true))
|
||||||
case let .animated(resource, _, isVideo):
|
case let .animated(resource, dimensions, isVideo):
|
||||||
|
imageSize = dimensions.cgSize.aspectFitted(boundingImageSize)
|
||||||
let imageApply = self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets()))
|
let imageApply = self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets()))
|
||||||
imageApply()
|
imageApply()
|
||||||
self.imageNode.setSignal(chatMessageStickerPackThumbnail(postbox: account.postbox, resource: resource, animated: true, nilIfEmpty: true))
|
self.imageNode.setSignal(chatMessageStickerPackThumbnail(postbox: account.postbox, resource: resource, animated: true, nilIfEmpty: true))
|
||||||
|
@ -348,7 +348,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
enum StickerPackThumbnailItem {
|
enum StickerPackThumbnailItem {
|
||||||
case still(TelegramMediaImageRepresentation)
|
case still(TelegramMediaImageRepresentation)
|
||||||
case animated(EngineMediaResource, Bool)
|
case animated(EngineMediaResource, PixelDimensions, Bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
var thumbnailItem: StickerPackThumbnailItem?
|
var thumbnailItem: StickerPackThumbnailItem?
|
||||||
@ -356,14 +356,14 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
if let thumbnail = info.thumbnail {
|
if let thumbnail = info.thumbnail {
|
||||||
if info.flags.contains(.isAnimated) || info.flags.contains(.isVideo) {
|
if info.flags.contains(.isAnimated) || info.flags.contains(.isVideo) {
|
||||||
thumbnailItem = .animated(EngineMediaResource(thumbnail.resource), info.flags.contains(.isVideo))
|
thumbnailItem = .animated(EngineMediaResource(thumbnail.resource), thumbnail.dimensions, info.flags.contains(.isVideo))
|
||||||
} else {
|
} else {
|
||||||
thumbnailItem = .still(thumbnail)
|
thumbnailItem = .still(thumbnail)
|
||||||
}
|
}
|
||||||
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: info.id.id, accessHash: info.accessHash), resource: thumbnail.resource)
|
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: info.id.id, accessHash: info.accessHash), resource: thumbnail.resource)
|
||||||
} else if let item = topItem {
|
} else if let item = topItem {
|
||||||
if item.file.isAnimatedSticker || item.file.isVideoSticker {
|
if item.file.isAnimatedSticker || item.file.isVideoSticker {
|
||||||
thumbnailItem = .animated(EngineMediaResource(item.file.resource), item.file.isVideoSticker)
|
thumbnailItem = .animated(EngineMediaResource(item.file.resource), item.file.dimensions ?? PixelDimensions(width: 512, height: 512), item.file.isVideoSticker)
|
||||||
resourceReference = MediaResourceReference.media(media: .standalone(media: item.file), resource: item.file.resource)
|
resourceReference = MediaResourceReference.media(media: .standalone(media: item.file), resource: item.file.resource)
|
||||||
} else if let dimensions = item.file.dimensions, let resource = chatMessageStickerResource(file: item.file, small: true) as? TelegramMediaResource {
|
} else if let dimensions = item.file.dimensions, let resource = chatMessageStickerResource(file: item.file, small: true) as? TelegramMediaResource {
|
||||||
thumbnailItem = .still(TelegramMediaImageRepresentation(dimensions: dimensions, resource: resource, progressiveSizes: [], immediateThumbnailData: nil))
|
thumbnailItem = .still(TelegramMediaImageRepresentation(dimensions: dimensions, resource: resource, progressiveSizes: [], immediateThumbnailData: nil))
|
||||||
@ -383,8 +383,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
self.stickerImageSize = stillImageSize
|
self.stickerImageSize = stillImageSize
|
||||||
|
|
||||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: representation.resource)
|
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: representation.resource)
|
||||||
case let .animated(resource, _):
|
case let .animated(resource, dimensions, _):
|
||||||
self.stickerImageSize = imageBoundingSize
|
self.stickerImageSize = dimensions.cgSize.aspectFitted(imageBoundingSize)
|
||||||
|
|
||||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: resource._asResource(), animated: true)
|
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: context.account.postbox, resource: resource._asResource(), animated: true)
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
switch thumbnailItem {
|
switch thumbnailItem {
|
||||||
case .still:
|
case .still:
|
||||||
break
|
break
|
||||||
case let .animated(resource, isVideo):
|
case let .animated(resource, _, isVideo):
|
||||||
let animatedStickerNode = AnimatedStickerNode()
|
let animatedStickerNode = AnimatedStickerNode()
|
||||||
self.animatedStickerNode = animatedStickerNode
|
self.animatedStickerNode = animatedStickerNode
|
||||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: resource._asResource(), isVideo: isVideo), width: 80, height: 80, mode: .direct(cachePathPrefix: nil))
|
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: resource._asResource(), isVideo: isVideo), width: 80, height: 80, mode: .direct(cachePathPrefix: nil))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user