mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add fallback for the emoji template pack
This commit is contained in:
parent
c66c0facab
commit
a526ba7843
@ -31,12 +31,8 @@ public func reactionStaticImage(context: AccountContext, animation: TelegramMedi
|
||||
}
|
||||
|
||||
var customColor: UIColor?
|
||||
for attribute in animation.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
customColor = nil
|
||||
}
|
||||
}
|
||||
if animation.isCustomTemplateEmoji {
|
||||
customColor = nil
|
||||
}
|
||||
|
||||
let fetchFrame = animationCacheFetchFile(context: context, userLocation: .other, userContentType: .sticker, resource: MediaResourceReference.standalone(resource: animation.resource), type: type, keyframeOnly: true, customColor: customColor)
|
||||
|
@ -651,6 +651,26 @@ public final class TelegramMediaFile: Media, Equatable, Codable {
|
||||
return hasSticker
|
||||
}
|
||||
|
||||
public var isCustomTemplateEmoji: Bool {
|
||||
for attribute in self.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute, let packReference = packReference {
|
||||
if isSingleColor {
|
||||
return true
|
||||
}
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 1269403972611866647 {
|
||||
return true
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public var isPremiumEmoji: Bool {
|
||||
for attribute in self.attributes {
|
||||
if case let .CustomEmoji(isPremium, _, _, _) = attribute {
|
||||
|
@ -442,11 +442,11 @@ public final class EmojiStatusComponent: Component {
|
||||
|
||||
var accentTint = false
|
||||
if let _ = emojiThemeColor {
|
||||
if emojiFile.isCustomTemplateEmoji {
|
||||
accentTint = true
|
||||
}
|
||||
for attribute in emojiFile.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute {
|
||||
if isSingleColor {
|
||||
accentTint = true
|
||||
}
|
||||
if case let .CustomEmoji(_, _, _, packReference) = attribute {
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 773947703670341676 || id == 2964141614563343 {
|
||||
|
@ -651,11 +651,11 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
effectView = view
|
||||
} else if let itemFile = item.itemFile {
|
||||
var useCleanEffect = false
|
||||
if itemFile.isCustomTemplateEmoji {
|
||||
useCleanEffect = true
|
||||
}
|
||||
for attribute in itemFile.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute {
|
||||
if isSingleColor {
|
||||
useCleanEffect = true
|
||||
}
|
||||
if case let .CustomEmoji(_, _, _, packReference) = attribute {
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 773947703670341676 || id == 2964141614563343 {
|
||||
|
@ -253,12 +253,8 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
|
||||
if !self.isDisplayingPlaceholder {
|
||||
var customColor = self.contentTintColor
|
||||
if let file = self.file {
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
customColor = self.dynamicColor
|
||||
}
|
||||
}
|
||||
if file.isCustomTemplateEmoji {
|
||||
customColor = self.dynamicColor
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,12 +330,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
|
||||
|
||||
self.loadAnimation()
|
||||
} else {
|
||||
var isTemplate = false
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
isTemplate = isSingleColor
|
||||
}
|
||||
}
|
||||
let isTemplate = file.isCustomTemplateEmoji
|
||||
|
||||
let pointSize = self.pointSize
|
||||
let placeholderColor = self.placeholderColor
|
||||
@ -380,12 +371,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
|
||||
return
|
||||
}
|
||||
|
||||
var isTemplate = false
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
isTemplate = isSingleColor
|
||||
}
|
||||
}
|
||||
let isTemplate = file.isCustomTemplateEmoji
|
||||
|
||||
let context = self.context
|
||||
if file.isAnimatedSticker || file.isVideoEmoji {
|
||||
|
@ -243,12 +243,7 @@ public final class EntityKeyboardAnimationData: Equatable {
|
||||
} else {
|
||||
type = .still
|
||||
}
|
||||
var isTemplate = false
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
isTemplate = isSingleColor
|
||||
}
|
||||
}
|
||||
let isTemplate = file.isCustomTemplateEmoji
|
||||
self.init(id: .file(file.fileId), type: type, resource: .standalone(resource: file.resource), dimensions: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0), immediateThumbnailData: file.immediateThumbnailData, isReaction: isReaction, isTemplate: isTemplate)
|
||||
}
|
||||
|
||||
@ -6442,11 +6437,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
existingIds.insert(file.fileId)
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
if file.isCustomTemplateEmoji {
|
||||
tintMode = .accent
|
||||
}
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .accent
|
||||
}
|
||||
if case let .CustomEmoji(_, _, _, packReference) = attribute {
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 773947703670341676 || id == 2964141614563343 {
|
||||
@ -6501,11 +6496,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
existingIds.insert(file.fileId)
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
if file.isCustomTemplateEmoji {
|
||||
tintMode = .accent
|
||||
}
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .accent
|
||||
}
|
||||
if case let .CustomEmoji(_, _, _, packReference) = attribute {
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 773947703670341676 || id == 2964141614563343 {
|
||||
@ -6547,11 +6542,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
existingIds.insert(file.fileId)
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
if file.isCustomTemplateEmoji {
|
||||
tintMode = .accent
|
||||
}
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .accent
|
||||
}
|
||||
if case let .CustomEmoji(_, _, _, packReference) = attribute {
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 773947703670341676 || id == 2964141614563343 {
|
||||
@ -6599,11 +6594,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
let resultItem: EmojiPagerContentComponent.Item
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
if file.isCustomTemplateEmoji {
|
||||
tintMode = .accent
|
||||
}
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .accent
|
||||
}
|
||||
if case let .CustomEmoji(_, _, _, packReference) = attribute {
|
||||
switch packReference {
|
||||
case let .id(id, _):
|
||||
if id == 773947703670341676 || id == 2964141614563343 {
|
||||
@ -6680,12 +6675,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in reactionItem.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if reactionItem.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationFile = reactionItem.file
|
||||
@ -6744,12 +6735,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in reactionItem.selectAnimation.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if reactionItem.selectAnimation.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationFile = reactionItem.selectAnimation
|
||||
@ -6829,12 +6816,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in animationFile.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if animationFile.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: animationFile, isReaction: true)
|
||||
@ -6881,12 +6864,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
switch item.content {
|
||||
case let .file(file):
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: file)
|
||||
@ -6936,15 +6915,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
if isStatusSelection {
|
||||
tintMode = .accent
|
||||
} else {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
if isStatusSelection {
|
||||
tintMode = .accent
|
||||
} else {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
|
||||
@ -7011,15 +6986,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
|
||||
for item in featuredEmojiPack.topItems {
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
if isStatusSelection {
|
||||
tintMode = .accent
|
||||
} else {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
if isStatusSelection {
|
||||
tintMode = .accent
|
||||
} else {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
|
||||
@ -7307,12 +7278,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let resultItem = EmojiPagerContentComponent.Item(
|
||||
@ -7353,12 +7320,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: item.file)
|
||||
@ -7391,12 +7354,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.media.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.media.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: item.media)
|
||||
@ -7452,12 +7411,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
processedIds.insert(item.file.fileId)
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: item.file)
|
||||
@ -7495,12 +7450,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
processedIds.insert(item.file.fileId)
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: item.file)
|
||||
@ -7529,12 +7480,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
}
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: item.file)
|
||||
@ -7593,12 +7540,8 @@ public final class EmojiPagerContentComponent: Component {
|
||||
|
||||
for item in featuredStickerPack.topItems {
|
||||
var tintMode: Item.TintMode = .none
|
||||
for attribute in item.file.attributes {
|
||||
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
|
||||
if isSingleColor {
|
||||
tintMode = .primary
|
||||
}
|
||||
}
|
||||
if item.file.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: item.file)
|
||||
|
Loading…
x
Reference in New Issue
Block a user