mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
[Temp] Reduce clear cache progress flicker
This commit is contained in:
parent
e40d2a0088
commit
7f115e2a08
@ -231,6 +231,7 @@ final class StorageUsageScreenComponent: Component {
|
|||||||
|
|
||||||
private var selectionState: SelectionState?
|
private var selectionState: SelectionState?
|
||||||
|
|
||||||
|
private var clearingDisplayTimestamp: Double?
|
||||||
private var isClearing: Bool = false {
|
private var isClearing: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
if self.isClearing != oldValue {
|
if self.isClearing != oldValue {
|
||||||
@ -1604,6 +1605,7 @@ final class StorageUsageScreenComponent: Component {
|
|||||||
clearingNode = StorageUsageClearProgressOverlayNode(presentationData: component.context.sharedContext.currentPresentationData.with { $0 })
|
clearingNode = StorageUsageClearProgressOverlayNode(presentationData: component.context.sharedContext.currentPresentationData.with { $0 })
|
||||||
self.clearingNode = clearingNode
|
self.clearingNode = clearingNode
|
||||||
self.addSubnode(clearingNode)
|
self.addSubnode(clearingNode)
|
||||||
|
self.clearingDisplayTimestamp = CFAbsoluteTimeGetCurrent()
|
||||||
}
|
}
|
||||||
|
|
||||||
let clearingSize = CGSize(width: availableSize.width, height: availableSize.height)
|
let clearingSize = CGSize(width: availableSize.width, height: availableSize.height)
|
||||||
@ -1617,10 +1619,26 @@ final class StorageUsageScreenComponent: Component {
|
|||||||
if let clearingNode = self.clearingNode {
|
if let clearingNode = self.clearingNode {
|
||||||
self.clearingNode = nil
|
self.clearingNode = nil
|
||||||
|
|
||||||
let animationTransition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut))
|
var delay: Double = 0.0
|
||||||
animationTransition.setAlpha(view: clearingNode.view, alpha: 0.0, completion: { [weak clearingNode] _ in
|
if let clearingDisplayTimestamp = self.clearingDisplayTimestamp {
|
||||||
clearingNode?.removeFromSupernode()
|
let timeDelta = CFAbsoluteTimeGetCurrent() - clearingDisplayTimestamp
|
||||||
})
|
if timeDelta < 0.12 {
|
||||||
|
delay = 0.0
|
||||||
|
} else if timeDelta < 0.4 {
|
||||||
|
delay = 0.4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if delay == 0.0 {
|
||||||
|
let animationTransition = Transition(animation: .curve(duration: 0.25, curve: .easeInOut))
|
||||||
|
animationTransition.setAlpha(view: clearingNode.view, alpha: 0.0, completion: { [weak clearingNode] _ in
|
||||||
|
clearingNode?.removeFromSupernode()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
clearingNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, delay: delay, removeOnCompletion: false, completion: { [weak clearingNode] _ in
|
||||||
|
clearingNode?.removeFromSupernode()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1646,6 +1664,7 @@ final class StorageUsageScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.statsDisposable = (component.context.engine.resources.collectStorageUsageStats()
|
self.statsDisposable = (component.context.engine.resources.collectStorageUsageStats()
|
||||||
|
|> delay(0.18, queue: .mainQueue())
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] stats in
|
|> deliverOnMainQueue).start(next: { [weak self] stats in
|
||||||
guard let self, let component = self.component else {
|
guard let self, let component = self.component else {
|
||||||
completion()
|
completion()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user