mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various Improvements
This commit is contained in:
@@ -433,7 +433,32 @@ public extension ContainedViewLayoutTransition {
|
||||
}
|
||||
}
|
||||
|
||||
func updateFrame(view: UIView, frame: CGRect, force: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
func updateFrame(view: UIView, frame: CGRect, force: Bool = false, beginWithCurrentState: Bool = false, delay: Double = 0.0, completion: ((Bool) -> Void)? = nil) {
|
||||
if frame.origin.x.isNaN {
|
||||
return
|
||||
}
|
||||
if frame.origin.y.isNaN {
|
||||
return
|
||||
}
|
||||
if frame.size.width.isNaN {
|
||||
return
|
||||
}
|
||||
if frame.size.width < 0.0 {
|
||||
return
|
||||
}
|
||||
if frame.size.height.isNaN {
|
||||
return
|
||||
}
|
||||
if frame.size.height < 0.0 {
|
||||
return
|
||||
}
|
||||
if !ASIsCGRectValidForLayout(CGRect(origin: CGPoint(), size: frame.size)) {
|
||||
return
|
||||
}
|
||||
if !ASIsCGPositionValidForLayout(frame.origin) {
|
||||
return
|
||||
}
|
||||
|
||||
if view.frame.equalTo(frame) && !force {
|
||||
completion?(true)
|
||||
} else {
|
||||
@@ -444,9 +469,14 @@ public extension ContainedViewLayoutTransition {
|
||||
completion(true)
|
||||
}
|
||||
case let .animated(duration, curve):
|
||||
let previousFrame = view.frame
|
||||
let previousFrame: CGRect
|
||||
if beginWithCurrentState, let presentation = view.layer.presentation() {
|
||||
previousFrame = presentation.frame
|
||||
} else {
|
||||
previousFrame = view.frame
|
||||
}
|
||||
view.frame = frame
|
||||
view.layer.animateFrame(from: previousFrame, to: frame, duration: duration, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, force: force, completion: { result in
|
||||
view.layer.animateFrame(from: previousFrame, to: frame, duration: duration, delay: delay, timingFunction: curve.timingFunction, mediaTimingFunction: curve.mediaTimingFunction, force: force, completion: { result in
|
||||
if let completion = completion {
|
||||
completion(result)
|
||||
}
|
||||
@@ -454,7 +484,7 @@ public extension ContainedViewLayoutTransition {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func updateFrame(layer: CALayer, frame: CGRect, completion: ((Bool) -> Void)? = nil) {
|
||||
if layer.frame.equalTo(frame) {
|
||||
completion?(true)
|
||||
|
||||
Reference in New Issue
Block a user