mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-06 14:25:04 +00:00
Fix UI
This commit is contained in:
parent
4cbf51364e
commit
4d6dfa5204
@ -361,7 +361,7 @@ private final class ChatListMediaPreviewNode: ASDisplayNode {
|
|||||||
dimensions = largest.dimensions.cgSize
|
dimensions = largest.dimensions.cgSize
|
||||||
if !self.requestedImage {
|
if !self.requestedImage {
|
||||||
self.requestedImage = true
|
self.requestedImage = true
|
||||||
let signal = mediaGridMessagePhoto(account: self.context.account, photoReference: .message(message: MessageReference(self.message), media: image), synchronousLoad: synchronousLoads)
|
let signal = mediaGridMessagePhoto(account: self.context.account, photoReference: .message(message: MessageReference(self.message), media: image), fullRepresentationSize: CGSize(width: 36.0, height: 36.0), synchronousLoad: synchronousLoads)
|
||||||
self.imageNode.setSignal(signal, attemptSynchronously: synchronousLoads)
|
self.imageNode.setSignal(signal, attemptSynchronously: synchronousLoads)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ private final class ChatListMediaPreviewNode: ASDisplayNode {
|
|||||||
dimensions = mediaDimensions.cgSize
|
dimensions = mediaDimensions.cgSize
|
||||||
if !self.requestedImage {
|
if !self.requestedImage {
|
||||||
self.requestedImage = true
|
self.requestedImage = true
|
||||||
let signal = mediaGridMessageVideo(postbox: self.context.account.postbox, videoReference: .message(message: MessageReference(self.message), media: file), synchronousLoad: synchronousLoads, autoFetchFullSizeThumbnail: true)
|
let signal = mediaGridMessageVideo(postbox: self.context.account.postbox, videoReference: .message(message: MessageReference(self.message), media: file), synchronousLoad: synchronousLoads, autoFetchFullSizeThumbnail: true, useMiniThumbnailIfAvailable: true)
|
||||||
self.imageNode.setSignal(signal, attemptSynchronously: synchronousLoads)
|
self.imageNode.setSignal(signal, attemptSynchronously: synchronousLoads)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -986,6 +986,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
} else if let _ = message.peers[message.id.peerId] as? TelegramSecretChat {
|
} else if let _ = message.peers[message.id.peerId] as? TelegramSecretChat {
|
||||||
displayMediaPreviews = false
|
displayMediaPreviews = false
|
||||||
}
|
}
|
||||||
|
if !item.context.sharedContext.immediateExperimentalUISettings.chatListPhotos {
|
||||||
|
displayMediaPreviews = false
|
||||||
|
}
|
||||||
if displayMediaPreviews {
|
if displayMediaPreviews {
|
||||||
let contentImageFillSize = CGSize(width: 8.0, height: contentImageSize.height)
|
let contentImageFillSize = CGSize(width: 8.0, height: contentImageSize.height)
|
||||||
_ = contentImageFillSize
|
_ = contentImageFillSize
|
||||||
|
|||||||
@ -27,16 +27,20 @@ public func largestRepresentationForPhoto(_ photo: TelegramMediaImage) -> Telegr
|
|||||||
return photo.representationForDisplayAtSize(PixelDimensions(width: 1280, height: 1280))
|
return photo.representationForDisplayAtSize(PixelDimensions(width: 1280, height: 1280))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func chatMessagePhotoDatas(postbox: Postbox, photoReference: ImageMediaReference, fullRepresentationSize: CGSize = CGSize(width: 1280.0, height: 1280.0), autoFetchFullSize: Bool = false, tryAdditionalRepresentations: Bool = false, synchronousLoad: Bool = false) -> Signal<Tuple4<Data?, Data?, ChatMessagePhotoQuality, Bool>, NoError> {
|
public func chatMessagePhotoDatas(postbox: Postbox, photoReference: ImageMediaReference, fullRepresentationSize: CGSize = CGSize(width: 1280.0, height: 1280.0), autoFetchFullSize: Bool = false, tryAdditionalRepresentations: Bool = false, synchronousLoad: Bool = false, useMiniThumbnailIfAvailable: Bool = false) -> Signal<Tuple4<Data?, Data?, ChatMessagePhotoQuality, Bool>, NoError> {
|
||||||
if let smallestRepresentation = smallestImageRepresentation(photoReference.media.representations), let largestRepresentation = photoReference.media.representationForDisplayAtSize(PixelDimensions(width: Int32(fullRepresentationSize.width), height: Int32(fullRepresentationSize.height))) {
|
if let smallestRepresentation = smallestImageRepresentation(photoReference.media.representations), let largestRepresentation = photoReference.media.representationForDisplayAtSize(PixelDimensions(width: Int32(fullRepresentationSize.width), height: Int32(fullRepresentationSize.height))), let fullRepresentation = largestImageRepresentation(photoReference.media.representations) {
|
||||||
let maybeFullSize = postbox.mediaBox.resourceData(largestRepresentation.resource, option: .complete(waitUntilFetchStatus: false), attemptSynchronously: synchronousLoad)
|
let maybeFullSize = postbox.mediaBox.resourceData(largestRepresentation.resource, option: .complete(waitUntilFetchStatus: false), attemptSynchronously: synchronousLoad)
|
||||||
|
let maybeLargestSize = postbox.mediaBox.resourceData(fullRepresentation.resource, option: .complete(waitUntilFetchStatus: false), attemptSynchronously: synchronousLoad)
|
||||||
|
|
||||||
let signal = maybeFullSize
|
let signal = combineLatest(maybeFullSize, maybeLargestSize)
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> mapToSignal { maybeData -> Signal<Tuple4<Data?, Data?, ChatMessagePhotoQuality, Bool>, NoError> in
|
|> mapToSignal { maybeData, maybeLargestData -> Signal<Tuple4<Data?, Data?, ChatMessagePhotoQuality, Bool>, NoError> in
|
||||||
if maybeData.complete {
|
if maybeData.complete {
|
||||||
let loadedData: Data? = try? Data(contentsOf: URL(fileURLWithPath: maybeData.path), options: [])
|
let loadedData: Data? = try? Data(contentsOf: URL(fileURLWithPath: maybeData.path), options: [])
|
||||||
return .single(Tuple(nil, loadedData, .full, true))
|
return .single(Tuple(nil, loadedData, .full, true))
|
||||||
|
} else if maybeLargestData.complete {
|
||||||
|
let loadedData: Data? = try? Data(contentsOf: URL(fileURLWithPath: maybeLargestData.path), options: [])
|
||||||
|
return .single(Tuple(nil, loadedData, .full, true))
|
||||||
} else {
|
} else {
|
||||||
let decodedThumbnailData = photoReference.media.immediateThumbnailData.flatMap(decodeTinyThumbnail)
|
let decodedThumbnailData = photoReference.media.immediateThumbnailData.flatMap(decodeTinyThumbnail)
|
||||||
let fetchedThumbnail: Signal<FetchResourceSourceType, FetchResourceError>
|
let fetchedThumbnail: Signal<FetchResourceSourceType, FetchResourceError>
|
||||||
@ -99,7 +103,7 @@ public func chatMessagePhotoDatas(postbox: Postbox, photoReference: ImageMediaRe
|
|||||||
|
|
||||||
let fullSizeData: Signal<Tuple2<Data?, Bool>, NoError>
|
let fullSizeData: Signal<Tuple2<Data?, Bool>, NoError>
|
||||||
|
|
||||||
if autoFetchFullSize {
|
if autoFetchFullSize && !useMiniThumbnailIfAvailable {
|
||||||
fullSizeData = Signal<Tuple2<Data?, Bool>, NoError> { subscriber in
|
fullSizeData = Signal<Tuple2<Data?, Bool>, NoError> { subscriber in
|
||||||
let fetchedFullSizeDisposable = fetchedFullSize.start()
|
let fetchedFullSizeDisposable = fetchedFullSize.start()
|
||||||
let fullSizeDisposable = postbox.mediaBox.resourceData(largestRepresentation.resource, option: .complete(waitUntilFetchStatus: false), attemptSynchronously: synchronousLoad).start(next: { next in
|
let fullSizeDisposable = postbox.mediaBox.resourceData(largestRepresentation.resource, option: .complete(waitUntilFetchStatus: false), attemptSynchronously: synchronousLoad).start(next: { next in
|
||||||
@ -1152,7 +1156,8 @@ public func avatarGalleryThumbnailPhoto(account: Account, representations: [Imag
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func mediaGridMessagePhoto(account: Account, photoReference: ImageMediaReference, fullRepresentationSize: CGSize = CGSize(width: 127.0, height: 127.0), synchronousLoad: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
public func mediaGridMessagePhoto(account: Account, photoReference: ImageMediaReference, fullRepresentationSize: CGSize = CGSize(width: 127.0, height: 127.0), synchronousLoad: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
||||||
let signal = chatMessagePhotoDatas(postbox: account.postbox, photoReference: photoReference, fullRepresentationSize: fullRepresentationSize, autoFetchFullSize: true, synchronousLoad: synchronousLoad)
|
let useMiniThumbnailIfAvailable: Bool = fullRepresentationSize.width < 40.0
|
||||||
|
let signal = chatMessagePhotoDatas(postbox: account.postbox, photoReference: photoReference, fullRepresentationSize: fullRepresentationSize, autoFetchFullSize: true, tryAdditionalRepresentations: useMiniThumbnailIfAvailable, synchronousLoad: synchronousLoad, useMiniThumbnailIfAvailable: useMiniThumbnailIfAvailable)
|
||||||
|
|
||||||
return signal
|
return signal
|
||||||
|> map { value in
|
|> map { value in
|
||||||
@ -1197,6 +1202,9 @@ public func mediaGridMessagePhoto(account: Account, photoReference: ImageMediaRe
|
|||||||
|
|
||||||
var blurredThumbnailImage: UIImage?
|
var blurredThumbnailImage: UIImage?
|
||||||
if let thumbnailImage = thumbnailImage {
|
if let thumbnailImage = thumbnailImage {
|
||||||
|
if useMiniThumbnailIfAvailable {
|
||||||
|
blurredThumbnailImage = UIImage(cgImage: thumbnailImage)
|
||||||
|
} else {
|
||||||
let thumbnailSize = CGSize(width: thumbnailImage.width, height: thumbnailImage.height)
|
let thumbnailSize = CGSize(width: thumbnailImage.width, height: thumbnailImage.height)
|
||||||
let thumbnailContextSize = thumbnailSize.aspectFilled(CGSize(width: 90.0, height: 90.0))
|
let thumbnailContextSize = thumbnailSize.aspectFilled(CGSize(width: 90.0, height: 90.0))
|
||||||
let thumbnailContext = DrawingContext(size: thumbnailContextSize, scale: 1.0)
|
let thumbnailContext = DrawingContext(size: thumbnailContextSize, scale: 1.0)
|
||||||
@ -1204,10 +1212,13 @@ public func mediaGridMessagePhoto(account: Account, photoReference: ImageMediaRe
|
|||||||
c.interpolationQuality = .none
|
c.interpolationQuality = .none
|
||||||
c.draw(thumbnailImage, in: CGRect(origin: CGPoint(), size: thumbnailContextSize))
|
c.draw(thumbnailImage, in: CGRect(origin: CGPoint(), size: thumbnailContextSize))
|
||||||
}
|
}
|
||||||
|
if !useMiniThumbnailIfAvailable {
|
||||||
telegramFastBlurMore(Int32(thumbnailContextSize.width), Int32(thumbnailContextSize.height), Int32(thumbnailContext.bytesPerRow), thumbnailContext.bytes)
|
telegramFastBlurMore(Int32(thumbnailContextSize.width), Int32(thumbnailContextSize.height), Int32(thumbnailContext.bytesPerRow), thumbnailContext.bytes)
|
||||||
|
}
|
||||||
|
|
||||||
blurredThumbnailImage = thumbnailContext.generateImage()
|
blurredThumbnailImage = thumbnailContext.generateImage()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context.withFlippedContext { c in
|
context.withFlippedContext { c in
|
||||||
c.setBlendMode(.copy)
|
c.setBlendMode(.copy)
|
||||||
@ -1305,14 +1316,14 @@ public func gifPaneVideoThumbnail(account: Account, videoReference: FileMediaRef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func mediaGridMessageVideo(postbox: Postbox, videoReference: FileMediaReference, onlyFullSize: Bool = false, synchronousLoad: Bool = false, autoFetchFullSizeThumbnail: Bool = false, overlayColor: UIColor? = nil, nilForEmptyResult: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
public func mediaGridMessageVideo(postbox: Postbox, videoReference: FileMediaReference, onlyFullSize: Bool = false, synchronousLoad: Bool = false, autoFetchFullSizeThumbnail: Bool = false, overlayColor: UIColor? = nil, nilForEmptyResult: Bool = false, useMiniThumbnailIfAvailable: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
||||||
return internalMediaGridMessageVideo(postbox: postbox, videoReference: videoReference, onlyFullSize: onlyFullSize, synchronousLoad: synchronousLoad, autoFetchFullSizeThumbnail: autoFetchFullSizeThumbnail, overlayColor: overlayColor, nilForEmptyResult: nilForEmptyResult)
|
return internalMediaGridMessageVideo(postbox: postbox, videoReference: videoReference, onlyFullSize: onlyFullSize, synchronousLoad: synchronousLoad, autoFetchFullSizeThumbnail: autoFetchFullSizeThumbnail, overlayColor: overlayColor, nilForEmptyResult: nilForEmptyResult, useMiniThumbnailIfAvailable: useMiniThumbnailIfAvailable)
|
||||||
|> map {
|
|> map {
|
||||||
return $0.1
|
return $0.1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func internalMediaGridMessageVideo(postbox: Postbox, videoReference: FileMediaReference, imageReference: ImageMediaReference? = nil, onlyFullSize: Bool = false, synchronousLoad: Bool = false, autoFetchFullSizeThumbnail: Bool = false, overlayColor: UIColor? = nil, nilForEmptyResult: Bool = false) -> Signal<(() -> CGSize?, (TransformImageArguments) -> DrawingContext?), NoError> {
|
public func internalMediaGridMessageVideo(postbox: Postbox, videoReference: FileMediaReference, imageReference: ImageMediaReference? = nil, onlyFullSize: Bool = false, synchronousLoad: Bool = false, autoFetchFullSizeThumbnail: Bool = false, overlayColor: UIColor? = nil, nilForEmptyResult: Bool = false, useMiniThumbnailIfAvailable: Bool = false) -> Signal<(() -> CGSize?, (TransformImageArguments) -> DrawingContext?), NoError> {
|
||||||
let signal: Signal<Tuple3<Data?, Tuple2<Data, String>?, Bool>, NoError>
|
let signal: Signal<Tuple3<Data?, Tuple2<Data, String>?, Bool>, NoError>
|
||||||
if let imageReference = imageReference {
|
if let imageReference = imageReference {
|
||||||
signal = chatMessagePhotoDatas(postbox: postbox, photoReference: imageReference, tryAdditionalRepresentations: true, synchronousLoad: synchronousLoad)
|
signal = chatMessagePhotoDatas(postbox: postbox, photoReference: imageReference, tryAdditionalRepresentations: true, synchronousLoad: synchronousLoad)
|
||||||
@ -1398,7 +1409,7 @@ public func internalMediaGridMessageVideo(postbox: Postbox, videoReference: File
|
|||||||
|
|
||||||
var blurredThumbnailImage: UIImage?
|
var blurredThumbnailImage: UIImage?
|
||||||
if let thumbnailImage = thumbnailImage {
|
if let thumbnailImage = thumbnailImage {
|
||||||
if max(thumbnailImage.width, thumbnailImage.height) > Int(min(200.0, min(drawingSize.width, drawingSize.height))) {
|
if max(thumbnailImage.width, thumbnailImage.height) > Int(min(200.0, min(drawingSize.width, drawingSize.height))) || useMiniThumbnailIfAvailable {
|
||||||
blurredThumbnailImage = UIImage(cgImage: thumbnailImage)
|
blurredThumbnailImage = UIImage(cgImage: thumbnailImage)
|
||||||
} else {
|
} else {
|
||||||
let thumbnailSize = CGSize(width: thumbnailImage.width, height: thumbnailImage.height)
|
let thumbnailSize = CGSize(width: thumbnailImage.width, height: thumbnailImage.height)
|
||||||
|
|||||||
@ -3006,9 +3006,11 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
|||||||
return $0.0 < $1.0
|
return $0.0 < $1.0
|
||||||
}).map({ $0.1 })
|
}).map({ $0.1 })
|
||||||
for file in gifFiles {
|
for file in gifFiles {
|
||||||
|
if !file.hasLinkedStickers {
|
||||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentGifs, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 200)
|
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentGifs, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for groupId in invalidateGroupStats {
|
for groupId in invalidateGroupStats {
|
||||||
transaction.setNeedsPeerGroupMessageStatsSynchronization(groupId: groupId, namespace: Namespaces.Message.Cloud)
|
transaction.setNeedsPeerGroupMessageStatsSynchronization(groupId: groupId, namespace: Namespaces.Message.Cloud)
|
||||||
|
|||||||
@ -218,8 +218,10 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
|
|||||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20)
|
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20)
|
||||||
}
|
}
|
||||||
for file in sentGifs {
|
for file in sentGifs {
|
||||||
|
if !file.hasLinkedStickers {
|
||||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentGifs, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 200)
|
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentGifs, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 200)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stateManager.addUpdates(result)
|
stateManager.addUpdates(result)
|
||||||
stateManager.addUpdateGroups([.ensurePeerHasLocalState(id: message.id.peerId)])
|
stateManager.addUpdateGroups([.ensurePeerHasLocalState(id: message.id.peerId)])
|
||||||
@ -356,8 +358,10 @@ func applyUpdateGroupMessages(postbox: Postbox, stateManager: AccountStateManage
|
|||||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20)
|
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentStickers, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 20)
|
||||||
}
|
}
|
||||||
for file in sentGifs {
|
for file in sentGifs {
|
||||||
|
if !file.hasLinkedStickers {
|
||||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentGifs, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 200)
|
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentGifs, item: OrderedItemListEntry(id: RecentMediaItemId(file.fileId).rawValue, contents: RecentMediaItem(file)), removeTailIfCountExceeds: 200)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
stateManager.addUpdates(result)
|
stateManager.addUpdates(result)
|
||||||
stateManager.addUpdateGroups([.ensurePeerHasLocalState(id: messages[0].id.peerId)])
|
stateManager.addUpdateGroups([.ensurePeerHasLocalState(id: messages[0].id.peerId)])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -450,7 +450,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
self.displayLink?.isPaused = !self.hasVisibility || self.isHidden
|
self.displayLink?.isPaused = !self.hasVisibility || self.isHidden
|
||||||
|
|
||||||
if isVisible {
|
/*if isVisible {
|
||||||
if let item = self.item?.0, let file = self.item?.1 as? TelegramMediaFile, !file.isAnimated {
|
if let item = self.item?.0, let file = self.item?.1 as? TelegramMediaFile, !file.isAnimated {
|
||||||
if self.frameSequenceThumbnailNode == nil {
|
if self.frameSequenceThumbnailNode == nil {
|
||||||
let frameSequenceThumbnailNode = FrameSequenceThumbnailNode(context: context, file: .message(message: MessageReference(item.message), media: file))
|
let frameSequenceThumbnailNode = FrameSequenceThumbnailNode(context: context, file: .message(message: MessageReference(item.message), media: file))
|
||||||
@ -473,7 +473,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||||||
self.frameSequenceThumbnailNode = nil
|
self.frameSequenceThumbnailNode = nil
|
||||||
frameSequenceThumbnailNode.removeFromSupernode()
|
frameSequenceThumbnailNode.removeFromSupernode()
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
self.frameSequenceThumbnailNode?.updateIsPlaying(isVisible)
|
self.frameSequenceThumbnailNode?.updateIsPlaying(isVisible)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user