Various fixes

This commit is contained in:
Ilya Laktyushin
2022-07-14 20:46:23 +02:00
124 changed files with 3573 additions and 618 deletions

View File

@@ -666,8 +666,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}*/
case let .controller(source):
let transitionInfo = source.transitionInfo()
if let transitionInfo = transitionInfo, let (sourceNode, sourceNodeRect) = transitionInfo.sourceNode() {
let contentParentNode = ContextControllerContentNode(sourceNode: sourceNode, controller: source.controller, tapped: { [weak self] in
if let transitionInfo = transitionInfo, let (sourceView, sourceNodeRect) = transitionInfo.sourceNode() {
let contentParentNode = ContextControllerContentNode(sourceView: sourceView, controller: source.controller, tapped: { [weak self] in
self?.attemptTransitionControllerIntoNavigation()
})
self.contentContainerNode.contentNode = .controller(contentParentNode)
@@ -676,7 +676,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
self.contentContainerNode.cornerRadius = 14.0
self.contentContainerNode.addSubnode(contentParentNode)
let projectedFrame = convertFrame(sourceNodeRect, from: sourceNode.view, to: self.view)
let projectedFrame = convertFrame(sourceNodeRect, from: sourceView, to: self.view)
self.originalProjectedContentViewFrame = (projectedFrame, projectedFrame)
}
}
@@ -713,8 +713,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}
case let .controller(source):
let transitionInfo = source.transitionInfo()
if let transitionInfo = transitionInfo, let (sourceNode, sourceNodeRect) = transitionInfo.sourceNode() {
let projectedFrame = convertFrame(sourceNodeRect, from: sourceNode.view, to: self.view)
if let transitionInfo = transitionInfo, let (sourceView, sourceNodeRect) = transitionInfo.sourceNode() {
let projectedFrame = convertFrame(sourceNodeRect, from: sourceView, to: self.view)
self.originalProjectedContentViewFrame = (projectedFrame, projectedFrame)
var updatedContentAreaInScreenSpace = transitionInfo.contentAreaInScreenSpace
@@ -857,7 +857,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
if let contentNode = self.contentContainerNode.contentNode, case let .controller(controller) = contentNode {
let snapshotView: UIView? = nil// controller.sourceNode.view.snapshotContentTree()
if let snapshotView = snapshotView {
controller.sourceNode.isHidden = true
controller.sourceView.isHidden = true
self.view.insertSubview(snapshotView, belowSubview: self.contentContainerNode.view)
snapshotView.layer.animateSpring(from: NSValue(cgPoint: localSourceFrame.center), to: NSValue(cgPoint: CGPoint(x: self.contentContainerNode.frame.midX, y: self.contentContainerNode.frame.minY + localSourceFrame.height / 2.0)), keyPath: "position", duration: springDuration, initialVelocity: 0.0, damping: springDamping, removeOnCompletion: false)
@@ -1166,8 +1166,8 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
var completedContentNode = false
var completedActionsNode = false
if let transitionInfo = transitionInfo, let (sourceNode, sourceNodeRect) = transitionInfo.sourceNode() {
let projectedFrame = convertFrame(sourceNodeRect, from: sourceNode.view, to: self.view)
if let transitionInfo = transitionInfo, let (sourceView, sourceNodeRect) = transitionInfo.sourceNode() {
let projectedFrame = convertFrame(sourceNodeRect, from: sourceView, to: self.view)
self.originalProjectedContentViewFrame = (projectedFrame, projectedFrame)
var updatedContentAreaInScreenSpace = transitionInfo.contentAreaInScreenSpace
@@ -1251,13 +1251,13 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
self.contentContainerNode.layer.animatePosition(from: CGPoint(), to: contentContainerOffset, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false, additive: true, completion: { [weak self] _ in
completedContentNode = true
if let strongSelf = self, let contentNode = strongSelf.contentContainerNode.contentNode, case let .controller(controller) = contentNode {
controller.sourceNode.isHidden = false
controller.sourceView.isHidden = false
}
intermediateCompletion()
})
} else {
if let contentNode = self.contentContainerNode.contentNode, case let .controller(controller) = contentNode {
controller.sourceNode.isHidden = false
controller.sourceView.isHidden = false
}
if let snapshotView = controller.view.snapshotContentTree(keepTransform: true) {
@@ -1768,12 +1768,12 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}
}
case let .controller(contentParentNode):
var projectedFrame: CGRect = convertFrame(contentParentNode.sourceNode.bounds, from: contentParentNode.sourceNode.view, to: self.view)
var projectedFrame: CGRect = convertFrame(contentParentNode.sourceView.bounds, from: contentParentNode.sourceView, to: self.view)
switch self.source {
case let .controller(source):
let transitionInfo = source.transitionInfo()
if let (sourceNode, sourceRect) = transitionInfo?.sourceNode() {
projectedFrame = convertFrame(sourceRect, from: sourceNode.view, to: self.view)
if let (sourceView, sourceRect) = transitionInfo?.sourceNode() {
projectedFrame = convertFrame(sourceRect, from: sourceView, to: self.view)
}
default:
break
@@ -2150,9 +2150,9 @@ public extension ContextExtractedContentSource {
public final class ContextControllerTakeControllerInfo {
public let contentAreaInScreenSpace: CGRect
public let sourceNode: () -> (ASDisplayNode, CGRect)?
public let sourceNode: () -> (UIView, CGRect)?
public init(contentAreaInScreenSpace: CGRect, sourceNode: @escaping () -> (ASDisplayNode, CGRect)?) {
public init(contentAreaInScreenSpace: CGRect, sourceNode: @escaping () -> (UIView, CGRect)?) {
self.contentAreaInScreenSpace = contentAreaInScreenSpace
self.sourceNode = sourceNode
}