Fixes incorrect corner radius animation for AppViewController + HeaderContentViewController

This commit is contained in:
Riley Testut
2024-02-15 17:18:53 -06:00
committed by Magesh K
parent fc5355345e
commit d3d609550e
2 changed files with 25 additions and 3 deletions

View File

@@ -266,7 +266,18 @@ final class AppViewController: UIViewController
}
let difference = self.scrollView.contentOffset.y - showNavigationBarThreshold
let range = (headerFrame.height + padding) - (self.navigationController?.navigationBar.bounds.height ?? self.view.safeAreaInsets.top)
let range: Double
if self.presentingViewController == nil && self.parent?.presentingViewController == nil
{
// Not presented modally, so rely on safe area + navigation bar height.
range = (headerFrame.height + padding) - (self.navigationController?.navigationBar.bounds.height ?? self.view.safeAreaInsets.top)
}
else
{
// Presented modally, so rely on maximumContentY.
range = maximumContentY - (maximumContentY - padding - headerFrame.height) - inset
}
let fractionComplete = min(difference, range) / range
self.navigationBarAnimator?.fractionComplete = fractionComplete

View File

@@ -299,7 +299,7 @@ class HeaderContentViewController<Header: UIView, Content: ScrollableContentView
{
statusBarHeight = 20
}
else if let statusBarManager = self.view.window?.windowScene?.statusBarManager
else if let statusBarManager = (self.view.window ?? self.presentedViewController?.view.window)?.windowScene?.statusBarManager
{
statusBarHeight = statusBarManager.statusBarFrame.height
}
@@ -347,7 +347,18 @@ class HeaderContentViewController<Header: UIView, Content: ScrollableContentView
}
let difference = self.scrollView.contentOffset.y - showNavigationBarThreshold
let range = maximumContentY - (maximumContentY - padding - headerFrame.height) - inset
let range: Double
if self.presentingViewController == nil && self.parent?.presentingViewController == nil
{
// Not presented modally, so rely on safe area + navigation bar height.
range = (headerFrame.height + padding) - (self.navigationController?.navigationBar.bounds.height ?? self.view.safeAreaInsets.top)
}
else
{
// Presented modally, so rely on maximumContentY.
range = maximumContentY - (maximumContentY - padding - headerFrame.height) - inset
}
let fractionComplete = min(difference, range) / range
self.navigationBarAnimator?.fractionComplete = fractionComplete