mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +00:00
Various fixes
This commit is contained in:
parent
a7ee1689f1
commit
88e07a974f
@ -177,7 +177,7 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
|||||||
let bubbleBorderImage = messageBubbleImage(maxCornerRadius: bubbleCorners.mainRadius, minCornerRadius: bubbleCorners.auxiliaryRadius, incoming: true, fillColor: .clear, strokeColor: .red, neighbors: .none, theme: theme.chat, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true, onlyOutline: true)
|
let bubbleBorderImage = messageBubbleImage(maxCornerRadius: bubbleCorners.mainRadius, minCornerRadius: bubbleCorners.auxiliaryRadius, incoming: true, fillColor: .clear, strokeColor: .red, neighbors: .none, theme: theme.chat, wallpaper: .color(0xffffff), knockout: true, mask: true, extendedEdges: true, onlyOutline: true)
|
||||||
|
|
||||||
var messageContainers: [ChatLoadingPlaceholderMessageContainer] = []
|
var messageContainers: [ChatLoadingPlaceholderMessageContainer] = []
|
||||||
for _ in 0 ..< 8 {
|
for _ in 0 ..< 11 {
|
||||||
let container = ChatLoadingPlaceholderMessageContainer(bubbleImage: bubbleImage, bubbleBorderImage: bubbleBorderImage)
|
let container = ChatLoadingPlaceholderMessageContainer(bubbleImage: bubbleImage, bubbleBorderImage: bubbleBorderImage)
|
||||||
container.setup(maskNode: self.maskNode, borderMaskNode: self.borderMaskNode)
|
container.setup(maskNode: self.maskNode, borderMaskNode: self.borderMaskNode)
|
||||||
messageContainers.append(container)
|
messageContainers.append(container)
|
||||||
@ -394,6 +394,9 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
|||||||
CGSize(width: floorToScreenPixels(0.36 * size.width), height: shortHeight),
|
CGSize(width: floorToScreenPixels(0.36 * size.width), height: shortHeight),
|
||||||
CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight),
|
CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight),
|
||||||
CGSize(width: floorToScreenPixels(0.57 * size.width), height: tallHeight),
|
CGSize(width: floorToScreenPixels(0.57 * size.width), height: tallHeight),
|
||||||
|
CGSize(width: floorToScreenPixels(0.73 * size.width), height: tallHeight),
|
||||||
|
CGSize(width: floorToScreenPixels(0.36 * size.width), height: tallHeight),
|
||||||
|
CGSize(width: floorToScreenPixels(0.57 * size.width), height: shortHeight),
|
||||||
]
|
]
|
||||||
|
|
||||||
var offset: CGFloat = 5.0
|
var offset: CGFloat = 5.0
|
||||||
@ -403,7 +406,7 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for messageContainer in self.messageContainers {
|
for messageContainer in self.messageContainers {
|
||||||
let messageSize = dimensions[index % 8]
|
let messageSize = dimensions[index % 11]
|
||||||
messageContainer.update(size: size, hasAvatar: self.isGroup, rect: CGRect(origin: CGPoint(x: 0.0, y: size.height - insets.bottom - offset - messageSize.height), size: messageSize), transition: transition)
|
messageContainer.update(size: size, hasAvatar: self.isGroup, rect: CGRect(origin: CGPoint(x: 0.0, y: size.height - insets.bottom - offset - messageSize.height), size: messageSize), transition: transition)
|
||||||
offset += messageSize.height
|
offset += messageSize.height
|
||||||
index += 1
|
index += 1
|
||||||
|
|||||||
@ -2319,7 +2319,8 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
let progress = abs(translation.x) / swipeOffset
|
let progress = abs(translation.x) / swipeOffset
|
||||||
swipeToReplyNode.updateProgress(progress)
|
swipeToReplyNode.updateProgress(progress)
|
||||||
|
|
||||||
if progress == 1.0 && !self.playedSwipeToReplyHaptic {
|
if progress > 1.0 - .ulpOfOne && !self.playedSwipeToReplyHaptic {
|
||||||
|
self.playedSwipeToReplyHaptic = true
|
||||||
self.swipeToReplyFeedback?.impact(.heavy)
|
self.swipeToReplyFeedback?.impact(.heavy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3963,7 +3963,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
let progress = abs(translation.x) / swipeOffset
|
let progress = abs(translation.x) / swipeOffset
|
||||||
swipeToReplyNode.updateProgress(progress)
|
swipeToReplyNode.updateProgress(progress)
|
||||||
|
|
||||||
if progress == 1.0 && !self.playedSwipeToReplyHaptic {
|
if progress > 1.0 - .ulpOfOne && !self.playedSwipeToReplyHaptic {
|
||||||
|
self.playedSwipeToReplyHaptic = true
|
||||||
self.swipeToReplyFeedback?.impact(.heavy)
|
self.swipeToReplyFeedback?.impact(.heavy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1031,7 +1031,8 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
let progress = abs(translation.x) / swipeOffset
|
let progress = abs(translation.x) / swipeOffset
|
||||||
swipeToReplyNode.updateProgress(progress)
|
swipeToReplyNode.updateProgress(progress)
|
||||||
|
|
||||||
if progress == 1.0 && !self.playedSwipeToReplyHaptic {
|
if progress > 1.0 - .ulpOfOne && !self.playedSwipeToReplyHaptic {
|
||||||
|
self.playedSwipeToReplyHaptic = true
|
||||||
self.swipeToReplyFeedback?.impact(.heavy)
|
self.swipeToReplyFeedback?.impact(.heavy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1283,7 +1283,8 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
let progress = abs(translation.x) / swipeOffset
|
let progress = abs(translation.x) / swipeOffset
|
||||||
swipeToReplyNode.updateProgress(progress)
|
swipeToReplyNode.updateProgress(progress)
|
||||||
|
|
||||||
if progress == 1.0 && !self.playedSwipeToReplyHaptic {
|
if progress > 1.0 - .ulpOfOne && !self.playedSwipeToReplyHaptic {
|
||||||
|
self.playedSwipeToReplyHaptic = true
|
||||||
self.swipeToReplyFeedback?.impact(.heavy)
|
self.swipeToReplyFeedback?.impact(.heavy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,9 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode {
|
|||||||
private let foregroundNode: ASImageNode
|
private let foregroundNode: ASImageNode
|
||||||
|
|
||||||
private let maskNode: ASDisplayNode
|
private let maskNode: ASDisplayNode
|
||||||
private let progressLayer: CAShapeLayer
|
private let progressLayer: SimpleShapeLayer
|
||||||
private let fillLayer: CAShapeLayer
|
private let fillLayer: SimpleShapeLayer
|
||||||
|
private let semiFillLayer: SimpleShapeLayer
|
||||||
|
|
||||||
private var absolutePosition: (CGRect, CGSize)?
|
private var absolutePosition: (CGRect, CGSize)?
|
||||||
|
|
||||||
@ -67,8 +68,9 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode {
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.maskNode = ASDisplayNode()
|
self.maskNode = ASDisplayNode()
|
||||||
self.progressLayer = CAShapeLayer()
|
self.progressLayer = SimpleShapeLayer()
|
||||||
self.fillLayer = CAShapeLayer()
|
self.fillLayer = SimpleShapeLayer()
|
||||||
|
self.semiFillLayer = SimpleShapeLayer()
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -78,6 +80,7 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode {
|
|||||||
|
|
||||||
self.maskNode.layer.addSublayer(self.progressLayer)
|
self.maskNode.layer.addSublayer(self.progressLayer)
|
||||||
self.maskNode.layer.addSublayer(self.fillLayer)
|
self.maskNode.layer.addSublayer(self.fillLayer)
|
||||||
|
self.maskNode.layer.addSublayer(self.semiFillLayer)
|
||||||
|
|
||||||
self.addSubnode(self.foregroundNode)
|
self.addSubnode(self.foregroundNode)
|
||||||
|
|
||||||
@ -96,10 +99,15 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode {
|
|||||||
self.fillLayer.fillColor = UIColor.clear.cgColor
|
self.fillLayer.fillColor = UIColor.clear.cgColor
|
||||||
self.fillLayer.isHidden = true
|
self.fillLayer.isHidden = true
|
||||||
|
|
||||||
|
self.semiFillLayer.fillColor = UIColor(rgb: 0xffffff, alpha: 0.6).cgColor
|
||||||
|
|
||||||
self.maskNode.frame = CGRect(origin: CGPoint(x: 22.0, y: 22.0), size: backgroundFrame.size)
|
self.maskNode.frame = CGRect(origin: CGPoint(x: 22.0, y: 22.0), size: backgroundFrame.size)
|
||||||
self.progressLayer.frame = CGRect(origin: .zero, size: size).insetBy(dx: -20.0, dy: -20.0)
|
self.progressLayer.frame = CGRect(origin: .zero, size: size).insetBy(dx: -20.0, dy: -20.0)
|
||||||
self.fillLayer.frame = CGRect(origin: .zero, size: size)
|
self.fillLayer.frame = CGRect(origin: .zero, size: size)
|
||||||
|
|
||||||
|
self.semiFillLayer.frame = self.fillLayer.frame
|
||||||
|
self.semiFillLayer.path = UIBezierPath(ovalIn: self.semiFillLayer.bounds).cgPath
|
||||||
|
|
||||||
let path = UIBezierPath(arcCenter: CGPoint(x: self.progressLayer.frame.width / 2.0, y: self.progressLayer.frame.height / 2.0), radius: size.width / 2.0, startAngle: CGFloat(-0.5 * .pi), endAngle: CGFloat(1.5 * .pi), clockwise: true)
|
let path = UIBezierPath(arcCenter: CGPoint(x: self.progressLayer.frame.width / 2.0, y: self.progressLayer.frame.height / 2.0), radius: size.width / 2.0, startAngle: CGFloat(-0.5 * .pi), endAngle: CGFloat(1.5 * .pi), clockwise: true)
|
||||||
self.progressLayer.path = path.cgPath
|
self.progressLayer.path = path.cgPath
|
||||||
|
|
||||||
@ -154,6 +162,8 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode {
|
|||||||
self.maskNode.alpha = progress
|
self.maskNode.alpha = progress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.semiFillLayer.opacity = Float(progress)
|
||||||
|
|
||||||
self.layer.sublayerTransform = CATransform3DMakeScale(scaleProgress, scaleProgress, 1.0)
|
self.layer.sublayerTransform = CATransform3DMakeScale(scaleProgress, scaleProgress, 1.0)
|
||||||
|
|
||||||
self.foregroundNode.alpha = foregroundProgress
|
self.foregroundNode.alpha = foregroundProgress
|
||||||
@ -180,7 +190,7 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode {
|
|||||||
var path = self.progressLayer.path
|
var path = self.progressLayer.path
|
||||||
var targetPath = UIBezierPath(arcCenter: CGPoint(x: self.progressLayer.frame.width / 2.0, y: self.progressLayer.frame.height / 2.0), radius: 35.0, startAngle: CGFloat(-0.5 * .pi), endAngle: CGFloat(-0.5 * .pi + 2.0 * .pi), clockwise: true).cgPath
|
var targetPath = UIBezierPath(arcCenter: CGPoint(x: self.progressLayer.frame.width / 2.0, y: self.progressLayer.frame.height / 2.0), radius: 35.0, startAngle: CGFloat(-0.5 * .pi), endAngle: CGFloat(-0.5 * .pi + 2.0 * .pi), clockwise: true).cgPath
|
||||||
self.progressLayer.path = targetPath
|
self.progressLayer.path = targetPath
|
||||||
self.progressLayer.animate(from: path, to: targetPath, keyPath: "path", timingFunction: kCAMediaTimingFunctionSpring, duration: 0.2)
|
self.progressLayer.animate(from: path, to: targetPath, keyPath: "path", timingFunction: kCAMediaTimingFunctionSpring, duration: 0.25)
|
||||||
|
|
||||||
self.fillLayer.isHidden = false
|
self.fillLayer.isHidden = false
|
||||||
self.fillLayer.path = UIBezierPath(ovalIn: CGRect(origin: .zero, size: size)).cgPath
|
self.fillLayer.path = UIBezierPath(ovalIn: CGRect(origin: .zero, size: size)).cgPath
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user