mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Visual improvements
This commit is contained in:
parent
ce5e3f4911
commit
f25d0776c7
4 changed files with 26 additions and 11 deletions
|
|
@ -421,7 +421,7 @@ public extension ContainedViewLayoutTransition {
|
|||
}
|
||||
case let .animated(duration, curve):
|
||||
let previousBounds: CGRect
|
||||
if beginWithCurrentState, layer.animation(forKey: "position") != nil, let presentation = layer.presentation() {
|
||||
if beginWithCurrentState, layer.animation(forKey: "bounds") != nil, let presentation = layer.presentation() {
|
||||
previousBounds = presentation.bounds
|
||||
} else {
|
||||
previousBounds = layer.bounds
|
||||
|
|
@ -464,7 +464,7 @@ public extension ContainedViewLayoutTransition {
|
|||
}
|
||||
}
|
||||
|
||||
func updatePosition(layer: CALayer, position: CGPoint, force: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
func updatePosition(layer: CALayer, position: CGPoint, force: Bool = false, beginFromCurrentState: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
if layer.position.equalTo(position) && !force {
|
||||
completion?(true)
|
||||
} else {
|
||||
|
|
@ -476,7 +476,22 @@ public extension ContainedViewLayoutTransition {
|
|||
completion(true)
|
||||
}
|
||||
case let .animated(duration, curve):
|
||||
let previousPosition = layer.position
|
||||
let previousPosition: CGPoint
|
||||
if beginFromCurrentState, let animationKeys = layer.animationKeys(), animationKeys.contains(where: { key in
|
||||
guard let animation = layer.animation(forKey: key) as? CAPropertyAnimation else {
|
||||
return false
|
||||
}
|
||||
if animation.keyPath == "position" {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}) {
|
||||
previousPosition = layer.presentation()?.position ?? layer.position
|
||||
} else {
|
||||
previousPosition = layer.position
|
||||
}
|
||||
|
||||
layer.position = position
|
||||
layer.animatePosition(from: previousPosition, to: position, duration: duration, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, completion: { result in
|
||||
if let completion = completion {
|
||||
|
|
@ -2772,7 +2787,7 @@ public final class ControlledTransition {
|
|||
}
|
||||
|
||||
public func updatePosition(layer: CALayer, position: CGPoint, completion: ((Bool) -> Void)?) {
|
||||
self.transition.updatePosition(layer: layer, position: position, completion: completion)
|
||||
self.transition.updatePosition(layer: layer, position: position, beginFromCurrentState: true, completion: completion)
|
||||
}
|
||||
|
||||
public func updateTransform(layer: CALayer, transform: CATransform3D, completion: ((Bool) -> Void)?) {
|
||||
|
|
@ -2792,11 +2807,11 @@ public final class ControlledTransition {
|
|||
}
|
||||
|
||||
public func updateBounds(layer: CALayer, bounds: CGRect, completion: ((Bool) -> Void)?) {
|
||||
self.transition.updateBounds(layer: layer, bounds: bounds, completion: completion)
|
||||
self.transition.updateBounds(layer: layer, bounds: bounds, beginWithCurrentState: true, completion: completion)
|
||||
}
|
||||
|
||||
public func updateFrame(layer: CALayer, frame: CGRect, completion: ((Bool) -> Void)?) {
|
||||
self.transition.updateFrame(layer: layer, frame: frame, completion: completion)
|
||||
self.transition.updateFrame(layer: layer, frame: frame, beginWithCurrentState: true, completion: completion)
|
||||
}
|
||||
|
||||
public func updateCornerRadius(layer: CALayer, cornerRadius: CGFloat, completion: ((Bool) -> Void)?) {
|
||||
|
|
|
|||
|
|
@ -2278,7 +2278,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||
}
|
||||
if !bubbleReactions.reactions.isEmpty && !item.presentationData.isPreview {
|
||||
if incoming {
|
||||
bottomNodeMergeStatus = .Both
|
||||
bottomNodeMergeStatus = .Left
|
||||
} else {
|
||||
bottomNodeMergeStatus = .Right
|
||||
}
|
||||
|
|
@ -3814,7 +3814,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||
}
|
||||
|
||||
var forceBackgroundSide = false
|
||||
if actionButtonsSizeAndApply != nil || reactionButtonsSizeAndApply != nil {
|
||||
if actionButtonsSizeAndApply != nil {
|
||||
forceBackgroundSide = true
|
||||
} else if case .semanticallyMerged = updatedMergedTop {
|
||||
forceBackgroundSide = true
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public struct ChatMessageItemLayoutConstants {
|
|||
public static var compact: ChatMessageItemLayoutConstants {
|
||||
let bubble = ChatMessageItemBubbleLayoutConstants(edgeInset: 3.0, defaultSpacing: 2.0 + UIScreenPixel, mergedSpacing: 0.0, maximumWidthFill: ChatMessageItemWidthFill(compactInset: 36.0, compactWidthBoundary: 500.0, freeMaximumFillFactor: 0.85), minimumSize: CGSize(width: 40.0, height: 35.0), contentInsets: UIEdgeInsets(top: 0.0, left: 6.0, bottom: 0.0, right: 0.0), borderInset: UIScreenPixel, strokeInsets: UIEdgeInsets(top: 1.0, left: 1.0, bottom: 1.0, right: 1.0))
|
||||
let text = ChatMessageItemTextLayoutConstants(bubbleInsets: UIEdgeInsets(top: 6.0 + UIScreenPixel, left: 11.0, bottom: 6.0 - UIScreenPixel, right: 11.0))
|
||||
let image = ChatMessageItemImageLayoutConstants(bubbleInsets: UIEdgeInsets(top: 2.0, left: 2.0, bottom: 2.0, right: 2.0), statusInsets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 6.0, right: 6.0), defaultCornerRadius: 16.0, mergedCornerRadius: 8.0, contentMergedCornerRadius: 0.0, maxDimensions: CGSize(width: 300.0, height: 380.0), minDimensions: CGSize(width: 170.0, height: 74.0))
|
||||
let image = ChatMessageItemImageLayoutConstants(bubbleInsets: UIEdgeInsets(top: 2.0, left: 2.0, bottom: 2.0, right: 2.0), statusInsets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 6.0, right: 6.0), defaultCornerRadius: 15.0, mergedCornerRadius: 7.0, contentMergedCornerRadius: 0.0, maxDimensions: CGSize(width: 300.0, height: 380.0), minDimensions: CGSize(width: 170.0, height: 74.0))
|
||||
let video = ChatMessageItemVideoLayoutConstants(maxHorizontalHeight: 250.0, maxVerticalHeight: 360.0)
|
||||
let file = ChatMessageItemFileLayoutConstants(bubbleInsets: UIEdgeInsets(top: 15.0, left: 9.0, bottom: 15.0, right: 12.0))
|
||||
let instantVideo = ChatMessageItemInstantVideoConstants(insets: UIEdgeInsets(top: 4.0, left: 0.0, bottom: 4.0, right: 0.0), dimensions: CGSize(width: 212.0, height: 212.0))
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ public func chatMessageItemLayoutConstants(_ constants: (ChatMessageItemLayoutCo
|
|||
} else {
|
||||
result = constants.0
|
||||
}
|
||||
result.image.defaultCornerRadius = presentationData.chatBubbleCorners.mainRadius
|
||||
result.image.mergedCornerRadius = (presentationData.chatBubbleCorners.mergeBubbleCorners && result.image.defaultCornerRadius >= 10.0) ? presentationData.chatBubbleCorners.auxiliaryRadius : presentationData.chatBubbleCorners.mainRadius
|
||||
result.image.defaultCornerRadius = max(0.0, presentationData.chatBubbleCorners.mainRadius - 1.0)
|
||||
result.image.mergedCornerRadius = max(0.0, ((presentationData.chatBubbleCorners.mergeBubbleCorners && result.image.defaultCornerRadius >= 10.0) ? presentationData.chatBubbleCorners.auxiliaryRadius : presentationData.chatBubbleCorners.mainRadius) - 1.0)
|
||||
let minRadius: CGFloat = 4.0
|
||||
let maxRadius: CGFloat = 16.0
|
||||
let radiusTransition = (presentationData.chatBubbleCorners.mainRadius - minRadius) / (maxRadius - minRadius)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue