mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Don't call basicEmoji for every message
This commit is contained in:
parent
9462549ea4
commit
605c9ecc8d
@ -4618,3 +4618,5 @@ Any member of this group will be able to see messages in the channel.";
|
|||||||
"Conversation.SelectedMessages_any" = "%@ Messages Selected";
|
"Conversation.SelectedMessages_any" = "%@ Messages Selected";
|
||||||
"Conversation.SelectedMessages_many" = "%@ Messages Selected";
|
"Conversation.SelectedMessages_many" = "%@ Messages Selected";
|
||||||
"Conversation.SelectedMessages_0" = "%@ Messages Selected";
|
"Conversation.SelectedMessages_0" = "%@ Messages Selected";
|
||||||
|
|
||||||
|
"AccentColor.Title" = "Accent Color";
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,8 @@ func chatHistoryEntriesForView(location: ChatLocation, view: MessageHistoryView,
|
|||||||
|
|
||||||
var contentTypeHint: ChatMessageEntryContentType = .generic
|
var contentTypeHint: ChatMessageEntryContentType = .generic
|
||||||
if presentationData.largeEmoji {
|
if presentationData.largeEmoji {
|
||||||
if let _ = associatedData.animatedEmojiStickers[entry.message.text.basicEmoji.0] {
|
let messageText = entry.message.text
|
||||||
|
if messageText.count == 1, let _ = associatedData.animatedEmojiStickers[messageText.basicEmoji.0] {
|
||||||
contentTypeHint = .animatedEmoji
|
contentTypeHint = .animatedEmoji
|
||||||
} else if messageIsElligibleForLargeEmoji(entry.message) {
|
} else if messageIsElligibleForLargeEmoji(entry.message) {
|
||||||
contentTypeHint = .largeEmoji
|
contentTypeHint = .largeEmoji
|
||||||
|
|||||||
Binary file not shown.
@ -0,0 +1,82 @@
|
|||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
import Display
|
||||||
|
import Postbox
|
||||||
|
import SwiftSignalKit
|
||||||
|
import AsyncDisplayKit
|
||||||
|
import TelegramCore
|
||||||
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
|
import AccountContext
|
||||||
|
|
||||||
|
final class ThemeAccentColorController: ViewController {
|
||||||
|
private let context: AccountContext
|
||||||
|
private let currentTheme: PresentationThemeReference
|
||||||
|
|
||||||
|
private var controllerNode: ThemeAccentColorControllerNode {
|
||||||
|
return self.displayNode as! ThemeAccentColorControllerNode
|
||||||
|
}
|
||||||
|
|
||||||
|
private var didPlayPresentationAnimation = false
|
||||||
|
|
||||||
|
private var presentationData: PresentationData
|
||||||
|
private var presentationDataDisposable: Disposable?
|
||||||
|
|
||||||
|
init(context: AccountContext, currentTheme: PresentationThemeReference) {
|
||||||
|
self.context = context
|
||||||
|
self.currentTheme = currentTheme
|
||||||
|
|
||||||
|
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
|
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationTheme: self.presentationData.theme, presentationStrings: self.presentationData.strings))
|
||||||
|
|
||||||
|
self.title = self.presentationData.strings.AccentColor_Title
|
||||||
|
|
||||||
|
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBarStyle.style
|
||||||
|
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||||
|
|
||||||
|
self.presentationDataDisposable = (context.sharedContext.presentationData
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.presentationData = presentationData
|
||||||
|
strongSelf.updateStrings()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
required init(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
self.presentationDataDisposable?.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
|
if let presentationArguments = self.presentationArguments as? ViewControllerPresentationArguments, !self.didPlayPresentationAnimation {
|
||||||
|
self.didPlayPresentationAnimation = true
|
||||||
|
if case .modalSheet = presentationArguments.presentationAnimation {
|
||||||
|
self.controllerNode.animateIn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateStrings() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override public func dismiss(completion: (() -> Void)? = nil) {
|
||||||
|
self.controllerNode.animateOut(completion: { [weak self] in
|
||||||
|
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||||
|
completion?()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||||
|
super.containerLayoutUpdated(layout, transition: transition)
|
||||||
|
|
||||||
|
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationHeight, transition: transition)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,287 @@
|
|||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
import Display
|
||||||
|
import Postbox
|
||||||
|
import SwiftSignalKit
|
||||||
|
import AsyncDisplayKit
|
||||||
|
import TelegramCore
|
||||||
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
|
import AccountContext
|
||||||
|
|
||||||
|
final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||||
|
private let context: AccountContext
|
||||||
|
private let currentTheme: PresentationThemeReference
|
||||||
|
private var presentationData: PresentationData
|
||||||
|
|
||||||
|
private let scrollNode: ASScrollNode
|
||||||
|
private let pageControlBackgroundNode: ASDisplayNode
|
||||||
|
private let pageControlNode: PageControlNode
|
||||||
|
|
||||||
|
private let chatListBackgroundNode: ASDisplayNode
|
||||||
|
private var chatNodes: [ListViewItemNode]?
|
||||||
|
|
||||||
|
private let chatBackgroundNode: ASDisplayNode
|
||||||
|
private var messageNodes: [ListViewItemNode]?
|
||||||
|
|
||||||
|
private var colorPanelNode: WallpaperColorPanelNode
|
||||||
|
private let toolbarNode: WallpaperGalleryToolbarNode
|
||||||
|
|
||||||
|
private var validLayout: (ContainerViewLayout, CGFloat)?
|
||||||
|
|
||||||
|
private var colorDisposable: Disposable?
|
||||||
|
|
||||||
|
init(context: AccountContext, currentTheme: PresentationThemeReference, dismiss: @escaping () -> Void, apply: @escaping () -> Void) {
|
||||||
|
self.context = context
|
||||||
|
self.currentTheme = currentTheme
|
||||||
|
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
|
self.scrollNode = ASScrollNode()
|
||||||
|
self.pageControlBackgroundNode = ASDisplayNode()
|
||||||
|
self.pageControlBackgroundNode.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.3)
|
||||||
|
self.pageControlBackgroundNode.cornerRadius = 6.0
|
||||||
|
|
||||||
|
self.pageControlNode = PageControlNode(dotColor: self.presentationData.theme.chatList.unreadBadgeActiveBackgroundColor, inactiveDotColor: self.presentationData.theme.list.pageIndicatorInactiveColor)
|
||||||
|
|
||||||
|
self.chatListBackgroundNode = ASDisplayNode()
|
||||||
|
self.chatBackgroundNode = ASDisplayNode()
|
||||||
|
|
||||||
|
self.colorPanelNode = WallpaperColorPanelNode(theme: presentationData.theme, strings: presentationData.strings)
|
||||||
|
self.toolbarNode = WallpaperGalleryToolbarNode(theme: self.presentationData.theme, strings: self.presentationData.strings)
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
|
||||||
|
self.setViewBlock({
|
||||||
|
return UITracingLayerView()
|
||||||
|
})
|
||||||
|
|
||||||
|
self.backgroundColor = self.presentationData.theme.list.plainBackgroundColor
|
||||||
|
|
||||||
|
self.chatListBackgroundNode.backgroundColor = self.presentationData.theme.chatList.backgroundColor
|
||||||
|
|
||||||
|
if case let .color(value) = self.presentationData.theme.chat.defaultWallpaper {
|
||||||
|
self.chatBackgroundNode.backgroundColor = UIColor(rgb: UInt32(bitPattern: value))
|
||||||
|
}
|
||||||
|
|
||||||
|
self.pageControlNode.isUserInteractionEnabled = false
|
||||||
|
self.pageControlNode.pagesCount = 2
|
||||||
|
|
||||||
|
self.addSubnode(self.scrollNode)
|
||||||
|
self.addSubnode(self.pageControlBackgroundNode)
|
||||||
|
self.addSubnode(self.pageControlNode)
|
||||||
|
self.addSubnode(self.colorPanelNode)
|
||||||
|
self.addSubnode(self.toolbarNode)
|
||||||
|
|
||||||
|
self.scrollNode.addSubnode(self.chatListBackgroundNode)
|
||||||
|
self.scrollNode.addSubnode(self.chatBackgroundNode)
|
||||||
|
|
||||||
|
self.colorPanelNode.colorChanged = { [weak self] color, ended in
|
||||||
|
if let strongSelf = self {
|
||||||
|
//strongSelf.updateEntries(color: color, preview: !ended)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if case let .customColor(colorValue) = self.source, let color = colorValue {
|
||||||
|
// colorPanelNode.color = UIColor(rgb: UInt32(bitPattern: color))
|
||||||
|
//}
|
||||||
|
|
||||||
|
self.toolbarNode.cancel = {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
self.toolbarNode.done = {
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
self.colorDisposable = (chatServiceBackgroundColor(wallpaper: self.presentationData.theme.chat.defaultWallpaper, mediaBox: context.account.postbox.mediaBox)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] color in
|
||||||
|
if let strongSelf = self {
|
||||||
|
if strongSelf.presentationData.theme.chat.defaultWallpaper.hasWallpaper {
|
||||||
|
strongSelf.pageControlBackgroundNode.backgroundColor = color
|
||||||
|
} else {
|
||||||
|
strongSelf.pageControlBackgroundNode.backgroundColor = .clear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
self.colorDisposable?.dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func didLoad() {
|
||||||
|
super.didLoad()
|
||||||
|
|
||||||
|
self.scrollNode.view.showsHorizontalScrollIndicator = false
|
||||||
|
self.scrollNode.view.isPagingEnabled = true
|
||||||
|
self.scrollNode.view.delegate = self
|
||||||
|
self.pageControlNode.setPage(0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
|
let bounds = scrollView.bounds
|
||||||
|
if !bounds.width.isZero {
|
||||||
|
self.pageControlNode.setPage(scrollView.contentOffset.x / bounds.width)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func animateIn(completion: (() -> Void)? = nil) {
|
||||||
|
self.layer.animatePosition(from: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), to: self.layer.position, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
||||||
|
}
|
||||||
|
|
||||||
|
func animateOut(completion: (() -> Void)? = nil) {
|
||||||
|
self.layer.animatePosition(from: self.layer.position, to: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, completion: { _ in
|
||||||
|
completion?()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateChatsLayout(layout: ContainerViewLayout, topInset: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
|
var items: [ChatListItem] = []
|
||||||
|
|
||||||
|
let interaction = ChatListNodeInteraction(activateSearch: {}, peerSelected: { _ in }, togglePeerSelected: { _ in }, messageSelected: { _, _, _ in}, groupSelected: { _ in }, addContact: { _ in }, setPeerIdWithRevealedOptions: { _, _ in }, setItemPinned: { _, _ in }, setPeerMuted: { _, _ in }, deletePeer: { _ in }, updatePeerGrouping: { _, _ in }, togglePeerMarkedUnread: { _, _ in}, toggleArchivedFolderHiddenByDefault: {})
|
||||||
|
let chatListPresentationData = ChatListPresentationData(theme: self.presentationData.theme, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true)
|
||||||
|
|
||||||
|
let peers = SimpleDictionary<PeerId, Peer>()
|
||||||
|
let messages = SimpleDictionary<MessageId, Message>()
|
||||||
|
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||||
|
let peer1 = TelegramUser(id: peerId, accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||||
|
|
||||||
|
let peer2 = TelegramUser(id: peerId, accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||||
|
|
||||||
|
items.append(ChatListItem(presentationData: chatListPresentationData, context: self.context, peerGroupId: .root, index: ChatListIndex(pinningIndex: nil, messageIndex: MessageIndex(id: MessageId(peerId: PeerId(namespace: 0, id: 1), namespace: 0, id: 0), timestamp: 66003)), content: .peer(message: Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer1, text: "", attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []), peer: RenderedPeer(peer: peer1), combinedReadState: nil, notificationSettings: nil, presence: nil, summaryInfo: ChatListMessageTagSummaryInfo(tagSummaryCount: nil, actionsSummaryCount: nil), embeddedState: nil, inputActivities: nil, isAd: false, ignoreUnreadBadge: false), editing: false, hasActiveRevealControls: false, selected: false, header: nil, enableContextActions: false, hiddenOffset: false, interaction: interaction))
|
||||||
|
|
||||||
|
items.append(ChatListItem(presentationData: chatListPresentationData, context: self.context, peerGroupId: .root, index: ChatListIndex(pinningIndex: nil, messageIndex: MessageIndex(id: MessageId(peerId: PeerId(namespace: 0, id: 2), namespace: 0, id: 0), timestamp: 66000)), content: .peer(message: Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer1, text: "", attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []), peer: RenderedPeer(peer: peer2), combinedReadState: nil, notificationSettings: nil, presence: nil, summaryInfo: ChatListMessageTagSummaryInfo(tagSummaryCount: nil, actionsSummaryCount: nil), embeddedState: nil, inputActivities: nil, isAd: false, ignoreUnreadBadge: false), editing: false, hasActiveRevealControls: false, selected: false, header: nil, enableContextActions: false, hiddenOffset: false, interaction: interaction))
|
||||||
|
|
||||||
|
let params = ListViewItemLayoutParams(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right)
|
||||||
|
if let chatNodes = self.chatNodes {
|
||||||
|
for i in 0 ..< items.count {
|
||||||
|
let itemNode = chatNodes[i]
|
||||||
|
items[i].updateNode(async: { $0() }, node: {
|
||||||
|
return itemNode
|
||||||
|
}, params: params, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], animation: .None, completion: { (layout, apply) in
|
||||||
|
let nodeFrame = CGRect(origin: itemNode.frame.origin, size: CGSize(width: layout.size.width, height: layout.size.height))
|
||||||
|
|
||||||
|
itemNode.contentSize = layout.contentSize
|
||||||
|
itemNode.insets = layout.insets
|
||||||
|
itemNode.frame = nodeFrame
|
||||||
|
itemNode.isUserInteractionEnabled = false
|
||||||
|
|
||||||
|
apply(ListViewItemApply(isOnScreen: true))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var chatNodes: [ListViewItemNode] = []
|
||||||
|
for i in 0 ..< items.count {
|
||||||
|
var itemNode: ListViewItemNode?
|
||||||
|
items[i].nodeConfiguredForParams(async: { $0() }, params: params, synchronousLoads: false, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], completion: { node, apply in
|
||||||
|
itemNode = node
|
||||||
|
apply().1(ListViewItemApply(isOnScreen: true))
|
||||||
|
})
|
||||||
|
//itemNode!.subnodeTransform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||||
|
itemNode!.isUserInteractionEnabled = false
|
||||||
|
chatNodes.append(itemNode!)
|
||||||
|
self.chatListBackgroundNode.addSubnode(itemNode!)
|
||||||
|
}
|
||||||
|
self.chatNodes = chatNodes
|
||||||
|
}
|
||||||
|
|
||||||
|
if let chatNodes = self.chatNodes {
|
||||||
|
var topOffset: CGFloat = topInset
|
||||||
|
for itemNode in chatNodes {
|
||||||
|
transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: 0.0, y: topOffset), size: itemNode.frame.size))
|
||||||
|
topOffset += itemNode.frame.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateMessagesLayout(layout: ContainerViewLayout, bottomInset: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
|
var items: [ChatMessageItem] = []
|
||||||
|
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1)
|
||||||
|
let otherPeerId = self.context.account.peerId
|
||||||
|
var peers = SimpleDictionary<PeerId, Peer>()
|
||||||
|
var messages = SimpleDictionary<MessageId, Message>()
|
||||||
|
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||||
|
peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||||
|
|
||||||
|
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||||
|
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [])
|
||||||
|
|
||||||
|
let controllerInteraction = ChatControllerInteraction.default
|
||||||
|
let chatPresentationData = ChatPresentationData(theme: ChatPresentationThemeData(theme: self.presentationData.theme, wallpaper: self.presentationData.theme.chat.defaultWallpaper), fontSize: self.presentationData.fontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: false, largeEmoji: false)
|
||||||
|
|
||||||
|
items.append(ChatMessageItem(presentationData: chatPresentationData, context: self.context, chatLocation: .peer(peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false), controllerInteraction: controllerInteraction, content: .message(message: Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: "", attributes: [ReplyMessageAttribute(messageId: replyMessageId)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []), read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: false))
|
||||||
|
|
||||||
|
items.append(ChatMessageItem(presentationData: chatPresentationData, context: self.context, chatLocation: .peer(peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false), controllerInteraction: controllerInteraction, content: .message(message: Message(stableId: 3, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66002, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []), read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: false))
|
||||||
|
|
||||||
|
items.append(ChatMessageItem(presentationData: chatPresentationData, context: self.context, chatLocation: .peer(peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false), controllerInteraction: controllerInteraction, content: .message(message: Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []), read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: false))
|
||||||
|
|
||||||
|
let voiceAttributes: [TelegramMediaFileAttribute] = [.Audio(isVoice: true, duration: 14, title: nil, performer: nil, waveform: MemoryBuffer())]
|
||||||
|
let voiceMedia = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: nil, attributes: voiceAttributes)
|
||||||
|
|
||||||
|
items.append(ChatMessageItem(presentationData: chatPresentationData, context: self.context, chatLocation: .peer(peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false, forcedResourceStatus: FileMediaResourceStatus(mediaStatus: .playbackStatus(.playing), fetchStatus: .Local)), controllerInteraction: controllerInteraction, content: .message(message: Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: []), read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: false))
|
||||||
|
|
||||||
|
items.append(ChatMessageItem(presentationData: chatPresentationData, context: self.context, chatLocation: .peer(peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false), controllerInteraction: controllerInteraction, content: .message(message: Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: "", attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []), read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: false))
|
||||||
|
|
||||||
|
let params = ListViewItemLayoutParams(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right)
|
||||||
|
if let messageNodes = self.messageNodes {
|
||||||
|
for i in 0 ..< items.count {
|
||||||
|
let itemNode = messageNodes[i]
|
||||||
|
items[i].updateNode(async: { $0() }, node: {
|
||||||
|
return itemNode
|
||||||
|
}, params: params, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], animation: .None, completion: { (layout, apply) in
|
||||||
|
let nodeFrame = CGRect(origin: itemNode.frame.origin, size: CGSize(width: layout.size.width, height: layout.size.height))
|
||||||
|
|
||||||
|
itemNode.contentSize = layout.contentSize
|
||||||
|
itemNode.insets = layout.insets
|
||||||
|
itemNode.frame = nodeFrame
|
||||||
|
itemNode.isUserInteractionEnabled = false
|
||||||
|
|
||||||
|
apply(ListViewItemApply(isOnScreen: true))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var messageNodes: [ListViewItemNode] = []
|
||||||
|
for i in 0 ..< items.count {
|
||||||
|
var itemNode: ListViewItemNode?
|
||||||
|
items[i].nodeConfiguredForParams(async: { $0() }, params: params, synchronousLoads: false, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], completion: { node, apply in
|
||||||
|
itemNode = node
|
||||||
|
apply().1(ListViewItemApply(isOnScreen: true))
|
||||||
|
})
|
||||||
|
itemNode!.subnodeTransform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||||
|
itemNode!.isUserInteractionEnabled = false
|
||||||
|
messageNodes.append(itemNode!)
|
||||||
|
self.chatBackgroundNode.addSubnode(itemNode!)
|
||||||
|
}
|
||||||
|
self.messageNodes = messageNodes
|
||||||
|
}
|
||||||
|
|
||||||
|
if let messageNodes = self.messageNodes {
|
||||||
|
var bottomOffset: CGFloat = layout.size.height - bottomInset - 9.0
|
||||||
|
for itemNode in messageNodes {
|
||||||
|
transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: 0.0, y: bottomOffset - itemNode.frame.height), size: itemNode.frame.size))
|
||||||
|
bottomOffset -= itemNode.frame.height
|
||||||
|
itemNode.updateFrame(itemNode.frame, within: layout.size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
|
let bounds = CGRect(origin: CGPoint(), size: layout.size)
|
||||||
|
self.scrollNode.frame = bounds
|
||||||
|
|
||||||
|
let toolbarHeight = 49.0 + layout.intrinsicInsets.bottom
|
||||||
|
self.chatListBackgroundNode.frame = CGRect(x: 0.0, y: 0.0, width: bounds.width, height: bounds.height)
|
||||||
|
self.chatBackgroundNode.frame = CGRect(x: bounds.width, y: 0.0, width: bounds.width, height: bounds.height)
|
||||||
|
|
||||||
|
self.scrollNode.view.contentSize = CGSize(width: bounds.width * 2.0, height: bounds.height)
|
||||||
|
|
||||||
|
transition.updateFrame(node: self.toolbarNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - toolbarHeight), size: CGSize(width: layout.size.width, height: 49.0 + layout.intrinsicInsets.bottom)))
|
||||||
|
self.toolbarNode.updateLayout(size: CGSize(width: layout.size.width, height: 49.0), layout: layout, transition: transition)
|
||||||
|
|
||||||
|
self.updateChatsLayout(layout: layout, topInset: navigationBarHeight, transition: transition)
|
||||||
|
self.updateMessagesLayout(layout: layout, bottomInset: toolbarHeight + 66.0, transition: transition)
|
||||||
|
|
||||||
|
let pageControlSize = self.pageControlNode.measure(CGSize(width: bounds.width, height: 100.0))
|
||||||
|
let pageControlFrame = CGRect(origin: CGPoint(x: floor((bounds.width - pageControlSize.width) / 2.0), y: layout.size.height - toolbarHeight - 42.0), size: pageControlSize)
|
||||||
|
self.pageControlNode.frame = pageControlFrame
|
||||||
|
self.pageControlBackgroundNode.frame = CGRect(x: pageControlFrame.minX - 11.0, y: pageControlFrame.minY - 12.0, width: pageControlFrame.width + 22.0, height: 30.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ import TelegramPresentationData
|
|||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
private let previewTheme: PresentationTheme
|
private let previewTheme: PresentationTheme
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
|
|||||||
@ -76,6 +76,8 @@
|
|||||||
09A218D9229EE1B600DE6898 /* HorizontalStickerGridItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A218D7229EE1B500DE6898 /* HorizontalStickerGridItem.swift */; };
|
09A218D9229EE1B600DE6898 /* HorizontalStickerGridItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A218D7229EE1B500DE6898 /* HorizontalStickerGridItem.swift */; };
|
||||||
09A218DA229EE1B600DE6898 /* HorizontalStickersChatContextPanelNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A218D8229EE1B500DE6898 /* HorizontalStickersChatContextPanelNode.swift */; };
|
09A218DA229EE1B600DE6898 /* HorizontalStickersChatContextPanelNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A218D8229EE1B500DE6898 /* HorizontalStickersChatContextPanelNode.swift */; };
|
||||||
09A218F522A15F1400DE6898 /* ThemeSettingsAppIconItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A218F422A15F1400DE6898 /* ThemeSettingsAppIconItem.swift */; };
|
09A218F522A15F1400DE6898 /* ThemeSettingsAppIconItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A218F422A15F1400DE6898 /* ThemeSettingsAppIconItem.swift */; };
|
||||||
|
09B4819323028A4200D5B32B /* ThemeAccentColorController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B4819223028A4200D5B32B /* ThemeAccentColorController.swift */; };
|
||||||
|
09B4819523028A8A00D5B32B /* ThemeAccentColorControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B4819423028A8A00D5B32B /* ThemeAccentColorControllerNode.swift */; };
|
||||||
09B4EE4721A6D33F00847FA6 /* RecentSessionsEmptyStateItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B4EE4621A6D33F00847FA6 /* RecentSessionsEmptyStateItem.swift */; };
|
09B4EE4721A6D33F00847FA6 /* RecentSessionsEmptyStateItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B4EE4621A6D33F00847FA6 /* RecentSessionsEmptyStateItem.swift */; };
|
||||||
09C500242142BA6400EF253E /* ItemListWebsiteItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C500232142BA6400EF253E /* ItemListWebsiteItem.swift */; };
|
09C500242142BA6400EF253E /* ItemListWebsiteItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C500232142BA6400EF253E /* ItemListWebsiteItem.swift */; };
|
||||||
09CE95002232729A00A7D2C3 /* StickerPaneSearchContentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE94FF2232729A00A7D2C3 /* StickerPaneSearchContentNode.swift */; };
|
09CE95002232729A00A7D2C3 /* StickerPaneSearchContentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE94FF2232729A00A7D2C3 /* StickerPaneSearchContentNode.swift */; };
|
||||||
@ -941,6 +943,8 @@
|
|||||||
09A218D7229EE1B500DE6898 /* HorizontalStickerGridItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalStickerGridItem.swift; sourceTree = "<group>"; };
|
09A218D7229EE1B500DE6898 /* HorizontalStickerGridItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalStickerGridItem.swift; sourceTree = "<group>"; };
|
||||||
09A218D8229EE1B500DE6898 /* HorizontalStickersChatContextPanelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalStickersChatContextPanelNode.swift; sourceTree = "<group>"; };
|
09A218D8229EE1B500DE6898 /* HorizontalStickersChatContextPanelNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalStickersChatContextPanelNode.swift; sourceTree = "<group>"; };
|
||||||
09A218F422A15F1400DE6898 /* ThemeSettingsAppIconItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSettingsAppIconItem.swift; sourceTree = "<group>"; };
|
09A218F422A15F1400DE6898 /* ThemeSettingsAppIconItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSettingsAppIconItem.swift; sourceTree = "<group>"; };
|
||||||
|
09B4819223028A4200D5B32B /* ThemeAccentColorController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeAccentColorController.swift; sourceTree = "<group>"; };
|
||||||
|
09B4819423028A8A00D5B32B /* ThemeAccentColorControllerNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeAccentColorControllerNode.swift; sourceTree = "<group>"; };
|
||||||
09B4EE4621A6D33F00847FA6 /* RecentSessionsEmptyStateItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentSessionsEmptyStateItem.swift; sourceTree = "<group>"; };
|
09B4EE4621A6D33F00847FA6 /* RecentSessionsEmptyStateItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentSessionsEmptyStateItem.swift; sourceTree = "<group>"; };
|
||||||
09C500232142BA6400EF253E /* ItemListWebsiteItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemListWebsiteItem.swift; sourceTree = "<group>"; };
|
09C500232142BA6400EF253E /* ItemListWebsiteItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemListWebsiteItem.swift; sourceTree = "<group>"; };
|
||||||
09CE94FF2232729A00A7D2C3 /* StickerPaneSearchContentNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerPaneSearchContentNode.swift; sourceTree = "<group>"; };
|
09CE94FF2232729A00A7D2C3 /* StickerPaneSearchContentNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerPaneSearchContentNode.swift; sourceTree = "<group>"; };
|
||||||
@ -2555,6 +2559,8 @@
|
|||||||
09CE9512223825B700A7D2C3 /* CustomWallpaperPicker.swift */,
|
09CE9512223825B700A7D2C3 /* CustomWallpaperPicker.swift */,
|
||||||
0957DE2222DE28FB001B4D57 /* ThemePreviewController.swift */,
|
0957DE2222DE28FB001B4D57 /* ThemePreviewController.swift */,
|
||||||
0957DE2422DE2909001B4D57 /* ThemePreviewControllerNode.swift */,
|
0957DE2422DE2909001B4D57 /* ThemePreviewControllerNode.swift */,
|
||||||
|
09B4819223028A4200D5B32B /* ThemeAccentColorController.swift */,
|
||||||
|
09B4819423028A8A00D5B32B /* ThemeAccentColorControllerNode.swift */,
|
||||||
);
|
);
|
||||||
name = Themes;
|
name = Themes;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -4448,6 +4454,7 @@
|
|||||||
09DE2F292269D5E30045E975 /* PrivacyIntroControllerNode.swift in Sources */,
|
09DE2F292269D5E30045E975 /* PrivacyIntroControllerNode.swift in Sources */,
|
||||||
D0F67FF01EE6B8A8000E5906 /* ChannelMembersSearchController.swift in Sources */,
|
D0F67FF01EE6B8A8000E5906 /* ChannelMembersSearchController.swift in Sources */,
|
||||||
D0EC6DAF1EB9F58900EBF1C3 /* ChatInterfaceInputContexts.swift in Sources */,
|
D0EC6DAF1EB9F58900EBF1C3 /* ChatInterfaceInputContexts.swift in Sources */,
|
||||||
|
09B4819323028A4200D5B32B /* ThemeAccentColorController.swift in Sources */,
|
||||||
0921F60E228EE000001A13D7 /* ChatMessageActionUrlAuthController.swift in Sources */,
|
0921F60E228EE000001A13D7 /* ChatMessageActionUrlAuthController.swift in Sources */,
|
||||||
D0EC6DB01EB9F58900EBF1C3 /* ChatInterfaceInputContextPanels.swift in Sources */,
|
D0EC6DB01EB9F58900EBF1C3 /* ChatInterfaceInputContextPanels.swift in Sources */,
|
||||||
D0EC6DB11EB9F58900EBF1C3 /* ChatInterfaceInputNodes.swift in Sources */,
|
D0EC6DB11EB9F58900EBF1C3 /* ChatInterfaceInputNodes.swift in Sources */,
|
||||||
@ -4567,6 +4574,7 @@
|
|||||||
D00817CA22B47A14008A895F /* WatchRequestHandlers.swift in Sources */,
|
D00817CA22B47A14008A895F /* WatchRequestHandlers.swift in Sources */,
|
||||||
D00817E222B47A14008A895F /* UIImage+ImageEffects.m in Sources */,
|
D00817E222B47A14008A895F /* UIImage+ImageEffects.m in Sources */,
|
||||||
D007019C2029E8F2006B9E34 /* LegacyICloudFileController.swift in Sources */,
|
D007019C2029E8F2006B9E34 /* LegacyICloudFileController.swift in Sources */,
|
||||||
|
09B4819523028A8A00D5B32B /* ThemeAccentColorControllerNode.swift in Sources */,
|
||||||
D000CABC21F158AD0011B15D /* PrepareSecretThumbnailData.swift in Sources */,
|
D000CABC21F158AD0011B15D /* PrepareSecretThumbnailData.swift in Sources */,
|
||||||
D0208AD61FA33D14001F0D5F /* RaiseToListenActivator.m in Sources */,
|
D0208AD61FA33D14001F0D5F /* RaiseToListenActivator.m in Sources */,
|
||||||
D0AF798022C2E26500CECCB8 /* compress_block.cc in Sources */,
|
D0AF798022C2E26500CECCB8 /* compress_block.cc in Sources */,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user