mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Group boosts
This commit is contained in:
parent
971b4d6986
commit
f4893a6792
@ -124,7 +124,7 @@ public final class ItemListStickerPackItem: ListViewItem, ItemListItem {
|
|||||||
|
|
||||||
public enum StickerPackThumbnailItem: Equatable {
|
public enum StickerPackThumbnailItem: Equatable {
|
||||||
case still(TelegramMediaImageRepresentation)
|
case still(TelegramMediaImageRepresentation)
|
||||||
case animated(MediaResource, PixelDimensions, Bool)
|
case animated(MediaResource, PixelDimensions, Bool, Bool)
|
||||||
|
|
||||||
public static func ==(lhs: StickerPackThumbnailItem, rhs: StickerPackThumbnailItem) -> Bool {
|
public static func ==(lhs: StickerPackThumbnailItem, rhs: StickerPackThumbnailItem) -> Bool {
|
||||||
switch lhs {
|
switch lhs {
|
||||||
@ -134,8 +134,8 @@ public enum StickerPackThumbnailItem: Equatable {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .animated(lhsResource, lhsDimensions, lhsIsVideo):
|
case let .animated(lhsResource, lhsDimensions, lhsIsVideo, lhsTinted):
|
||||||
if case let .animated(rhsResource, rhsDimensions, rhsIsVideo) = rhs, lhsResource.isEqual(to: rhsResource), lhsDimensions == rhsDimensions, lhsIsVideo == rhsIsVideo {
|
if case let .animated(rhsResource, rhsDimensions, rhsIsVideo, rhsTinted) = rhs, lhsResource.isEqual(to: rhsResource), lhsDimensions == rhsDimensions, lhsIsVideo == rhsIsVideo, lhsTinted == rhsTinted {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -489,14 +489,14 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
var resourceReference: MediaResourceReference?
|
var resourceReference: MediaResourceReference?
|
||||||
if let thumbnail = item.packInfo.thumbnail {
|
if let thumbnail = item.packInfo.thumbnail {
|
||||||
if item.packInfo.flags.contains(.isAnimated) || item.packInfo.flags.contains(.isVideo) {
|
if item.packInfo.flags.contains(.isAnimated) || item.packInfo.flags.contains(.isVideo) {
|
||||||
thumbnailItem = .animated(thumbnail.resource, thumbnail.dimensions, item.packInfo.flags.contains(.isVideo))
|
thumbnailItem = .animated(thumbnail.resource, thumbnail.dimensions, item.packInfo.flags.contains(.isVideo), item.packInfo.flags.contains(.isCustomTemplateEmoji))
|
||||||
} else {
|
} else {
|
||||||
thumbnailItem = .still(thumbnail)
|
thumbnailItem = .still(thumbnail)
|
||||||
}
|
}
|
||||||
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: item.packInfo.id.id, accessHash: item.packInfo.accessHash), resource: thumbnail.resource)
|
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: item.packInfo.id.id, accessHash: item.packInfo.accessHash), resource: thumbnail.resource)
|
||||||
} else if let item = item.topItem {
|
} else if let item = item.topItem {
|
||||||
if item.file.isAnimatedSticker || item.file.isVideoSticker {
|
if item.file.isAnimatedSticker || item.file.isVideoSticker {
|
||||||
thumbnailItem = .animated(item.file.resource, item.file.dimensions ?? PixelDimensions(width: 100, height: 100), item.file.isVideoSticker)
|
thumbnailItem = .animated(item.file.resource, item.file.dimensions ?? PixelDimensions(width: 100, height: 100), item.file.isVideoSticker, item.file.isCustomTemplateEmoji)
|
||||||
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, hasVideo: false, isPersonal: false))
|
thumbnailItem = .still(TelegramMediaImageRepresentation(dimensions: dimensions, resource: resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false))
|
||||||
@ -523,7 +523,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
imageApply = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: stillImageSize, boundingSize: stillImageSize, intrinsicInsets: UIEdgeInsets()))
|
imageApply = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: stillImageSize, boundingSize: stillImageSize, intrinsicInsets: UIEdgeInsets()))
|
||||||
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: item.context.account.postbox, resource: representation.resource, nilIfEmpty: true)
|
updatedImageSignal = chatMessageStickerPackThumbnail(postbox: item.context.account.postbox, resource: representation.resource, nilIfEmpty: true)
|
||||||
}
|
}
|
||||||
case let .animated(resource, dimensions, _):
|
case let .animated(resource, dimensions, _, _):
|
||||||
imageSize = dimensions.cgSize.aspectFitted(imageBoundingSize)
|
imageSize = dimensions.cgSize.aspectFitted(imageBoundingSize)
|
||||||
|
|
||||||
if fileUpdated {
|
if fileUpdated {
|
||||||
@ -806,7 +806,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
switch thumbnailItem {
|
switch thumbnailItem {
|
||||||
case .still:
|
case .still:
|
||||||
break
|
break
|
||||||
case let .animated(resource, _, isVideo):
|
case let .animated(resource, _, isVideo, isTinted):
|
||||||
let animationNode: AnimatedStickerNode
|
let animationNode: AnimatedStickerNode
|
||||||
if let current = strongSelf.animationNode {
|
if let current = strongSelf.animationNode {
|
||||||
animationNode = current
|
animationNode = current
|
||||||
@ -824,6 +824,15 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
|
|||||||
animationNode.visibility = strongSelf.visibility != .none && item.playAnimatedStickers
|
animationNode.visibility = strongSelf.visibility != .none && item.playAnimatedStickers
|
||||||
animationNode.isHidden = !item.playAnimatedStickers
|
animationNode.isHidden = !item.playAnimatedStickers
|
||||||
strongSelf.imageNode.isHidden = item.playAnimatedStickers
|
strongSelf.imageNode.isHidden = item.playAnimatedStickers
|
||||||
|
|
||||||
|
if let animationNode = animationNode as? DefaultAnimatedStickerNodeImpl {
|
||||||
|
if isTinted {
|
||||||
|
animationNode.dynamicColor = item.presentationData.theme.list.itemPrimaryTextColor
|
||||||
|
} else {
|
||||||
|
animationNode.dynamicColor = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let animationNode = strongSelf.animationNode {
|
if let animationNode = strongSelf.animationNode {
|
||||||
animationNode.updateLayout(size: imageFrame.size)
|
animationNode.updateLayout(size: imageFrame.size)
|
||||||
transition.updateFrame(node: animationNode, frame: imageFrame)
|
transition.updateFrame(node: animationNode, frame: imageFrame)
|
||||||
|
|||||||
@ -564,8 +564,8 @@ private final class SheetContent: CombinedComponent {
|
|||||||
level = Int(boostState.level)
|
level = Int(boostState.level)
|
||||||
boosts = Int(boostState.boosts)
|
boosts = Int(boostState.boosts)
|
||||||
if let nextLevelBoosts = boostState.nextLevelBoosts {
|
if let nextLevelBoosts = boostState.nextLevelBoosts {
|
||||||
remaining = Int(nextLevelBoosts - boostState.boosts)
|
remaining = max(0, Int(nextLevelBoosts - boostState.boosts))
|
||||||
progress = CGFloat(boostState.boosts - boostState.currentLevelBoosts) / CGFloat(nextLevelBoosts - boostState.currentLevelBoosts)
|
progress = max(0.0, min(1.0, CGFloat(boostState.boosts - boostState.currentLevelBoosts) / CGFloat(nextLevelBoosts - boostState.currentLevelBoosts)))
|
||||||
} else {
|
} else {
|
||||||
remaining = nil
|
remaining = nil
|
||||||
progress = 1.0
|
progress = 1.0
|
||||||
@ -575,8 +575,8 @@ private final class SheetContent: CombinedComponent {
|
|||||||
level = status.level
|
level = status.level
|
||||||
boosts = status.boosts
|
boosts = status.boosts
|
||||||
if let nextLevelBoosts = status.nextLevelBoosts {
|
if let nextLevelBoosts = status.nextLevelBoosts {
|
||||||
remaining = nextLevelBoosts - status.boosts
|
remaining = max(0, nextLevelBoosts - status.boosts)
|
||||||
progress = CGFloat(status.boosts - status.currentLevelBoosts) / CGFloat(nextLevelBoosts - status.currentLevelBoosts)
|
progress = max(0.0, min(1.0, CGFloat(status.boosts - status.currentLevelBoosts) / CGFloat(nextLevelBoosts - status.currentLevelBoosts)))
|
||||||
} else {
|
} else {
|
||||||
remaining = nil
|
remaining = nil
|
||||||
progress = 1.0
|
progress = 1.0
|
||||||
@ -589,9 +589,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
progress = 0.0
|
progress = 0.0
|
||||||
myBoostCount = 0
|
myBoostCount = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let badgeText = "\(boosts)"
|
|
||||||
|
|
||||||
var textString = ""
|
var textString = ""
|
||||||
|
|
||||||
var isCurrent = false
|
var isCurrent = false
|
||||||
@ -798,7 +796,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
activeValue: premiumValue,
|
activeValue: premiumValue,
|
||||||
activeTitleColor: .white,
|
activeTitleColor: .white,
|
||||||
badgeIconName: iconName,
|
badgeIconName: iconName,
|
||||||
badgeText: badgeText,
|
badgeText: "\(boosts)",
|
||||||
badgePosition: progress,
|
badgePosition: progress,
|
||||||
badgeGraphPosition: progress,
|
badgeGraphPosition: progress,
|
||||||
invertProgress: true,
|
invertProgress: true,
|
||||||
|
|||||||
@ -43,6 +43,7 @@ public struct StickerPackCollectionInfoFlags: OptionSet {
|
|||||||
public static let isVideo = StickerPackCollectionInfoFlags(rawValue: 1 << 3)
|
public static let isVideo = StickerPackCollectionInfoFlags(rawValue: 1 << 3)
|
||||||
public static let isEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 4)
|
public static let isEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 4)
|
||||||
public static let isAvailableAsChannelStatus = StickerPackCollectionInfoFlags(rawValue: 1 << 5)
|
public static let isAvailableAsChannelStatus = StickerPackCollectionInfoFlags(rawValue: 1 << 5)
|
||||||
|
public static let isCustomTemplateEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,9 @@ extension StickerPackCollectionInfo {
|
|||||||
if (flags & (1 << 7)) != 0 {
|
if (flags & (1 << 7)) != 0 {
|
||||||
setFlags.insert(.isEmoji)
|
setFlags.insert(.isEmoji)
|
||||||
}
|
}
|
||||||
|
if (flags & (1 << 9)) != 0 {
|
||||||
|
setFlags.insert(.isCustomTemplateEmoji)
|
||||||
|
}
|
||||||
if (flags & (1 << 10)) != 0 {
|
if (flags & (1 << 10)) != 0 {
|
||||||
setFlags.insert(.isAvailableAsChannelStatus)
|
setFlags.insert(.isAvailableAsChannelStatus)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"app": "10.7.1",
|
"app": "10.7.2",
|
||||||
"bazel": "7.0.2",
|
"bazel": "7.0.2",
|
||||||
"xcode": "15.2",
|
"xcode": "15.2",
|
||||||
"macos": "13.0"
|
"macos": "13.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user