Fix profile tab switching animation ending in bad state
Caused by fda0c18794
, old/new.view is no
longer the same as .collectionView, so the transform wasn't being
properly reset.
Closes #536
This commit is contained in:
parent
cc696e58fc
commit
57c023c973
|
@ -213,7 +213,7 @@ class ProfileViewController: UIViewController, StateRestorableViewController {
|
||||||
|
|
||||||
// old header cell must have the header view
|
// old header cell must have the header view
|
||||||
let headerView = oldHeaderCell.addConstraint(height: oldHeaderCell.bounds.height)!
|
let headerView = oldHeaderCell.addConstraint(height: oldHeaderCell.bounds.height)!
|
||||||
// Set the outgoing VC's header view mode to placeholder, so that it does steal the header view back
|
// Set the outgoing VC's header view mode to placeholder, so that it does not steal the header view back
|
||||||
// in case it updates the cell in the background.
|
// in case it updates the cell in the background.
|
||||||
old.headerViewMode = .placeholder(height: oldHeaderCell.bounds.height)
|
old.headerViewMode = .placeholder(height: oldHeaderCell.bounds.height)
|
||||||
|
|
||||||
|
@ -224,12 +224,13 @@ class ProfileViewController: UIViewController, StateRestorableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable user interaction during animation, to avoid any potential weird race conditions
|
// disable user interaction during animation, to avoid any potential weird race conditions
|
||||||
headerView.isUserInteractionEnabled = false
|
view.isUserInteractionEnabled = false
|
||||||
|
|
||||||
headerView.layer.zPosition = 100
|
headerView.layer.zPosition = 100
|
||||||
view.addSubview(headerView)
|
view.addSubview(headerView)
|
||||||
let oldHeaderCellTop = oldHeaderCell.convert(CGPoint.zero, to: view).y
|
let oldHeaderCellTop = oldHeaderCell.convert(CGPoint.zero, to: view).y
|
||||||
let headerTopOffset = oldHeaderCellTop - view.safeAreaInsets.top
|
let headerTopOffset = oldHeaderCellTop - view.safeAreaInsets.top
|
||||||
let headerBottomOffset = oldHeaderCell.convert(CGPoint(x: 0, y: oldHeaderCell.bounds.maxY), to: view).y// - view.safeAreaInsets.top
|
let headerBottomOffset = oldHeaderCell.convert(CGPoint(x: 0, y: oldHeaderCell.bounds.maxY), to: view).y
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
headerView.topAnchor.constraint(equalTo: view.topAnchor, constant: headerTopOffset),
|
headerView.topAnchor.constraint(equalTo: view.topAnchor, constant: headerTopOffset),
|
||||||
headerView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: headerBottomOffset),
|
headerView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: headerBottomOffset),
|
||||||
|
@ -272,16 +273,17 @@ class ProfileViewController: UIViewController, StateRestorableViewController {
|
||||||
}
|
}
|
||||||
animator.addCompletion { _ in
|
animator.addCompletion { _ in
|
||||||
old.removeViewAndController()
|
old.removeViewAndController()
|
||||||
old.collectionView.transform = .identity
|
old.view.transform = .identity
|
||||||
|
|
||||||
new.collectionView.transform = .identity
|
new.view.transform = .identity
|
||||||
new.collectionView.contentOffset = origOldContentOffset
|
new.collectionView.contentOffset = origOldContentOffset
|
||||||
|
|
||||||
// reenable scroll indicators after the switching animation is done
|
// reenable scroll indicators after the switching animation is done
|
||||||
old.collectionView.showsVerticalScrollIndicator = true
|
old.collectionView.showsVerticalScrollIndicator = true
|
||||||
new.collectionView.showsVerticalScrollIndicator = true
|
new.collectionView.showsVerticalScrollIndicator = true
|
||||||
|
|
||||||
headerView.isUserInteractionEnabled = true
|
self.view.isUserInteractionEnabled = true
|
||||||
|
|
||||||
headerView.transform = .identity
|
headerView.transform = .identity
|
||||||
headerView.layer.zPosition = 0
|
headerView.layer.zPosition = 0
|
||||||
// move the header view into the new page controller's cell
|
// move the header view into the new page controller's cell
|
||||||
|
|
Loading…
Reference in New Issue