Skip to content

Commit dc0a09f

Browse files
committed
Remove extra backgroundFillView for the pop animation as can use the AlbumsViewController.view directly
1 parent 7f437a7 commit dc0a09f

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

custom-transitions/Transitions/TransitionManager.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ final class TransitionManager: NSObject, UIViewControllerAnimatedTransitioning {
1111

1212
private let duration: TimeInterval
1313
private var operation = UINavigationController.Operation.push
14-
private var popSnapshots = [UIViewController: UIView]()
1514

1615
init(duration: TimeInterval) {
1716
self.duration = duration
@@ -64,8 +63,6 @@ private extension TransitionManager {
6463
let detailsViewController = toViewController as? AlbumDetailViewController
6564
else { return }
6665

67-
popSnapshots[albumsViewController] = fromViewController.view.snapshotView(afterScreenUpdates: false)
68-
6966
presentViewController(detailsViewController, from: albumsViewController, with: context)
7067

7168
case .pop:
@@ -140,17 +137,6 @@ private extension TransitionManager {
140137

141138
let containerView = context.containerView
142139

143-
let backgroundFillView: UIView
144-
if let snapshot = popSnapshots[toViewController] {
145-
backgroundFillView = snapshot
146-
backgroundFillView.frame = fromViewController.view.frame
147-
popSnapshots[toViewController] = nil
148-
} else {
149-
backgroundFillView = UIView()
150-
backgroundFillView.frame = fromViewController.view.frame
151-
AlbumsViewController.setupBackgroundColor(for: backgroundFillView)
152-
}
153-
154140
let snapshotContentView = UIView()
155141
snapshotContentView.backgroundColor = albumDetailRootView.backgroundColor
156142
snapshotContentView.frame = albumDetailRootView.frame
@@ -163,13 +149,10 @@ private extension TransitionManager {
163149
snapshotAlbumCoverImageView.layer.cornerRadius = albumDetailHeaderView.layer.cornerRadius
164150
snapshotAlbumCoverImageView.frame = containerView.convert(albumDetailHeaderView.albumCoverImageView.frame, from: albumDetailHeaderView)
165151

166-
containerView.addSubview(backgroundFillView)
167152
containerView.addSubview(toViewController.view)
168153
containerView.addSubview(snapshotContentView)
169154
containerView.addSubview(snapshotAlbumCoverImageView)
170155

171-
toViewController.view.isHidden = true
172-
173156
let animator = UIViewPropertyAnimator(duration: duration, curve: .easeInOut) {
174157
snapshotContentView.frame = containerView.convert(albumCell.contentView.frame, from: albumCell)
175158
snapshotContentView.backgroundColor = albumCell.contentView.backgroundColor
@@ -178,8 +161,6 @@ private extension TransitionManager {
178161
}
179162

180163
animator.addCompletion { position in
181-
toViewController.view.isHidden = false
182-
backgroundFillView.removeFromSuperview()
183164
snapshotAlbumCoverImageView.removeFromSuperview()
184165
snapshotContentView.removeFromSuperview()
185166
context.completeTransition(position == .end)

0 commit comments

Comments
 (0)