Group boosts

This commit is contained in:
Ilya Laktyushin 2024-02-09 16:20:06 +04:00
parent 971b4d6986
commit f4893a6792
5 changed files with 27 additions and 16 deletions

View File

@ -124,7 +124,7 @@ public final class ItemListStickerPackItem: ListViewItem, ItemListItem {
public enum StickerPackThumbnailItem: Equatable {
case still(TelegramMediaImageRepresentation)
case animated(MediaResource, PixelDimensions, Bool)
case animated(MediaResource, PixelDimensions, Bool, Bool)
public static func ==(lhs: StickerPackThumbnailItem, rhs: StickerPackThumbnailItem) -> Bool {
switch lhs {
@ -134,8 +134,8 @@ public enum StickerPackThumbnailItem: Equatable {
} else {
return false
}
case let .animated(lhsResource, lhsDimensions, lhsIsVideo):
if case let .animated(rhsResource, rhsDimensions, rhsIsVideo) = rhs, lhsResource.isEqual(to: rhsResource), lhsDimensions == rhsDimensions, lhsIsVideo == rhsIsVideo {
case let .animated(lhsResource, lhsDimensions, lhsIsVideo, lhsTinted):
if case let .animated(rhsResource, rhsDimensions, rhsIsVideo, rhsTinted) = rhs, lhsResource.isEqual(to: rhsResource), lhsDimensions == rhsDimensions, lhsIsVideo == rhsIsVideo, lhsTinted == rhsTinted {
return true
} else {
return false
@ -489,14 +489,14 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
var resourceReference: MediaResourceReference?
if let thumbnail = item.packInfo.thumbnail {
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 {
thumbnailItem = .still(thumbnail)
}
resourceReference = MediaResourceReference.stickerPackThumbnail(stickerPack: .id(id: item.packInfo.id.id, accessHash: item.packInfo.accessHash), resource: thumbnail.resource)
} else if let item = item.topItem {
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)
} 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))
@ -523,7 +523,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
imageApply = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: stillImageSize, boundingSize: stillImageSize, intrinsicInsets: UIEdgeInsets()))
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)
if fileUpdated {
@ -806,7 +806,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
switch thumbnailItem {
case .still:
break
case let .animated(resource, _, isVideo):
case let .animated(resource, _, isVideo, isTinted):
let animationNode: AnimatedStickerNode
if let current = strongSelf.animationNode {
animationNode = current
@ -824,6 +824,15 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
animationNode.visibility = strongSelf.visibility != .none && item.playAnimatedStickers
animationNode.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 {
animationNode.updateLayout(size: imageFrame.size)
transition.updateFrame(node: animationNode, frame: imageFrame)

View File

@ -564,8 +564,8 @@ private final class SheetContent: CombinedComponent {
level = Int(boostState.level)
boosts = Int(boostState.boosts)
if let nextLevelBoosts = boostState.nextLevelBoosts {
remaining = Int(nextLevelBoosts - boostState.boosts)
progress = CGFloat(boostState.boosts - boostState.currentLevelBoosts) / CGFloat(nextLevelBoosts - boostState.currentLevelBoosts)
remaining = max(0, Int(nextLevelBoosts - boostState.boosts))
progress = max(0.0, min(1.0, CGFloat(boostState.boosts - boostState.currentLevelBoosts) / CGFloat(nextLevelBoosts - boostState.currentLevelBoosts)))
} else {
remaining = nil
progress = 1.0
@ -575,8 +575,8 @@ private final class SheetContent: CombinedComponent {
level = status.level
boosts = status.boosts
if let nextLevelBoosts = status.nextLevelBoosts {
remaining = nextLevelBoosts - status.boosts
progress = CGFloat(status.boosts - status.currentLevelBoosts) / CGFloat(nextLevelBoosts - status.currentLevelBoosts)
remaining = max(0, nextLevelBoosts - status.boosts)
progress = max(0.0, min(1.0, CGFloat(status.boosts - status.currentLevelBoosts) / CGFloat(nextLevelBoosts - status.currentLevelBoosts)))
} else {
remaining = nil
progress = 1.0
@ -589,9 +589,7 @@ private final class SheetContent: CombinedComponent {
progress = 0.0
myBoostCount = 0
}
let badgeText = "\(boosts)"
var textString = ""
var isCurrent = false
@ -798,7 +796,7 @@ private final class SheetContent: CombinedComponent {
activeValue: premiumValue,
activeTitleColor: .white,
badgeIconName: iconName,
badgeText: badgeText,
badgeText: "\(boosts)",
badgePosition: progress,
badgeGraphPosition: progress,
invertProgress: true,

View File

@ -43,6 +43,7 @@ public struct StickerPackCollectionInfoFlags: OptionSet {
public static let isVideo = StickerPackCollectionInfoFlags(rawValue: 1 << 3)
public static let isEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 4)
public static let isAvailableAsChannelStatus = StickerPackCollectionInfoFlags(rawValue: 1 << 5)
public static let isCustomTemplateEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 6)
}

View File

@ -49,6 +49,9 @@ extension StickerPackCollectionInfo {
if (flags & (1 << 7)) != 0 {
setFlags.insert(.isEmoji)
}
if (flags & (1 << 9)) != 0 {
setFlags.insert(.isCustomTemplateEmoji)
}
if (flags & (1 << 10)) != 0 {
setFlags.insert(.isAvailableAsChannelStatus)
}

View File

@ -1,5 +1,5 @@
{
"app": "10.7.1",
"app": "10.7.2",
"bazel": "7.0.2",
"xcode": "15.2",
"macos": "13.0"