Various improvements

This commit is contained in:
Isaac
2024-04-19 17:16:12 +04:00
parent e938cecd37
commit e2a3decea3
10 changed files with 177 additions and 60 deletions

View File

@@ -1589,6 +1589,13 @@ public extension EmojiPagerContentComponent {
return emojiItems
}
enum StickersSubject {
case profilePhotoEmojiSelection
case groupPhotoEmojiSelection
case chatStickers
case greetingStickers
}
static func stickerInputData(
context: AccountContext,
animationCache: AnimationCache,
@@ -1601,8 +1608,7 @@ public extension EmojiPagerContentComponent {
forceHasPremium: Bool,
hasEdit: Bool = false,
searchIsPlaceholderOnly: Bool = true,
isProfilePhotoEmojiSelection: Bool = false,
isGroupPhotoEmojiSelection: Bool = false,
subject: StickersSubject = .chatStickers,
hideBackground: Bool = false
) -> Signal<EmojiPagerContentComponent, NoError> {
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
@@ -1652,12 +1658,17 @@ public extension EmojiPagerContentComponent {
let strings = context.sharedContext.currentPresentationData.with({ $0 }).strings
//TODO:localize
let searchCategories: Signal<EmojiSearchCategories?, NoError>
if isProfilePhotoEmojiSelection || isGroupPhotoEmojiSelection {
switch subject {
case .groupPhotoEmojiSelection, .profilePhotoEmojiSelection:
searchCategories = context.engine.stickers.emojiSearchCategories(kind: .avatar)
} else {
searchCategories = context.engine.stickers.emojiSearchCategories(kind: .emoji)
case .chatStickers:
searchCategories = context.engine.stickers.emojiSearchCategories(kind: .chatStickers)
case .greetingStickers:
searchCategories = context.engine.stickers.emojiSearchCategories(kind: .greetingStickers)
}
return combineLatest(
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: stickerOrderedItemListCollectionIds, namespaces: stickerNamespaces, aroundIndex: nil, count: 10000000),
hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: false),
@@ -2091,6 +2102,14 @@ public extension EmojiPagerContentComponent {
)
}
let warpContentsOnEdges: Bool
switch subject {
case .profilePhotoEmojiSelection, .groupPhotoEmojiSelection:
warpContentsOnEdges = true
default:
warpContentsOnEdges = false
}
return EmojiPagerContentComponent(
id: isMasks ? "masks" : "stickers",
context: context,
@@ -2103,7 +2122,7 @@ public extension EmojiPagerContentComponent {
itemLayoutType: .detailed,
itemContentUniqueId: nil,
searchState: .empty(hasResults: false),
warpContentsOnEdges: isProfilePhotoEmojiSelection || isGroupPhotoEmojiSelection,
warpContentsOnEdges: warpContentsOnEdges,
hideBackground: hideBackground,
displaySearchWithPlaceholder: hasSearch ? strings.StickersSearch_SearchStickersPlaceholder : nil,
searchCategories: searchCategories,