mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[WIP] Send message effects
This commit is contained in:
@@ -2163,4 +2163,140 @@ public extension EmojiPagerContentComponent {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
static func messageEffectsInputData(
|
||||
context: AccountContext,
|
||||
animationCache: AnimationCache,
|
||||
animationRenderer: MultiAnimationRenderer,
|
||||
hasSearch: Bool,
|
||||
hideBackground: Bool = false
|
||||
) -> Signal<EmojiPagerContentComponent, NoError> {
|
||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
|
||||
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
|
||||
|
||||
let strings = context.sharedContext.currentPresentationData.with({ $0 }).strings
|
||||
|
||||
let searchCategories: Signal<EmojiSearchCategories?, NoError> = .single(nil)
|
||||
|
||||
return combineLatest(
|
||||
hasPremium(context: context, chatPeerId: nil, premiumIfSavedMessages: false),
|
||||
context.engine.stickers.availableMessageEffects(),
|
||||
searchCategories
|
||||
)
|
||||
|> map { hasPremium, availableMessageEffects, searchCategories -> EmojiPagerContentComponent in
|
||||
struct ItemGroup {
|
||||
var supergroupId: AnyHashable
|
||||
var id: AnyHashable
|
||||
var title: String?
|
||||
var subtitle: String?
|
||||
var actionButtonTitle: String?
|
||||
var isPremiumLocked: Bool
|
||||
var isFeatured: Bool
|
||||
var displayPremiumBadges: Bool
|
||||
var hasEdit: Bool
|
||||
var headerItem: EntityKeyboardAnimationData?
|
||||
var items: [EmojiPagerContentComponent.Item]
|
||||
}
|
||||
var itemGroups: [ItemGroup] = []
|
||||
var itemGroupIndexById: [AnyHashable: Int] = [:]
|
||||
|
||||
if let availableMessageEffects {
|
||||
var reactionEffects: [AvailableMessageEffects.MessageEffect] = []
|
||||
var stickerEffects: [AvailableMessageEffects.MessageEffect] = []
|
||||
for messageEffect in availableMessageEffects.messageEffects {
|
||||
if messageEffect.effectAnimation != nil {
|
||||
reactionEffects.append(messageEffect)
|
||||
} else {
|
||||
stickerEffects.append(messageEffect)
|
||||
}
|
||||
}
|
||||
|
||||
for i in 0 ..< 2 {
|
||||
let groupId = i == 0 ? "reactions" : "stickers"
|
||||
for item in i == 0 ? reactionEffects : stickerEffects {
|
||||
if item.isPremium && isPremiumDisabled {
|
||||
continue
|
||||
}
|
||||
|
||||
let itemFile: TelegramMediaFile = item.effectSticker
|
||||
|
||||
var tintMode: Item.TintMode = .none
|
||||
if itemFile.isCustomTemplateEmoji {
|
||||
tintMode = .primary
|
||||
}
|
||||
|
||||
let animationData = EntityKeyboardAnimationData(file: itemFile, partialReference: .none)
|
||||
let resultItem = EmojiPagerContentComponent.Item(
|
||||
animationData: animationData,
|
||||
content: .animation(animationData),
|
||||
itemFile: itemFile,
|
||||
subgroupId: nil,
|
||||
icon: .none,
|
||||
tintMode: tintMode
|
||||
)
|
||||
|
||||
if let groupIndex = itemGroupIndexById[groupId] {
|
||||
itemGroups[groupIndex].items.append(resultItem)
|
||||
} else {
|
||||
itemGroupIndexById[groupId] = itemGroups.count
|
||||
//TODO:localize
|
||||
itemGroups.append(ItemGroup(supergroupId: groupId, id: groupId, title: i == 0 ? nil : "Message Effects", subtitle: nil, actionButtonTitle: nil, isPremiumLocked: false, isFeatured: false, displayPremiumBadges: false, hasEdit: false, headerItem: nil, items: [resultItem]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let warpContentsOnEdges: Bool = true
|
||||
|
||||
let allItemGroups = itemGroups.map { group -> EmojiPagerContentComponent.ItemGroup in
|
||||
let hasClear = false
|
||||
let isEmbedded = false
|
||||
|
||||
return EmojiPagerContentComponent.ItemGroup(
|
||||
supergroupId: group.supergroupId,
|
||||
groupId: group.id,
|
||||
title: group.title,
|
||||
subtitle: group.subtitle,
|
||||
badge: nil,
|
||||
actionButtonTitle: group.actionButtonTitle,
|
||||
isFeatured: group.isFeatured,
|
||||
isPremiumLocked: group.isPremiumLocked,
|
||||
isEmbedded: isEmbedded,
|
||||
hasClear: hasClear,
|
||||
hasEdit: group.hasEdit,
|
||||
collapsedLineCount: nil,
|
||||
displayPremiumBadges: group.displayPremiumBadges,
|
||||
headerItem: group.headerItem,
|
||||
fillWithLoadingPlaceholders: false,
|
||||
items: group.items
|
||||
)
|
||||
}
|
||||
|
||||
return EmojiPagerContentComponent(
|
||||
id: "stickers",
|
||||
context: context,
|
||||
avatarPeer: nil,
|
||||
animationCache: animationCache,
|
||||
animationRenderer: animationRenderer,
|
||||
inputInteractionHolder: EmojiPagerContentComponent.InputInteractionHolder(),
|
||||
panelItemGroups: [],
|
||||
contentItemGroups: allItemGroups,
|
||||
itemLayoutType: .detailed,
|
||||
itemContentUniqueId: nil,
|
||||
searchState: .empty(hasResults: false),
|
||||
warpContentsOnEdges: warpContentsOnEdges,
|
||||
hideBackground: hideBackground,
|
||||
displaySearchWithPlaceholder: hasSearch ? strings.StickersSearch_SearchStickersPlaceholder : nil,
|
||||
searchCategories: searchCategories,
|
||||
searchInitiallyHidden: true,
|
||||
searchAlwaysActive: false,
|
||||
searchIsPlaceholderOnly: false,
|
||||
searchUnicodeEmojiOnly: false,
|
||||
emptySearchResults: nil,
|
||||
enableLongPress: false,
|
||||
selectedItems: Set(),
|
||||
customTintColor: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user