mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
c084c410b0
commit
8c57b9eef0
@ -345,14 +345,16 @@ public final class DirectMediaImageCache {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var resultImage: UIImage?
|
|
||||||
var blurredImage: UIImage?
|
var blurredImage: UIImage?
|
||||||
|
if includeBlurred, let data = immediateThumbnailData.flatMap(decodeTinyThumbnail), let image = loadImage(data: data), let blurredImageValue = generateBlurredThumbnail(image: image, adjustSaturation: true) {
|
||||||
|
blurredImage = blurredImageValue
|
||||||
|
}
|
||||||
|
|
||||||
|
var resultImage: UIImage?
|
||||||
for otherWidth in possibleWidths.reversed() {
|
for otherWidth in possibleWidths.reversed() {
|
||||||
if otherWidth == width {
|
if otherWidth == width {
|
||||||
if let data = try? Data(contentsOf: URL(fileURLWithPath: self.getCachePath(resourceId: resource.resource.resource.id, imageType: .square(width: otherWidth)))), let image = loadImage(data: data) {
|
if let data = try? Data(contentsOf: URL(fileURLWithPath: self.getCachePath(resourceId: resource.resource.resource.id, imageType: .square(width: otherWidth)))), let image = loadImage(data: data) {
|
||||||
if blurredImage == nil, includeBlurred, let data = immediateThumbnailData.flatMap(decodeTinyThumbnail), let image = loadImage(data: data), let blurredImageValue = generateBlurredThumbnail(image: image, adjustSaturation: true) {
|
|
||||||
blurredImage = blurredImageValue
|
|
||||||
}
|
|
||||||
return GetMediaResult(image: image, blurredImage: blurredImage, loadSignal: nil)
|
return GetMediaResult(image: image, blurredImage: blurredImage, loadSignal: nil)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -369,15 +371,8 @@ public final class DirectMediaImageCache {
|
|||||||
if let blurredImageValue = generateBlurredThumbnail(image: image) {
|
if let blurredImageValue = generateBlurredThumbnail(image: image) {
|
||||||
resultImage = blurredImageValue
|
resultImage = blurredImageValue
|
||||||
}
|
}
|
||||||
if includeBlurred, let blurredImageValue = generateBlurredThumbnail(image: image, adjustSaturation: true) {
|
|
||||||
blurredImage = blurredImageValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if blurredImage == nil, includeBlurred, let data = immediateThumbnailData.flatMap(decodeTinyThumbnail), let image = loadImage(data: data), let blurredImageValue = generateBlurredThumbnail(image: image, adjustSaturation: true) {
|
|
||||||
blurredImage = blurredImageValue
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetMediaResult(image: resultImage, blurredImage: blurredImage, loadSignal: self.getLoadSignal(width: width, userLocation: userLocation, userContentType: .image, resource: resource.resource, resourceSizeLimit: resource.size))
|
return GetMediaResult(image: resultImage, blurredImage: blurredImage, loadSignal: self.getLoadSignal(width: width, userLocation: userLocation, userContentType: .image, resource: resource.resource, resourceSizeLimit: resource.size))
|
||||||
}
|
}
|
||||||
@ -386,7 +381,17 @@ public final class DirectMediaImageCache {
|
|||||||
if synchronous {
|
if synchronous {
|
||||||
return self.getImageSynchronous(message: message, userLocation: .peer(message.id.peerId), media: media, width: width, possibleWidths: possibleWidths, includeBlurred: includeBlurred)
|
return self.getImageSynchronous(message: message, userLocation: .peer(message.id.peerId), media: media, width: width, possibleWidths: possibleWidths, includeBlurred: includeBlurred)
|
||||||
} else {
|
} else {
|
||||||
return GetMediaResult(image: nil, blurredImage: nil, loadSignal: Signal { subscriber in
|
var immediateThumbnailData: Data?
|
||||||
|
if let image = media as? TelegramMediaImage {
|
||||||
|
immediateThumbnailData = image.immediateThumbnailData
|
||||||
|
} else if let file = media as? TelegramMediaFile {
|
||||||
|
immediateThumbnailData = file.immediateThumbnailData
|
||||||
|
}
|
||||||
|
var blurredImage: UIImage?
|
||||||
|
if includeBlurred, let data = immediateThumbnailData.flatMap(decodeTinyThumbnail), let image = loadImage(data: data), let blurredImageValue = generateBlurredThumbnail(image: image, adjustSaturation: true) {
|
||||||
|
blurredImage = blurredImageValue
|
||||||
|
}
|
||||||
|
return GetMediaResult(image: nil, blurredImage: blurredImage, loadSignal: Signal { subscriber in
|
||||||
let result = self.getImageSynchronous(message: message, userLocation: .peer(message.id.peerId), media: media, width: width, possibleWidths: possibleWidths, includeBlurred: includeBlurred)
|
let result = self.getImageSynchronous(message: message, userLocation: .peer(message.id.peerId), media: media, width: width, possibleWidths: possibleWidths, includeBlurred: includeBlurred)
|
||||||
guard let result = result else {
|
guard let result = result else {
|
||||||
subscriber.putNext(nil)
|
subscriber.putNext(nil)
|
||||||
|
@ -228,26 +228,6 @@ final class NeonTool: DrawingElement {
|
|||||||
self.activePath = bezierPath
|
self.activePath = bezierPath
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
// if self.points.isEmpty {
|
|
||||||
// self.points[self.ctr] = point
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// self.ctr += 1
|
|
||||||
// self.points[self.ctr] = point
|
|
||||||
//
|
|
||||||
// if self.ctr == 4 {
|
|
||||||
// self.points[3] = CGPoint(x: (self.points[2]!.x + self.points[4]!.x) / 2.0, y: (self.points[2]!.y + self.points[4]!.y) / 2.0)
|
|
||||||
//
|
|
||||||
// self.path.move(to: self.points[0]!)
|
|
||||||
// self.path.addCurve(to: self.points[3]!, controlPoint1: self.points[1]!, controlPoint2: self.points[2]!)
|
|
||||||
//
|
|
||||||
// self.points[0] = self.points[3]!
|
|
||||||
// self.points[1] = self.points[4]!
|
|
||||||
//
|
|
||||||
// self.ctr = 1
|
|
||||||
// self.addedSegments += 1
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func currentBezierPath(_ ctr: Int) -> UIBezierPath? {
|
private func currentBezierPath(_ ctr: Int) -> UIBezierPath? {
|
||||||
|
@ -129,6 +129,8 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
|||||||
|
|
||||||
public var screenSize: CGSize
|
public var screenSize: CGSize
|
||||||
|
|
||||||
|
private var previousPointTimestamp: Double?
|
||||||
|
|
||||||
init(size: CGSize) {
|
init(size: CGSize) {
|
||||||
self.imageSize = size
|
self.imageSize = size
|
||||||
self.screenSize = size
|
self.screenSize = size
|
||||||
@ -202,11 +204,13 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let currentTimestamp = CACurrentMediaTime()
|
||||||
switch state {
|
switch state {
|
||||||
case .began:
|
case .began:
|
||||||
strongSelf.isDrawing = true
|
strongSelf.isDrawing = true
|
||||||
strongSelf.previousStrokePoint = nil
|
strongSelf.previousStrokePoint = nil
|
||||||
strongSelf.drawingGestureStartTimestamp = CACurrentMediaTime()
|
strongSelf.drawingGestureStartTimestamp = currentTimestamp
|
||||||
|
strongSelf.previousPointTimestamp = currentTimestamp
|
||||||
|
|
||||||
if strongSelf.uncommitedElement != nil {
|
if strongSelf.uncommitedElement != nil {
|
||||||
strongSelf.finishDrawing(rect: CGRect(origin: .zero, size: strongSelf.imageSize), synchronous: true)
|
strongSelf.finishDrawing(rect: CGRect(origin: .zero, size: strongSelf.imageSize), synchronous: true)
|
||||||
@ -267,6 +271,10 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
|||||||
strongSelf.uncommitedElement = newElement
|
strongSelf.uncommitedElement = newElement
|
||||||
strongSelf.updateInternalState()
|
strongSelf.updateInternalState()
|
||||||
case .changed:
|
case .changed:
|
||||||
|
if let previousPointTimestamp = strongSelf.previousPointTimestamp, currentTimestamp - previousPointTimestamp < 0.016 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.previousPointTimestamp = currentTimestamp
|
||||||
strongSelf.uncommitedElement?.updatePath(point, state: state)
|
strongSelf.uncommitedElement?.updatePath(point, state: state)
|
||||||
|
|
||||||
// if case let .direct(point) = path, let lastPoint = line.points.last {
|
// if case let .direct(point) = path, let lastPoint = line.points.last {
|
||||||
|
@ -1160,10 +1160,18 @@ public final class SparseItemGrid: ASDisplayNode {
|
|||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
self.fromViewport.allowsGroupOpacity = true
|
||||||
|
self.toViewport.allowsGroupOpacity = true
|
||||||
|
|
||||||
self.addSubnode(fromViewport)
|
self.addSubnode(fromViewport)
|
||||||
self.addSubnode(toViewport)
|
self.addSubnode(toViewport)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
self.fromViewport.allowsGroupOpacity = false
|
||||||
|
self.toViewport.allowsGroupOpacity = false
|
||||||
|
}
|
||||||
|
|
||||||
func update(progress: CGFloat, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
|
func update(progress: CGFloat, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
|
||||||
guard var fromAnchorFrame = self.fromViewport.frameForItem(at: self.anchorItemIndex) else {
|
guard var fromAnchorFrame = self.fromViewport.frameForItem(at: self.anchorItemIndex) else {
|
||||||
return
|
return
|
||||||
|
@ -287,7 +287,6 @@ private class ExtendedMediaOverlayNode: ASDisplayNode {
|
|||||||
self.dustNode.revealed = { [weak self] in
|
self.dustNode.revealed = { [weak self] in
|
||||||
self?.isRevealed = true
|
self?.isRevealed = true
|
||||||
self?.blurredImageNode.removeFromSupernode()
|
self?.blurredImageNode.removeFromSupernode()
|
||||||
self?.isUserInteractionEnabled = false
|
|
||||||
}
|
}
|
||||||
self.dustNode.tapped = { [weak self] in
|
self.dustNode.tapped = { [weak self] in
|
||||||
self?.isRevealed = true
|
self?.isRevealed = true
|
||||||
@ -295,7 +294,7 @@ private class ExtendedMediaOverlayNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.blurredImageNode.isHidden = true
|
self.blurredImageNode.isHidden = true
|
||||||
self.isUserInteractionEnabled = false
|
self.isRevealed = true
|
||||||
}
|
}
|
||||||
self.blurredImageNode.frame = imageFrame
|
self.blurredImageNode.frame = imageFrame
|
||||||
|
|
||||||
@ -1941,7 +1940,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
var tappable = false
|
var tappable = false
|
||||||
switch state {
|
switch state {
|
||||||
case .play, .pause, .download, .none:
|
case .play, .pause, .download, .none:
|
||||||
tappable = false
|
tappable = true
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user