mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
[WIP] Saved messages
This commit is contained in:
@@ -47,9 +47,13 @@ public final class ChatMessageDateHeader: ListViewItemHeader {
|
||||
self.action = action
|
||||
self.roundedTimestamp = dateHeaderTimestampId(timestamp: timestamp)
|
||||
self.id = ListViewItemNode.HeaderId(space: 0, id: Int64(self.roundedTimestamp))
|
||||
|
||||
let isRotated = controllerInteraction?.chatIsRotated ?? true
|
||||
|
||||
self.stickDirection = isRotated ? .bottom : .top
|
||||
}
|
||||
|
||||
public let stickDirection: ListViewItemHeaderStickDirection = .bottom
|
||||
public let stickDirection: ListViewItemHeaderStickDirection
|
||||
public let stickOverInsets: Bool = true
|
||||
|
||||
public let height: CGFloat = 34.0
|
||||
@@ -191,9 +195,13 @@ public final class ChatMessageDateHeaderNode: ListViewItemHeaderNode {
|
||||
}
|
||||
self.text = text
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: true, isRotated: true, seeThrough: false)
|
||||
let isRotated = controllerInteraction?.chatIsRotated ?? true
|
||||
|
||||
self.transform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||
super.init(layerBacked: false, dynamicBounce: true, isRotated: isRotated, seeThrough: false)
|
||||
|
||||
if isRotated {
|
||||
self.transform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||
}
|
||||
|
||||
let graphics = PresentationResourcesChat.principalGraphics(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper, bubbleCorners: presentationData.chatBubbleCorners)
|
||||
|
||||
@@ -398,9 +406,13 @@ public final class ChatMessageAvatarHeader: ListViewItemHeader {
|
||||
self.controllerInteraction = controllerInteraction
|
||||
self.id = ListViewItemNode.HeaderId(space: 1, id: Id(peerId: peerId, timestampId: dateHeaderTimestampId(timestamp: timestamp)))
|
||||
self.storyStats = storyStats
|
||||
|
||||
let isRotated = controllerInteraction?.chatIsRotated ?? true
|
||||
|
||||
self.stickDirection = isRotated ? .top : .bottom
|
||||
}
|
||||
|
||||
public let stickDirection: ListViewItemHeaderStickDirection = .top
|
||||
public let stickDirection: ListViewItemHeaderStickDirection
|
||||
public let stickOverInsets: Bool = false
|
||||
|
||||
public let height: CGFloat = 38.0
|
||||
@@ -484,9 +496,13 @@ public final class ChatMessageAvatarHeaderNodeImpl: ListViewItemHeaderNode, Chat
|
||||
self.avatarNode = AvatarNode(font: avatarFont)
|
||||
self.avatarNode.contentNode.displaysAsynchronously = !presentationData.isPreview
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: true, isRotated: true, seeThrough: false)
|
||||
let isRotated = controllerInteraction?.chatIsRotated ?? true
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: true, isRotated: isRotated, seeThrough: false)
|
||||
|
||||
self.transform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||
if isRotated {
|
||||
self.transform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||
}
|
||||
|
||||
self.addSubnode(self.containerNode)
|
||||
self.containerNode.addSubnode(self.avatarNode)
|
||||
|
||||
@@ -259,7 +259,7 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
|
||||
self.associatedData = associatedData
|
||||
self.controllerInteraction = controllerInteraction
|
||||
self.content = content
|
||||
self.disableDate = disableDate
|
||||
self.disableDate = disableDate || !controllerInteraction.chatIsRotated
|
||||
self.additionalContent = additionalContent
|
||||
|
||||
var avatarHeader: ChatMessageAvatarHeader?
|
||||
@@ -369,6 +369,9 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
|
||||
if case .messageOptions = associatedData.subject {
|
||||
headers = []
|
||||
}
|
||||
if !controllerInteraction.chatIsRotated {
|
||||
headers = []
|
||||
}
|
||||
if let avatarHeader = self.avatarHeader {
|
||||
headers.append(avatarHeader)
|
||||
}
|
||||
@@ -450,11 +453,11 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
|
||||
}
|
||||
|
||||
let configure = {
|
||||
let node = (viewClassName as! ChatMessageItemView.Type).init()
|
||||
let node = (viewClassName as! ChatMessageItemView.Type).init(rotated: self.controllerInteraction.chatIsRotated)
|
||||
node.setupItem(self, synchronousLoad: synchronousLoads)
|
||||
|
||||
let nodeLayout = node.asyncLayout()
|
||||
let (top, bottom, dateAtBottom) = self.mergedWithItems(top: previousItem, bottom: nextItem)
|
||||
let (top, bottom, dateAtBottom) = self.mergedWithItems(top: previousItem, bottom: nextItem, isRotated: self.controllerInteraction.chatIsRotated)
|
||||
|
||||
var disableDate = self.disableDate
|
||||
if let subject = self.associatedData.subject, case let .messageOptions(_, _, info) = subject {
|
||||
@@ -490,7 +493,15 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
|
||||
}
|
||||
}
|
||||
|
||||
public func mergedWithItems(top: ListViewItem?, bottom: ListViewItem?) -> (top: ChatMessageMerge, bottom: ChatMessageMerge, dateAtBottom: Bool) {
|
||||
public func mergedWithItems(top: ListViewItem?, bottom: ListViewItem?, isRotated: Bool) -> (top: ChatMessageMerge, bottom: ChatMessageMerge, dateAtBottom: Bool) {
|
||||
var top = top
|
||||
var bottom = bottom
|
||||
if !isRotated {
|
||||
let previousTop = top
|
||||
top = bottom
|
||||
bottom = previousTop
|
||||
}
|
||||
|
||||
var mergedTop: ChatMessageMerge = .none
|
||||
var mergedBottom: ChatMessageMerge = .none
|
||||
var dateAtBottom = false
|
||||
@@ -530,8 +541,10 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
|
||||
|
||||
let nodeLayout = nodeValue.asyncLayout()
|
||||
|
||||
let isRotated = self.controllerInteraction.chatIsRotated
|
||||
|
||||
async {
|
||||
let (top, bottom, dateAtBottom) = self.mergedWithItems(top: previousItem, bottom: nextItem)
|
||||
let (top, bottom, dateAtBottom) = self.mergedWithItems(top: previousItem, bottom: nextItem, isRotated: isRotated)
|
||||
|
||||
var disableDate = self.disableDate
|
||||
if let subject = self.associatedData.subject, case let .messageOptions(_, _, info) = subject {
|
||||
|
||||
Reference in New Issue
Block a user