Added icon for downloaded music

This commit is contained in:
Peter 2018-10-15 17:41:02 +03:00
parent d0911df3b8
commit 113428aa13
5 changed files with 42 additions and 15 deletions

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "phone.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

View File

@ -46,6 +46,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
private var streamingCacheStatusFrame: CGRect? private var streamingCacheStatusFrame: CGRect?
private var fileIconImage: UIImage? private var fileIconImage: UIImage?
private var cloudFetchIconImage: UIImage? private var cloudFetchIconImage: UIImage?
private var cloudFetchedIconImage: UIImage?
override init() { override init() {
self.titleNode = TextNode() self.titleNode = TextNode()
@ -322,14 +323,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
let streamingProgressDiameter: CGFloat = 28.0 let streamingProgressDiameter: CGFloat = 28.0
var hasStreamingProgress = false var hasStreamingProgress = false
if isAudio && !isVoice { if isAudio && !isVoice {
if let resourceStatus = currentResourceStatus { hasStreamingProgress = true
switch resourceStatus.fetchStatus {
case .Fetching, .Remote:
hasStreamingProgress = true
case .Local:
break
}
}
if hasStreamingProgress { if hasStreamingProgress {
textConstrainedSize.width -= streamingProgressDiameter + 4.0 textConstrainedSize.width -= streamingProgressDiameter + 4.0
@ -359,9 +353,11 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
} }
var cloudFetchIconImage: UIImage? var cloudFetchIconImage: UIImage?
var cloudFetchedIconImage: UIImage?
if hasStreamingProgress { if hasStreamingProgress {
minLayoutWidth += streamingProgressDiameter + 4.0 minLayoutWidth += streamingProgressDiameter + 4.0
cloudFetchIconImage = incoming ? PresentationResourcesChat.chatBubbleFileCloudFetchIncomingIcon(presentationData.theme.theme) : PresentationResourcesChat.chatBubbleFileCloudFetchOutgoingIcon(presentationData.theme.theme) 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? let fileIconImage: UIImage?
@ -431,7 +427,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
} }
if isAudio && !isVoice { 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 { if hasStreamingProgress {
fittedLayoutSize.width += streamingProgressDiameter + 6.0 fittedLayoutSize.width += streamingProgressDiameter + 6.0
} }
@ -531,7 +527,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
strongSelf.statusDisposable.set((updatedStatusSignal |> deliverOnMainQueue).start(next: { [weak strongSelf] status in strongSelf.statusDisposable.set((updatedStatusSignal |> deliverOnMainQueue).start(next: { [weak strongSelf] status in
displayLinkDispatcher.dispatch { displayLinkDispatcher.dispatch {
if let strongSelf = strongSelf { if let strongSelf = strongSelf {
var previousHadCacheStatus = false /*var previousHadCacheStatus = false
if let resourceStatus = strongSelf.resourceStatus { if let resourceStatus = strongSelf.resourceStatus {
switch resourceStatus.fetchStatus { switch resourceStatus.fetchStatus {
case .Fetching, .Remote: case .Fetching, .Remote:
@ -546,13 +542,13 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
hasCacheStatus = true hasCacheStatus = true
case .Local: case .Local:
hasCacheStatus = false hasCacheStatus = false
} }*/
strongSelf.resourceStatus = status strongSelf.resourceStatus = status
if isAudio && !isVoice && previousHadCacheStatus != hasCacheStatus { /*if isAudio && !isVoice && previousHadCacheStatus != hasCacheStatus {
strongSelf.requestUpdateLayout(false) strongSelf.requestUpdateLayout(false)
} else { } else {*/
strongSelf.updateStatus() strongSelf.updateStatus()
} //}
} }
} }
})) }))
@ -567,6 +563,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
strongSelf.streamingCacheStatusFrame = streamingCacheStatusFrame strongSelf.streamingCacheStatusFrame = streamingCacheStatusFrame
strongSelf.fileIconImage = fileIconImage strongSelf.fileIconImage = fileIconImage
strongSelf.cloudFetchIconImage = cloudFetchIconImage strongSelf.cloudFetchIconImage = cloudFetchIconImage
strongSelf.cloudFetchedIconImage = cloudFetchedIconImage
if let updatedFetchControls = updatedFetchControls { if let updatedFetchControls = updatedFetchControls {
let _ = strongSelf.fetchControls.swap(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)) streamingState = .cloudProgress(color: streamingStatusForegroundColor, strokeBackgroundColor: streamingStatusBackgroundColor, lineWidth: 2.0, value: CGFloat(adjustedProgress))
case .Local: case .Local:
streamingState = .none if let cloudFetchedIconImage = self.cloudFetchedIconImage {
streamingState = .customIcon(cloudFetchedIconImage)
} else {
streamingState = .none
}
case .Remote: case .Remote:
if let cloudFetchIconImage = self.cloudFetchIconImage { if let cloudFetchIconImage = self.cloudFetchIconImage {
streamingState = .customIcon(cloudFetchIconImage) streamingState = .customIcon(cloudFetchIconImage)

View File

@ -112,6 +112,8 @@ enum PresentationResourceKey: Int32 {
case chatBubbleFileCloudFetchIncomingIcon case chatBubbleFileCloudFetchIncomingIcon
case chatBubbleFileCloudFetchOutgoingIcon case chatBubbleFileCloudFetchOutgoingIcon
case chatBubbleFileCloudFetchedIncomingIcon
case chatBubbleFileCloudFetchedOutgoingIcon
case chatBubbleReplyThumbnailPlayImage case chatBubbleReplyThumbnailPlayImage

View File

@ -1023,4 +1023,16 @@ struct PresentationResourcesChat {
generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/FileCloudFetch"), color: theme.chat.bubble.outgoingAccentControlColor) 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)
})
}
} }