mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-22 05:24:29 +00:00
Various improvements
This commit is contained in:
parent
461c780517
commit
1fa4bd2267
@ -243,18 +243,21 @@ public final class RadialStatusNode: ASControlNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private let enableBlur: Bool
|
private let enableBlur: Bool
|
||||||
|
private let isPreview: Bool
|
||||||
|
|
||||||
public private(set) var state: RadialStatusNodeState = .none
|
public private(set) var state: RadialStatusNodeState = .none
|
||||||
|
|
||||||
|
private var staticBackgroundNode: ASImageNode?
|
||||||
private var backgroundNode: NavigationBackgroundNode?
|
private var backgroundNode: NavigationBackgroundNode?
|
||||||
private var currentBackgroundNodeColor: UIColor?
|
private var currentBackgroundNodeColor: UIColor?
|
||||||
|
|
||||||
private var contentNode: RadialStatusContentNode?
|
private var contentNode: RadialStatusContentNode?
|
||||||
private var nextContentNode: RadialStatusContentNode?
|
private var nextContentNode: RadialStatusContentNode?
|
||||||
|
|
||||||
public init(backgroundNodeColor: UIColor, enableBlur: Bool = false) {
|
public init(backgroundNodeColor: UIColor, enableBlur: Bool = false, isPreview: Bool = false) {
|
||||||
self.enableBlur = enableBlur
|
|
||||||
self.backgroundNodeColor = backgroundNodeColor
|
self.backgroundNodeColor = backgroundNodeColor
|
||||||
|
self.enableBlur = enableBlur
|
||||||
|
self.isPreview = isPreview
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
@ -325,6 +328,7 @@ public final class RadialStatusNode: ASControlNode {
|
|||||||
} else {
|
} else {
|
||||||
self.contentNode = node
|
self.contentNode = node
|
||||||
if let contentNode = self.contentNode {
|
if let contentNode = self.contentNode {
|
||||||
|
contentNode.displaysAsynchronously = self.displaysAsynchronously
|
||||||
contentNode.frame = self.bounds
|
contentNode.frame = self.bounds
|
||||||
contentNode.prepareAnimateIn(from: nil)
|
contentNode.prepareAnimateIn(from: nil)
|
||||||
self.addSubnode(contentNode)
|
self.addSubnode(contentNode)
|
||||||
@ -354,27 +358,40 @@ public final class RadialStatusNode: ASControlNode {
|
|||||||
|
|
||||||
if updated {
|
if updated {
|
||||||
if let color = color {
|
if let color = color {
|
||||||
if let backgroundNode = self.backgroundNode {
|
if self.isPreview {
|
||||||
backgroundNode.updateColor(color: color, transition: .immediate)
|
let backgroundNode: ASImageNode
|
||||||
self.currentBackgroundNodeColor = color
|
if let current = self.staticBackgroundNode {
|
||||||
|
backgroundNode = current
|
||||||
completion()
|
|
||||||
} else {
|
|
||||||
let backgroundNode = NavigationBackgroundNode(color: color, enableBlur: self.enableBlur)
|
|
||||||
self.currentBackgroundNodeColor = color
|
|
||||||
|
|
||||||
backgroundNode.frame = self.bounds
|
|
||||||
backgroundNode.update(size: backgroundNode.bounds.size, cornerRadius: backgroundNode.bounds.size.height / 2.0, transition: .immediate)
|
|
||||||
self.backgroundNode = backgroundNode
|
|
||||||
self.insertSubnode(backgroundNode, at: 0)
|
|
||||||
|
|
||||||
if animated {
|
|
||||||
backgroundNode.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2, removeOnCompletion: false)
|
|
||||||
backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, removeOnCompletion: false, completion: { _ in
|
|
||||||
completion()
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
|
backgroundNode = ASImageNode()
|
||||||
|
backgroundNode.image = generateFilledCircleImage(diameter: 50.0, color: self.backgroundNodeColor)
|
||||||
|
self.insertSubnode(backgroundNode, at: 0)
|
||||||
|
self.staticBackgroundNode = backgroundNode
|
||||||
|
}
|
||||||
|
backgroundNode.frame = self.bounds
|
||||||
|
} else {
|
||||||
|
if let backgroundNode = self.backgroundNode {
|
||||||
|
backgroundNode.updateColor(color: color, transition: .immediate)
|
||||||
|
self.currentBackgroundNodeColor = color
|
||||||
|
|
||||||
completion()
|
completion()
|
||||||
|
} else {
|
||||||
|
let backgroundNode = NavigationBackgroundNode(color: color, enableBlur: self.enableBlur)
|
||||||
|
self.currentBackgroundNodeColor = color
|
||||||
|
|
||||||
|
backgroundNode.frame = self.bounds
|
||||||
|
backgroundNode.update(size: backgroundNode.bounds.size, cornerRadius: backgroundNode.bounds.size.height / 2.0, transition: .immediate)
|
||||||
|
self.backgroundNode = backgroundNode
|
||||||
|
self.insertSubnode(backgroundNode, at: 0)
|
||||||
|
|
||||||
|
if animated {
|
||||||
|
backgroundNode.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2, removeOnCompletion: false)
|
||||||
|
backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, removeOnCompletion: false, completion: { _ in
|
||||||
|
completion()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
completion()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let backgroundNode = self.backgroundNode {
|
} else if let backgroundNode = self.backgroundNode {
|
||||||
|
@ -341,8 +341,8 @@ public final class PrincipalThemeEssentialGraphics {
|
|||||||
self.clockMediaMinImage = emptyImage
|
self.clockMediaMinImage = emptyImage
|
||||||
self.clockFreeFrameImage = emptyImage
|
self.clockFreeFrameImage = emptyImage
|
||||||
self.clockFreeMinImage = emptyImage
|
self.clockFreeMinImage = emptyImage
|
||||||
self.dateAndStatusMediaBackground = emptyImage
|
self.dateAndStatusMediaBackground = generateStretchableFilledCircleImage(diameter: 18.0, color: theme.message.mediaDateAndStatusFillColor)!
|
||||||
self.dateAndStatusFreeBackground = emptyImage
|
self.dateAndStatusFreeBackground = generateStretchableFilledCircleImage(diameter: 18.0, color: serviceColor.dateFillStatic)!
|
||||||
|
|
||||||
let impressionCountImage = UIImage(bundleImageName: "Chat/Message/ImpressionCount")!
|
let impressionCountImage = UIImage(bundleImageName: "Chat/Message/ImpressionCount")!
|
||||||
self.incomingDateAndStatusImpressionIcon = generateTintedImage(image: impressionCountImage, color: theme.message.incoming.secondaryTextColor)!
|
self.incomingDateAndStatusImpressionIcon = generateTintedImage(image: impressionCountImage, color: theme.message.incoming.secondaryTextColor)!
|
||||||
|
@ -2092,7 +2092,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
let statusSuggestedWidthAndContinue = mosaicStatusLayout(ChatMessageDateAndStatusNode.Arguments(
|
let statusSuggestedWidthAndContinue = mosaicStatusLayout(ChatMessageDateAndStatusNode.Arguments(
|
||||||
context: item.context,
|
context: item.context,
|
||||||
presentationData: item.presentationData,
|
presentationData: item.presentationData,
|
||||||
edited: edited,
|
edited: edited && !item.presentationData.isPreview,
|
||||||
impressionCount: viewCount,
|
impressionCount: viewCount,
|
||||||
dateText: dateText,
|
dateText: dateText,
|
||||||
type: statusType,
|
type: statusType,
|
||||||
|
@ -1225,7 +1225,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
|
|
||||||
if progressRequired {
|
if progressRequired {
|
||||||
if self.statusNode == nil {
|
if self.statusNode == nil {
|
||||||
let statusNode = RadialStatusNode(backgroundNodeColor: item.presentationData.theme.theme.chat.message.mediaOverlayControlColors.fillColor)
|
let statusNode = RadialStatusNode(backgroundNodeColor: item.presentationData.theme.theme.chat.message.mediaOverlayControlColors.fillColor, isPreview: item.presentationData.isPreview)
|
||||||
statusNode.displaysAsynchronously = !item.presentationData.isPreview
|
statusNode.displaysAsynchronously = !item.presentationData.isPreview
|
||||||
self.isUserInteractionEnabled = false
|
self.isUserInteractionEnabled = false
|
||||||
self.statusNode = statusNode
|
self.statusNode = statusNode
|
||||||
|
@ -1254,7 +1254,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
uploading = true
|
uploading = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.isVideo && !file.isVideoSticker && !isSecretMedia && automaticPlayback && !isStory && !uploading {
|
if file.isVideo && !file.isVideoSticker && !isSecretMedia && automaticPlayback && !isStory && !uploading && !presentationData.isPreview {
|
||||||
updateVideoFile = file
|
updateVideoFile = file
|
||||||
if hasCurrentVideoNode {
|
if hasCurrentVideoNode {
|
||||||
if let currentFile = currentMedia as? TelegramMediaFile {
|
if let currentFile = currentMedia as? TelegramMediaFile {
|
||||||
@ -1796,6 +1796,9 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if isPreview {
|
||||||
|
progressRequired = true
|
||||||
|
}
|
||||||
|
|
||||||
var radialStatusSize: CGFloat
|
var radialStatusSize: CGFloat
|
||||||
if isSecretMedia {
|
if isSecretMedia {
|
||||||
@ -1805,7 +1808,8 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
}
|
}
|
||||||
if progressRequired {
|
if progressRequired {
|
||||||
if self.statusNode == nil {
|
if self.statusNode == nil {
|
||||||
let statusNode = RadialStatusNode(backgroundNodeColor: theme.chat.message.mediaOverlayControlColors.fillColor)
|
let statusNode = RadialStatusNode(backgroundNodeColor: theme.chat.message.mediaOverlayControlColors.fillColor, isPreview: isPreview)
|
||||||
|
statusNode.displaysAsynchronously = !isPreview
|
||||||
let imageSize = self.imageNode.bounds.size
|
let imageSize = self.imageNode.bounds.size
|
||||||
statusNode.frame = CGRect(origin: CGPoint(x: floor(imageSize.width / 2.0 - radialStatusSize / 2.0), y: floor(imageSize.height / 2.0 - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize))
|
statusNode.frame = CGRect(origin: CGPoint(x: floor(imageSize.width / 2.0 - radialStatusSize / 2.0), y: floor(imageSize.height / 2.0 - radialStatusSize / 2.0)), size: CGSize(width: radialStatusSize, height: radialStatusSize))
|
||||||
self.statusNode = statusNode
|
self.statusNode = statusNode
|
||||||
@ -1893,6 +1897,10 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
automaticPlayback = false
|
automaticPlayback = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isPreview {
|
||||||
|
muted = false
|
||||||
|
}
|
||||||
|
|
||||||
if let actualFetchStatus = self.actualFetchStatus {
|
if let actualFetchStatus = self.actualFetchStatus {
|
||||||
if automaticPlayback || message.forwardInfo != nil {
|
if automaticPlayback || message.forwardInfo != nil {
|
||||||
fetchStatus = actualFetchStatus
|
fetchStatus = actualFetchStatus
|
||||||
@ -2069,6 +2077,9 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if isPreview {
|
||||||
|
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
|
}
|
||||||
|
|
||||||
if isSecretMedia {
|
if isSecretMedia {
|
||||||
let remainingTime: Int32?
|
let remainingTime: Int32?
|
||||||
@ -2119,12 +2130,11 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
})
|
})
|
||||||
statusNode.backgroundNodeColor = backgroundColor
|
statusNode.backgroundNodeColor = backgroundColor
|
||||||
}
|
}
|
||||||
if let badgeContent = badgeContent {
|
if var badgeContent = badgeContent {
|
||||||
if self.badgeNode == nil {
|
if self.badgeNode == nil {
|
||||||
let badgeNode = ChatMessageInteractiveMediaBadge()
|
let badgeNode = ChatMessageInteractiveMediaBadge()
|
||||||
if isPreview {
|
if isPreview {
|
||||||
badgeNode.durationNode.displaysAsynchronously = false
|
badgeNode.durationNode.displaysAsynchronously = false
|
||||||
badgeNode.sizeNode?.displaysAsynchronously = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var inset: CGFloat = 6.0
|
var inset: CGFloat = 6.0
|
||||||
@ -2149,6 +2159,12 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
|
|||||||
|
|
||||||
animated = false
|
animated = false
|
||||||
}
|
}
|
||||||
|
if isPreview {
|
||||||
|
mediaDownloadState = nil
|
||||||
|
if case let .mediaDownload(backgroundColor, foregroundColor, duration, _ ,_ , _) = badgeContent {
|
||||||
|
badgeContent = .text(inset: 0.0, backgroundColor: backgroundColor, foregroundColor: foregroundColor, text: NSAttributedString(string: duration), iconName: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
self.badgeNode?.update(theme: theme, content: badgeContent, mediaDownloadState: mediaDownloadState, animated: animated)
|
self.badgeNode?.update(theme: theme, content: badgeContent, mediaDownloadState: mediaDownloadState, animated: animated)
|
||||||
} else if let badgeNode = self.badgeNode {
|
} else if let badgeNode = self.badgeNode {
|
||||||
self.badgeNode = nil
|
self.badgeNode = nil
|
||||||
|
@ -83,7 +83,6 @@ public final class DrawingMessageRenderer {
|
|||||||
private let containerNode: ASDisplayNode
|
private let containerNode: ASDisplayNode
|
||||||
|
|
||||||
private let messagesContainerNode: ASDisplayNode
|
private let messagesContainerNode: ASDisplayNode
|
||||||
private var dateHeaderNode: ListViewItemHeaderNode?
|
|
||||||
private var avatarHeaderNode: ListViewItemHeaderNode?
|
private var avatarHeaderNode: ListViewItemHeaderNode?
|
||||||
private var messageNodes: [ListViewItemNode]?
|
private var messageNodes: [ListViewItemNode]?
|
||||||
|
|
||||||
@ -156,7 +155,6 @@ public final class DrawingMessageRenderer {
|
|||||||
let size = layout.size
|
let size = layout.size
|
||||||
|
|
||||||
let theme = presentationData.theme.withUpdated(preview: true)
|
let theme = presentationData.theme.withUpdated(preview: true)
|
||||||
let dateHeaderItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: presentationData.chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder)
|
|
||||||
|
|
||||||
let avatarHeaderItem = self.context.sharedContext.makeChatMessageAvatarHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, peer: self.messages.first!.peers[self.messages.first!.author!.id]!, message: self.messages.first!, theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: presentationData.chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder)
|
let avatarHeaderItem = self.context.sharedContext.makeChatMessageAvatarHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, peer: self.messages.first!.peers[self.messages.first!.author!.id]!, message: self.messages.first!, theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: presentationData.chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder)
|
||||||
|
|
||||||
@ -235,17 +233,6 @@ public final class DrawingMessageRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dateHeaderNode: ListViewItemHeaderNode
|
|
||||||
if let currentDateHeaderNode = self.dateHeaderNode {
|
|
||||||
dateHeaderNode = currentDateHeaderNode
|
|
||||||
dateHeaderItem.updateNode(dateHeaderNode, previous: nil, next: dateHeaderItem)
|
|
||||||
} else {
|
|
||||||
dateHeaderNode = dateHeaderItem.node(synchronousLoad: true)
|
|
||||||
dateHeaderNode.subnodeTransform = CATransform3DMakeScale(-1.0, 1.0, 1.0)
|
|
||||||
// self.messagesContainerNode.addSubnode(dateHeaderNode)
|
|
||||||
self.dateHeaderNode = dateHeaderNode
|
|
||||||
}
|
|
||||||
|
|
||||||
let avatarHeaderNode: ListViewItemHeaderNode
|
let avatarHeaderNode: ListViewItemHeaderNode
|
||||||
if let currentAvatarHeaderNode = self.avatarHeaderNode {
|
if let currentAvatarHeaderNode = self.avatarHeaderNode {
|
||||||
avatarHeaderNode = currentAvatarHeaderNode
|
avatarHeaderNode = currentAvatarHeaderNode
|
||||||
@ -257,9 +244,6 @@ public final class DrawingMessageRenderer {
|
|||||||
self.avatarHeaderNode = avatarHeaderNode
|
self.avatarHeaderNode = avatarHeaderNode
|
||||||
}
|
}
|
||||||
|
|
||||||
dateHeaderNode.frame = CGRect(origin: CGPoint(x: 0.0, y: bottomOffset), size: CGSize(width: layout.size.width, height: dateHeaderItem.height))
|
|
||||||
dateHeaderNode.updateLayout(size: size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right)
|
|
||||||
|
|
||||||
avatarHeaderNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 3.0), size: CGSize(width: layout.size.width, height: avatarHeaderItem.height))
|
avatarHeaderNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 3.0), size: CGSize(width: layout.size.width, height: avatarHeaderItem.height))
|
||||||
avatarHeaderNode.updateLayout(size: size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right)
|
avatarHeaderNode.updateLayout(size: size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user