mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[WIP] Emoji statuses
This commit is contained in:
@@ -369,19 +369,23 @@ public struct Transition {
|
||||
}
|
||||
|
||||
public func setAlpha(view: UIView, alpha: CGFloat, completion: ((Bool) -> Void)? = nil) {
|
||||
if view.alpha == alpha {
|
||||
self.setAlpha(layer: view.layer, alpha: alpha, completion: completion)
|
||||
}
|
||||
|
||||
public func setAlpha(layer: CALayer, alpha: CGFloat, completion: ((Bool) -> Void)? = nil) {
|
||||
if layer.opacity == Float(alpha) {
|
||||
completion?(true)
|
||||
return
|
||||
}
|
||||
switch self.animation {
|
||||
case .none:
|
||||
view.alpha = alpha
|
||||
view.layer.removeAnimation(forKey: "opacity")
|
||||
layer.opacity = Float(alpha)
|
||||
layer.removeAnimation(forKey: "opacity")
|
||||
completion?(true)
|
||||
case .curve:
|
||||
let previousAlpha = (view.layer.presentation()?.opacity).flatMap(CGFloat.init) ?? view.alpha
|
||||
view.alpha = alpha
|
||||
self.animateAlpha(view: view, from: previousAlpha, to: alpha, completion: completion)
|
||||
let previousAlpha = layer.presentation()?.opacity ?? layer.opacity
|
||||
layer.opacity = Float(alpha)
|
||||
self.animateAlpha(layer: layer, from: CGFloat(previousAlpha), to: alpha, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,6 +417,37 @@ public struct Transition {
|
||||
}
|
||||
}
|
||||
|
||||
public func setTransform(view: UIView, transform: CATransform3D, completion: ((Bool) -> Void)? = nil) {
|
||||
self.setTransform(layer: view.layer, transform: transform, completion: completion)
|
||||
}
|
||||
|
||||
public func setTransform(layer: CALayer, transform: CATransform3D, completion: ((Bool) -> Void)? = nil) {
|
||||
switch self.animation {
|
||||
case .none:
|
||||
layer.transform = transform
|
||||
completion?(true)
|
||||
case let .curve(duration, curve):
|
||||
let previousValue: CATransform3D
|
||||
if let presentation = layer.presentation() {
|
||||
previousValue = presentation.transform
|
||||
} else {
|
||||
previousValue = layer.transform
|
||||
}
|
||||
layer.transform = transform
|
||||
layer.animate(
|
||||
from: NSValue(caTransform3D: previousValue),
|
||||
to: NSValue(caTransform3D: transform),
|
||||
keyPath: "transform",
|
||||
duration: duration,
|
||||
delay: 0.0,
|
||||
curve: curve,
|
||||
removeOnCompletion: true,
|
||||
additive: false,
|
||||
completion: completion
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public func setSublayerTransform(view: UIView, transform: CATransform3D, completion: ((Bool) -> Void)? = nil) {
|
||||
switch self.animation {
|
||||
case .none:
|
||||
@@ -479,11 +514,15 @@ public struct Transition {
|
||||
}
|
||||
|
||||
public func animateAlpha(view: UIView, from fromValue: CGFloat, to toValue: CGFloat, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
self.animateAlpha(layer: view.layer, from: fromValue, to: toValue, additive: additive, completion: completion)
|
||||
}
|
||||
|
||||
public func animateAlpha(layer: CALayer, from fromValue: CGFloat, to toValue: CGFloat, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
switch self.animation {
|
||||
case .none:
|
||||
completion?(true)
|
||||
case let .curve(duration, curve):
|
||||
view.layer.animate(
|
||||
layer.animate(
|
||||
from: fromValue as NSNumber,
|
||||
to: toValue as NSNumber,
|
||||
keyPath: "opacity",
|
||||
|
||||
Reference in New Issue
Block a user