mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-23 14:05:33 +00:00
UI improvements
This commit is contained in:
parent
fe726400fd
commit
ae8931c474
@ -1334,7 +1334,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
}
|
||||
strongSelf.requestUpdateOverlayWantsToBeBelowKeyboard(transition.containedViewLayoutTransition)
|
||||
},
|
||||
updateSearchQuery: { [weak self] rawQuery in
|
||||
updateSearchQuery: { [weak self] rawQuery, languageCode in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -1347,7 +1347,6 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
} else {
|
||||
let context = strongSelf.context
|
||||
|
||||
let languageCode = "en"
|
||||
var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query, completeMatch: false)
|
||||
if !languageCode.lowercased().hasPrefix("en") {
|
||||
signal = signal
|
||||
|
@ -252,8 +252,10 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
private var scheduledEmojiContentAnimationHint: EmojiPagerContentComponent.ContentAnimation?
|
||||
|
||||
private let emojiSearchDisposable = MetaDisposable()
|
||||
private let emojiSearchResult = Promise<(groups: [EmojiPagerContentComponent.ItemGroup], id: AnyHashable, emptyResultEmoji: TelegramMediaFile?)?>(nil)
|
||||
private let emojiSearchResult = Promise<(groups: [EmojiPagerContentComponent.ItemGroup], id: AnyHashable)?>(nil)
|
||||
private var emptyResultEmojis: [TelegramMediaFile] = []
|
||||
private var stableEmptyResultEmoji: TelegramMediaFile?
|
||||
private let stableEmptyResultEmojiDisposable = MetaDisposable()
|
||||
|
||||
private var previewItem: (groupId: AnyHashable, item: EmojiPagerContentComponent.Item)?
|
||||
private var dismissedPreviewItem: (groupId: AnyHashable, item: EmojiPagerContentComponent.Item)?
|
||||
@ -313,6 +315,32 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
self.layer.addSublayer(self.cloudLayer0)
|
||||
self.layer.addSublayer(self.cloudLayer1)
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
self.stableEmptyResultEmojiDisposable.set((self.context.account.postbox.combinedView(keys: [viewKey])
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] views in
|
||||
guard let strongSelf = self, let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
var filteredFiles: [TelegramMediaFile] = []
|
||||
let filterList: [String] = ["😖", "😫", "🫠", "😨", "❓"]
|
||||
for featuredEmojiPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for item in featuredEmojiPack.topItems {
|
||||
for attribute in item.file.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, alt, _):
|
||||
if filterList.contains(alt) {
|
||||
filteredFiles.append(item.file)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
strongSelf.emptyResultEmojis = filteredFiles
|
||||
}))
|
||||
|
||||
self.emojiContentDisposable = (combineLatest(queue: .mainQueue(),
|
||||
emojiContent,
|
||||
self.emojiSearchResult.get()
|
||||
@ -328,7 +356,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
var emptySearchResults: EmojiPagerContentComponent.EmptySearchResults?
|
||||
if !emojiSearchResult.groups.contains(where: { !$0.items.isEmpty }) {
|
||||
if strongSelf.stableEmptyResultEmoji == nil {
|
||||
strongSelf.stableEmptyResultEmoji = emojiSearchResult.emptyResultEmoji
|
||||
strongSelf.stableEmptyResultEmoji = strongSelf.emptyResultEmojis.randomElement()
|
||||
}
|
||||
//TODO:localize
|
||||
emptySearchResults = EmojiPagerContentComponent.EmptySearchResults(
|
||||
@ -397,7 +425,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
},
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { rawQuery in
|
||||
updateSearchQuery: { rawQuery, languageCode in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -410,7 +438,6 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
} else {
|
||||
let context = strongSelf.context
|
||||
|
||||
let languageCode = "en"
|
||||
var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query, completeMatch: false)
|
||||
if !languageCode.lowercased().hasPrefix("en") {
|
||||
signal = signal
|
||||
@ -435,14 +462,14 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
|> distinctUntilChanged
|
||||
|
||||
let resultSignal = signal
|
||||
|> mapToSignal { keywords -> Signal<(result: [EmojiPagerContentComponent.ItemGroup], emptyResultEmoji: TelegramMediaFile?), NoError> in
|
||||
|> mapToSignal { keywords -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in
|
||||
return combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000),
|
||||
context.engine.stickers.availableReactions(),
|
||||
hasPremium
|
||||
)
|
||||
|> take(1)
|
||||
|> map { view, availableReactions, hasPremium -> (result: [EmojiPagerContentComponent.ItemGroup], emptyResultEmoji: TelegramMediaFile?) in
|
||||
|> map { view, availableReactions, hasPremium -> [EmojiPagerContentComponent.ItemGroup] in
|
||||
var result: [(String, TelegramMediaFile?, String)] = []
|
||||
|
||||
var allEmoticons: [String: String] = [:]
|
||||
@ -493,42 +520,21 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var emptyResultEmoji: TelegramMediaFile?
|
||||
if let availableReactions = availableReactions {
|
||||
//let reactionFilter: [String] = ["😖", "😫", "🫠", "😨", "❓"]
|
||||
let filteredReactions: [TelegramMediaFile] = availableReactions.reactions.compactMap { reaction -> TelegramMediaFile? in
|
||||
switch reaction.value {
|
||||
case let .builtin(value):
|
||||
let _ = value
|
||||
//if reactionFilter.contains(value) {
|
||||
return reaction.selectAnimation
|
||||
/*} else {
|
||||
return nil
|
||||
}*/
|
||||
case .custom:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
emptyResultEmoji = filteredReactions.randomElement()
|
||||
}
|
||||
|
||||
return (result: [EmojiPagerContentComponent.ItemGroup(
|
||||
supergroupId: "search",
|
||||
groupId: "search",
|
||||
title: nil,
|
||||
subtitle: nil,
|
||||
actionButtonTitle: nil,
|
||||
isFeatured: false,
|
||||
isPremiumLocked: false,
|
||||
isEmbedded: false,
|
||||
hasClear: false,
|
||||
collapsedLineCount: nil,
|
||||
displayPremiumBadges: false,
|
||||
headerItem: nil,
|
||||
items: items
|
||||
)],
|
||||
emptyResultEmoji: emptyResultEmoji
|
||||
)
|
||||
return [EmojiPagerContentComponent.ItemGroup(
|
||||
supergroupId: "search",
|
||||
groupId: "search",
|
||||
title: nil,
|
||||
subtitle: nil,
|
||||
actionButtonTitle: nil,
|
||||
isFeatured: false,
|
||||
isPremiumLocked: false,
|
||||
isEmbedded: false,
|
||||
hasClear: false,
|
||||
collapsedLineCount: nil,
|
||||
displayPremiumBadges: false,
|
||||
headerItem: nil,
|
||||
items: items
|
||||
)]
|
||||
}
|
||||
}
|
||||
|
||||
@ -538,7 +544,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.emojiSearchResult.set(.single((result.result, AnyHashable(query), result.emptyResultEmoji)))
|
||||
strongSelf.emojiSearchResult.set(.single((result, AnyHashable(query))))
|
||||
}))
|
||||
}
|
||||
},
|
||||
@ -1100,6 +1106,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
return
|
||||
}
|
||||
self.previewItem = (groupId, item)
|
||||
self.view.endEditing(true)
|
||||
self.refreshLayout(transition: .immediate)
|
||||
} else {
|
||||
self.freezeUpdates = true
|
||||
|
@ -1547,7 +1547,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
|
||||
private let activated: () -> Void
|
||||
private let deactivated: () -> Void
|
||||
private let updateQuery: (String) -> Void
|
||||
private let updateQuery: (String, String) -> Void
|
||||
|
||||
let tintContainerView: UIView
|
||||
|
||||
@ -1577,7 +1577,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
return self.textField != nil
|
||||
}
|
||||
|
||||
init(activated: @escaping () -> Void, deactivated: @escaping () -> Void, updateQuery: @escaping (String) -> Void) {
|
||||
init(activated: @escaping () -> Void, deactivated: @escaping () -> Void, updateQuery: @escaping (String, String) -> Void) {
|
||||
self.activated = activated
|
||||
self.deactivated = deactivated
|
||||
self.updateQuery = updateQuery
|
||||
@ -1691,7 +1691,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
self.updateQuery("")
|
||||
self.updateQuery("", "en")
|
||||
|
||||
self.clearIconView.isHidden = true
|
||||
self.clearIconTintView.isHidden = true
|
||||
@ -1707,7 +1707,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
}
|
||||
|
||||
@objc private func clearPressed() {
|
||||
self.updateQuery("")
|
||||
self.updateQuery("", "en")
|
||||
self.textField?.text = ""
|
||||
|
||||
self.clearIconView.isHidden = true
|
||||
@ -1726,11 +1726,19 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate {
|
||||
|
||||
let text = textField.text ?? ""
|
||||
|
||||
var inputLanguage = textField.textInputMode?.primaryLanguage ?? "en"
|
||||
if let range = inputLanguage.range(of: "-") {
|
||||
inputLanguage = String(inputLanguage[inputLanguage.startIndex ..< range.lowerBound])
|
||||
}
|
||||
if let range = inputLanguage.range(of: "_") {
|
||||
inputLanguage = String(inputLanguage[inputLanguage.startIndex ..< range.lowerBound])
|
||||
}
|
||||
|
||||
self.clearIconView.isHidden = text.isEmpty
|
||||
self.clearIconTintView.isHidden = text.isEmpty
|
||||
self.clearIconButton.isHidden = text.isEmpty
|
||||
|
||||
self.updateQuery(text)
|
||||
self.updateQuery(text, inputLanguage)
|
||||
}
|
||||
|
||||
private func update(transition: Transition) {
|
||||
@ -2068,7 +2076,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
public let presentGlobalOverlayController: (ViewController) -> Void
|
||||
public let navigationController: () -> NavigationController?
|
||||
public let requestUpdate: (Transition) -> Void
|
||||
public let updateSearchQuery: (String) -> Void
|
||||
public let updateSearchQuery: (String, String) -> Void
|
||||
public let chatPeerId: PeerId?
|
||||
public let peekBehavior: EmojiContentPeekBehavior?
|
||||
public let customLayout: CustomLayout?
|
||||
@ -2088,7 +2096,7 @@ public final class EmojiPagerContentComponent: Component {
|
||||
presentGlobalOverlayController: @escaping (ViewController) -> Void,
|
||||
navigationController: @escaping () -> NavigationController?,
|
||||
requestUpdate: @escaping (Transition) -> Void,
|
||||
updateSearchQuery: @escaping (String) -> Void,
|
||||
updateSearchQuery: @escaping (String, String) -> Void,
|
||||
chatPeerId: PeerId?,
|
||||
peekBehavior: EmojiContentPeekBehavior?,
|
||||
customLayout: CustomLayout?,
|
||||
@ -6036,11 +6044,11 @@ public final class EmojiPagerContentComponent: Component {
|
||||
strongSelf.isSearchActivated = false
|
||||
strongSelf.pagerEnvironment?.onWantsExclusiveModeUpdated(false)
|
||||
strongSelf.component?.inputInteractionHolder.inputInteraction?.requestUpdate(.immediate)
|
||||
}, updateQuery: { [weak self] query in
|
||||
}, updateQuery: { [weak self] query, languageCode in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.component?.inputInteractionHolder.inputInteraction?.updateSearchQuery(query)
|
||||
strongSelf.component?.inputInteractionHolder.inputInteraction?.updateSearchQuery(query, languageCode)
|
||||
})
|
||||
self.visibleSearchHeader = visibleSearchHeader
|
||||
if self.isSearchActivated {
|
||||
|
@ -1123,7 +1123,7 @@ final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
},
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { _ in
|
||||
updateSearchQuery: { _, _ in
|
||||
},
|
||||
chatPeerId: chatPeerId,
|
||||
peekBehavior: nil,
|
||||
@ -1327,7 +1327,7 @@ final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
},
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { _ in
|
||||
updateSearchQuery: { _, _ in
|
||||
},
|
||||
chatPeerId: chatPeerId,
|
||||
peekBehavior: stickerPeekBehavior,
|
||||
@ -2053,7 +2053,7 @@ final class EntityInputView: UIView, AttachmentTextInputPanelInputView, UIInputV
|
||||
},
|
||||
requestUpdate: { _ in
|
||||
},
|
||||
updateSearchQuery: { _ in
|
||||
updateSearchQuery: { _, _ in
|
||||
},
|
||||
chatPeerId: nil,
|
||||
peekBehavior: nil,
|
||||
|
Loading…
x
Reference in New Issue
Block a user