Various Improvements

This commit is contained in:
Ilya Laktyushin
2021-09-17 21:25:13 +03:00
parent 151a472294
commit 1f285271b2
22 changed files with 407 additions and 91 deletions

View File

@@ -925,46 +925,60 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
}))
}
func transitionToProgressWithValue(signal: Signal<Float?, NoError>) {
func transitionToProgressWithValue(signal: Signal<Float?, NoError>, dismissImmediately: Bool = false) {
self.inputFieldNode.deactivateInput()
let transition = ContainedViewLayoutTransition.animated(duration: 0.12, curve: .easeInOut)
transition.updateAlpha(node: self.actionButtonNode, alpha: 0.0)
transition.updateAlpha(node: self.inputFieldNode, alpha: 0.0)
transition.updateAlpha(node: self.actionSeparatorNode, alpha: 0.0)
transition.updateAlpha(node: self.actionsBackgroundNode, alpha: 0.0)
self.transitionToContentNode(ShareLoadingContainerNode(theme: self.presentationData.theme, forceNativeAppearance: true), fastOut: true)
let timestamp = CACurrentMediaTime()
var wasDone = false
let doneImpl: (Bool) -> Void = { [weak self] shouldDelay in
let minDelay: Double = shouldDelay ? 0.9 : 0.6
let delay = max(minDelay, (timestamp + minDelay) - CACurrentMediaTime())
Queue.mainQueue().after(delay, {
if dismissImmediately {
self.animateOut(shared: true, completion: {})
self.shareDisposable.set((signal
|> deliverOnMainQueue).start(next: { _ in
}, completed: { [weak self] in
if let strongSelf = self {
strongSelf.animateOut(shared: true, completion: {
self?.dismiss?(true)
})
strongSelf.dismiss?(true)
}
})
}))
} else {
let transition = ContainedViewLayoutTransition.animated(duration: 0.12, curve: .easeInOut)
transition.updateAlpha(node: self.actionButtonNode, alpha: 0.0)
transition.updateAlpha(node: self.inputFieldNode, alpha: 0.0)
transition.updateAlpha(node: self.actionSeparatorNode, alpha: 0.0)
transition.updateAlpha(node: self.actionsBackgroundNode, alpha: 0.0)
self.transitionToContentNode(ShareLoadingContainerNode(theme: self.presentationData.theme, forceNativeAppearance: true), fastOut: true)
let timestamp = CACurrentMediaTime()
var wasDone = false
let doneImpl: (Bool) -> Void = { [weak self] shouldDelay in
let minDelay: Double = shouldDelay ? 0.9 : 0.6
let delay = max(minDelay, (timestamp + minDelay) - CACurrentMediaTime())
Queue.mainQueue().after(delay, {
if let strongSelf = self {
strongSelf.animateOut(shared: true, completion: {
self?.dismiss?(true)
})
}
})
}
self.shareDisposable.set((signal
|> deliverOnMainQueue).start(next: { [weak self] status in
guard let strongSelf = self, let contentNode = strongSelf.contentNode as? ShareLoadingContainerNode else {
return
}
if let status = status {
contentNode.state = .progress(status)
}
}, completed: { [weak self] in
guard let strongSelf = self, let contentNode = strongSelf.contentNode as? ShareLoadingContainerNode else {
return
}
contentNode.state = .done
if !wasDone {
wasDone = true
doneImpl(true)
}
}))
}
self.shareDisposable.set((signal
|> deliverOnMainQueue).start(next: { [weak self] status in
guard let strongSelf = self, let contentNode = strongSelf.contentNode as? ShareLoadingContainerNode else {
return
}
if let status = status {
contentNode.state = .progress(status)
}
}, completed: { [weak self] in
guard let strongSelf = self, let contentNode = strongSelf.contentNode as? ShareLoadingContainerNode else {
return
}
contentNode.state = .done
if !wasDone {
wasDone = true
doneImpl(true)
}
}))
}
}