mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-26 08:45:25 +01:00
fix: image preview transition using wrong mask when nest as child controller issue
This commit is contained in:
parent
55b2823de5
commit
4a6b2a9d1d
@ -163,10 +163,17 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
|||||||
var needsMaskWithAnimation = true
|
var needsMaskWithAnimation = true
|
||||||
let maskLayerToRect: CGRect? = {
|
let maskLayerToRect: CGRect? = {
|
||||||
guard case .mosaic = transitionItem.source else { return nil }
|
guard case .mosaic = transitionItem.source else { return nil }
|
||||||
guard let navigationBar = toVC.navigationController?.navigationBar else { return nil }
|
guard let navigationBar = toVC.navigationController?.navigationBar, let navigationBarSuperView = navigationBar.superview else { return nil }
|
||||||
let navigationBarFrameInWindow = toVC.view.convert(navigationBar.frame, to: nil)
|
let navigationBarFrameInWindow = navigationBarSuperView.convert(navigationBar.frame, to: nil)
|
||||||
|
|
||||||
|
// crop rect top edge
|
||||||
var rect = transitionMaskView.frame
|
var rect = transitionMaskView.frame
|
||||||
rect.origin.y = navigationBarFrameInWindow.maxY + UIView.separatorLineHeight(of: toVC.view) // extra hairline
|
let _toViewFrameInWindow = toVC.view.superview.flatMap { $0.convert(toVC.view.frame, to: nil) }
|
||||||
|
if let toViewFrameInWindow = _toViewFrameInWindow, toViewFrameInWindow.minY > navigationBarFrameInWindow.maxY {
|
||||||
|
rect.origin.y = toViewFrameInWindow.minY
|
||||||
|
} else {
|
||||||
|
rect.origin.y = navigationBarFrameInWindow.maxY + UIView.separatorLineHeight(of: toVC.view) // extra hairline
|
||||||
|
}
|
||||||
|
|
||||||
if rect.minY < snapshot.frame.minY {
|
if rect.minY < snapshot.frame.minY {
|
||||||
needsMaskWithAnimation = false
|
needsMaskWithAnimation = false
|
||||||
@ -177,8 +184,8 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
|||||||
let maskLayerToPath = maskLayerToRect.flatMap { UIBezierPath(rect: $0) }?.cgPath
|
let maskLayerToPath = maskLayerToRect.flatMap { UIBezierPath(rect: $0) }?.cgPath
|
||||||
let maskLayerToFinalRect: CGRect? = {
|
let maskLayerToFinalRect: CGRect? = {
|
||||||
guard case .mosaic = transitionItem.source else { return nil }
|
guard case .mosaic = transitionItem.source else { return nil }
|
||||||
guard let tabBarController = toVC.tabBarController else { return nil }
|
guard let tabBarController = toVC.tabBarController, let tabBarSuperView = tabBarController.tabBar.superview else { return nil }
|
||||||
let tabBarFrameInWindow = toVC.view.convert(tabBarController.tabBar.frame, to: nil)
|
let tabBarFrameInWindow = tabBarSuperView.convert(tabBarController.tabBar.frame, to: nil)
|
||||||
var rect = maskLayerToRect ?? transitionMaskView.frame
|
var rect = maskLayerToRect ?? transitionMaskView.frame
|
||||||
let offset = rect.maxY - tabBarFrameInWindow.minY
|
let offset = rect.maxY - tabBarFrameInWindow.minY
|
||||||
guard offset > 0 else { return rect }
|
guard offset > 0 else { return rect }
|
||||||
@ -411,10 +418,17 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
|||||||
var needsMaskWithAnimation = true
|
var needsMaskWithAnimation = true
|
||||||
let maskLayerToRect: CGRect? = {
|
let maskLayerToRect: CGRect? = {
|
||||||
guard case .mosaic = transitionItem.source else { return nil }
|
guard case .mosaic = transitionItem.source else { return nil }
|
||||||
guard let navigationBar = toVC.navigationController?.navigationBar else { return nil }
|
guard let navigationBar = toVC.navigationController?.navigationBar, let navigationBarSuperView = navigationBar.superview else { return nil }
|
||||||
let navigationBarFrameInWindow = toVC.view.convert(navigationBar.frame, to: nil)
|
let navigationBarFrameInWindow = navigationBarSuperView.convert(navigationBar.frame, to: nil)
|
||||||
|
|
||||||
|
// crop rect top edge
|
||||||
var rect = transitionMaskView.frame
|
var rect = transitionMaskView.frame
|
||||||
rect.origin.y = navigationBarFrameInWindow.maxY
|
let _toViewFrameInWindow = toVC.view.superview.flatMap { $0.convert(toVC.view.frame, to: nil) }
|
||||||
|
if let toViewFrameInWindow = _toViewFrameInWindow, toViewFrameInWindow.minY > navigationBarFrameInWindow.maxY {
|
||||||
|
rect.origin.y = toViewFrameInWindow.minY
|
||||||
|
} else {
|
||||||
|
rect.origin.y = navigationBarFrameInWindow.maxY + UIView.separatorLineHeight(of: toVC.view) // extra hairline
|
||||||
|
}
|
||||||
|
|
||||||
if rect.minY < snapshot.frame.minY {
|
if rect.minY < snapshot.frame.minY {
|
||||||
needsMaskWithAnimation = false
|
needsMaskWithAnimation = false
|
||||||
@ -430,8 +444,8 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
|||||||
|
|
||||||
let maskLayerToFinalRect: CGRect? = {
|
let maskLayerToFinalRect: CGRect? = {
|
||||||
guard case .mosaic = transitionItem.source else { return nil }
|
guard case .mosaic = transitionItem.source else { return nil }
|
||||||
guard let tabBarController = toVC.tabBarController else { return nil }
|
guard let tabBarController = toVC.tabBarController, let tabBarSuperView = tabBarController.tabBar.superview else { return nil }
|
||||||
let tabBarFrameInWindow = toVC.view.convert(tabBarController.tabBar.frame, to: nil)
|
let tabBarFrameInWindow = tabBarSuperView.convert(tabBarController.tabBar.frame, to: nil)
|
||||||
var rect = maskLayerToRect ?? transitionMaskView.frame
|
var rect = maskLayerToRect ?? transitionMaskView.frame
|
||||||
let offset = rect.maxY - tabBarFrameInWindow.minY
|
let offset = rect.maxY - tabBarFrameInWindow.minY
|
||||||
guard offset > 0 else { return rect }
|
guard offset > 0 else { return rect }
|
||||||
|
Loading…
Reference in New Issue
Block a user