mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Storage improvements
This commit is contained in:
@@ -765,4 +765,36 @@ public struct Transition {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func setBackgroundColor(view: UIView, color: UIColor, completion: ((Bool) -> Void)? = nil) {
|
||||
self.setBackgroundColor(layer: view.layer, color: color, completion: completion)
|
||||
}
|
||||
|
||||
public func setBackgroundColor(layer: CALayer, color: UIColor, completion: ((Bool) -> Void)? = nil) {
|
||||
if let current = layer.backgroundColor, current == color.cgColor {
|
||||
completion?(true)
|
||||
return
|
||||
}
|
||||
|
||||
switch self.animation {
|
||||
case .none:
|
||||
layer.backgroundColor = color.cgColor
|
||||
completion?(true)
|
||||
case let .curve(duration, curve):
|
||||
let previousColor: CGColor = layer.backgroundColor ?? UIColor.clear.cgColor
|
||||
layer.backgroundColor = color.cgColor
|
||||
|
||||
layer.animate(
|
||||
from: previousColor,
|
||||
to: color.cgColor,
|
||||
keyPath: "backgroundColor",
|
||||
duration: duration,
|
||||
delay: 0.0,
|
||||
curve: curve,
|
||||
removeOnCompletion: true,
|
||||
additive: false,
|
||||
completion: completion
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,15 @@ public final class ComponentView<EnvironmentType> {
|
||||
self.currentSize = size
|
||||
return size
|
||||
}
|
||||
|
||||
public func updateEnvironment(transition: Transition, @EnvironmentBuilder environment: () -> Environment<EnvironmentType>) -> CGSize? {
|
||||
guard let currentComponent = self.currentComponent, let currentContainerSize = self.currentContainerSize else {
|
||||
return nil
|
||||
}
|
||||
let size = self._update(transition: transition, component: currentComponent, maybeEnvironment: environment, updateEnvironment: true, forceUpdate: false, containerSize: currentContainerSize)
|
||||
self.currentSize = size
|
||||
return size
|
||||
}
|
||||
|
||||
private func _update(transition: Transition, component: AnyComponent<EnvironmentType>, maybeEnvironment: () -> Environment<EnvironmentType>, updateEnvironment: Bool, forceUpdate: Bool, containerSize: CGSize) -> CGSize {
|
||||
precondition(!self.isUpdating)
|
||||
|
||||
Reference in New Issue
Block a user