diff --git a/Images.xcassets/Chat/Message/FileCloudFetched.imageset/Contents.json b/Images.xcassets/Chat/Message/FileCloudFetched.imageset/Contents.json new file mode 100644 index 0000000000..70484f8552 --- /dev/null +++ b/Images.xcassets/Chat/Message/FileCloudFetched.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "phone.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/Chat/Message/FileCloudFetched.imageset/phone.pdf b/Images.xcassets/Chat/Message/FileCloudFetched.imageset/phone.pdf new file mode 100644 index 0000000000..8aef36688b Binary files /dev/null and b/Images.xcassets/Chat/Message/FileCloudFetched.imageset/phone.pdf differ diff --git a/TelegramUI/ChatMessageInteractiveFileNode.swift b/TelegramUI/ChatMessageInteractiveFileNode.swift index a80593dc5c..a695098d5e 100644 --- a/TelegramUI/ChatMessageInteractiveFileNode.swift +++ b/TelegramUI/ChatMessageInteractiveFileNode.swift @@ -46,6 +46,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { private var streamingCacheStatusFrame: CGRect? private var fileIconImage: UIImage? private var cloudFetchIconImage: UIImage? + private var cloudFetchedIconImage: UIImage? override init() { self.titleNode = TextNode() @@ -322,14 +323,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { let streamingProgressDiameter: CGFloat = 28.0 var hasStreamingProgress = false if isAudio && !isVoice { - if let resourceStatus = currentResourceStatus { - switch resourceStatus.fetchStatus { - case .Fetching, .Remote: - hasStreamingProgress = true - case .Local: - break - } - } + hasStreamingProgress = true if hasStreamingProgress { textConstrainedSize.width -= streamingProgressDiameter + 4.0 @@ -359,9 +353,11 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { } var cloudFetchIconImage: UIImage? + var cloudFetchedIconImage: UIImage? if hasStreamingProgress { minLayoutWidth += streamingProgressDiameter + 4.0 cloudFetchIconImage = incoming ? PresentationResourcesChat.chatBubbleFileCloudFetchIncomingIcon(presentationData.theme.theme) : PresentationResourcesChat.chatBubbleFileCloudFetchOutgoingIcon(presentationData.theme.theme) + cloudFetchedIconImage = incoming ? PresentationResourcesChat.chatBubbleFileCloudFetchedIncomingIcon(presentationData.theme.theme) : PresentationResourcesChat.chatBubbleFileCloudFetchedOutgoingIcon(presentationData.theme.theme) } let fileIconImage: UIImage? @@ -431,7 +427,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { } if isAudio && !isVoice { - streamingCacheStatusFrame = CGRect(origin: CGPoint(x: fittedLayoutSize.width + 6.0, y: 4.0), size: CGSize(width: streamingProgressDiameter, height: streamingProgressDiameter)) + streamingCacheStatusFrame = CGRect(origin: CGPoint(x: fittedLayoutSize.width + 6.0, y: 8.0), size: CGSize(width: streamingProgressDiameter, height: streamingProgressDiameter)) if hasStreamingProgress { fittedLayoutSize.width += streamingProgressDiameter + 6.0 } @@ -531,7 +527,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { strongSelf.statusDisposable.set((updatedStatusSignal |> deliverOnMainQueue).start(next: { [weak strongSelf] status in displayLinkDispatcher.dispatch { if let strongSelf = strongSelf { - var previousHadCacheStatus = false + /*var previousHadCacheStatus = false if let resourceStatus = strongSelf.resourceStatus { switch resourceStatus.fetchStatus { case .Fetching, .Remote: @@ -546,13 +542,13 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { hasCacheStatus = true case .Local: hasCacheStatus = false - } + }*/ strongSelf.resourceStatus = status - if isAudio && !isVoice && previousHadCacheStatus != hasCacheStatus { + /*if isAudio && !isVoice && previousHadCacheStatus != hasCacheStatus { strongSelf.requestUpdateLayout(false) - } else { + } else {*/ strongSelf.updateStatus() - } + //} } } })) @@ -567,6 +563,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { strongSelf.streamingCacheStatusFrame = streamingCacheStatusFrame strongSelf.fileIconImage = fileIconImage strongSelf.cloudFetchIconImage = cloudFetchIconImage + strongSelf.cloudFetchedIconImage = cloudFetchedIconImage if let updatedFetchControls = updatedFetchControls { let _ = strongSelf.fetchControls.swap(updatedFetchControls) @@ -632,7 +629,11 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { } streamingState = .cloudProgress(color: streamingStatusForegroundColor, strokeBackgroundColor: streamingStatusBackgroundColor, lineWidth: 2.0, value: CGFloat(adjustedProgress)) case .Local: - streamingState = .none + if let cloudFetchedIconImage = self.cloudFetchedIconImage { + streamingState = .customIcon(cloudFetchedIconImage) + } else { + streamingState = .none + } case .Remote: if let cloudFetchIconImage = self.cloudFetchIconImage { streamingState = .customIcon(cloudFetchIconImage) diff --git a/TelegramUI/PresentationResourceKey.swift b/TelegramUI/PresentationResourceKey.swift index f306ec92c9..2b6616617e 100644 --- a/TelegramUI/PresentationResourceKey.swift +++ b/TelegramUI/PresentationResourceKey.swift @@ -112,6 +112,8 @@ enum PresentationResourceKey: Int32 { case chatBubbleFileCloudFetchIncomingIcon case chatBubbleFileCloudFetchOutgoingIcon + case chatBubbleFileCloudFetchedIncomingIcon + case chatBubbleFileCloudFetchedOutgoingIcon case chatBubbleReplyThumbnailPlayImage diff --git a/TelegramUI/PresentationResourcesChat.swift b/TelegramUI/PresentationResourcesChat.swift index 6f1fc9b850..9c25036f3d 100644 --- a/TelegramUI/PresentationResourcesChat.swift +++ b/TelegramUI/PresentationResourcesChat.swift @@ -1023,4 +1023,16 @@ struct PresentationResourcesChat { generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/FileCloudFetch"), color: theme.chat.bubble.outgoingAccentControlColor) }) } + + static func chatBubbleFileCloudFetchedIncomingIcon(_ theme: PresentationTheme) -> UIImage? { + return theme.image(PresentationResourceKey.chatBubbleFileCloudFetchedIncomingIcon.rawValue, { theme in + generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/FileCloudFetched"), color: theme.chat.bubble.incomingAccentControlColor) + }) + } + + static func chatBubbleFileCloudFetchedOutgoingIcon(_ theme: PresentationTheme) -> UIImage? { + return theme.image(PresentationResourceKey.chatBubbleFileCloudFetchedOutgoingIcon.rawValue, { theme in + generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/FileCloudFetched"), color: theme.chat.bubble.outgoingAccentControlColor) + }) + } }