Skip to content

Commit

Permalink
Fixed the display of the popup bar and bottom bar shadow line
Browse files Browse the repository at this point in the history
  • Loading branch information
iDevelopper committed May 25, 2024
1 parent 4000dba commit da26d42
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ internal let PBPopupBarImageHeightFloating: CGFloat = 40.0
*/
@objc public var inheritsVisualStyleFromBottomBar: Bool = true {
didSet {
if inheritsVisualStyleFromBottomBar == true {
self.popupController.containerViewController.configurePopupBarFromBottomBar()
}
self.popupController.containerViewController.configurePopupBarFromBottomBar()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,8 @@ extension PBPopupPresentationStyle

UIView.animate(withDuration: animated ? vc.popupBar.popupBarPresentationDuration : 0.0, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0, options: [.curveEaseInOut, .layoutSubviews], animations: {

vc.configureScrollEdgeAppearanceForBottomBar()
vc.configurePopupBarFromBottomBar()

self.popupBarView.frame = self.popupBarViewFrameForPopupStateClosed()
self.popupBarView.alpha = 1.0

Expand Down Expand Up @@ -754,7 +754,7 @@ extension PBPopupPresentationStyle
vc.popupBar.ignoreLayoutDuringTransition = true
UIView.animate(withDuration: animated ? vc.popupBar.popupBarPresentationDuration : 0.0, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0, options: [.curveLinear, .layoutSubviews], animations: {

vc.configureScrollEdgeAppearanceForBottomBar()
vc.configurePopupBarFromBottomBar()

self.popupBarView.frame = contentFrame
self.popupBarView.alpha = 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ internal extension UITabBarController
if self.popupController.popupPresentationState == .presenting {
self.tabBar.scrollEdgeAppearance = self.tabBar.standardAppearance
}
else {
self.tabBar.scrollEdgeAppearance = nil
}
}
#endif
}
Expand All @@ -285,15 +282,22 @@ internal extension UITabBarController

let bottomBarAppearance = self.tabBar.standardAppearance

self.bottomBarAppearance = bottomBarAppearance.copy()
if self.bottomBarAppearance == nil {
self.bottomBarAppearance = bottomBarAppearance.copy()
}

self.popupBar.shadowColor = self.bottomBarAppearance.shadowColor

if self.bottomBarAppearance.shadowColor != nil {
self.popupBar.shadowColor = self.bottomBarAppearance.shadowColor
bottomBarAppearance.shadowColor = self.bottomBarAppearance.shadowColor
if self.popupBar.isFloating, self.popupController.popupPresentationState != .hidden {
if self.popupController.popupPresentationState != .dismissing {
bottomBarAppearance.shadowColor = .clear
}
}

bottomBarAppearance.shadowColor = appearance.shadowColor
if self.popupBar.isFloating {
bottomBarAppearance.shadowColor = .clear
self.tabBar.standardAppearance = bottomBarAppearance
if #available(iOS 15.0, *) {
self.tabBar.scrollEdgeAppearance = bottomBarAppearance
}

if self.popupBar.inheritsVisualStyleFromBottomBar == false {
Expand Down Expand Up @@ -710,9 +714,7 @@ internal extension UINavigationController

if self.popupController.popupPresentationState == .presenting {
self.toolbar.scrollEdgeAppearance = self.toolbar.standardAppearance
}
else {
self.toolbar.scrollEdgeAppearance = nil
self.toolbar.compactScrollEdgeAppearance = self.toolbar.standardAppearance
}
}
#endif
Expand All @@ -728,15 +730,24 @@ internal extension UINavigationController

let bottomBarAppearance = self.toolbar.standardAppearance

self.bottomBarAppearance = bottomBarAppearance.copy()
if self.bottomBarAppearance == nil {
self.bottomBarAppearance = bottomBarAppearance.copy()
}

if self.bottomBarAppearance.shadowColor != nil {
self.popupBar.shadowColor = self.bottomBarAppearance.shadowColor
self.popupBar.shadowColor = self.bottomBarAppearance.shadowColor

bottomBarAppearance.shadowColor = self.bottomBarAppearance.shadowColor
if self.popupBar.isFloating, self.popupController.popupPresentationState != .hidden {
if self.popupController.popupPresentationState != .dismissing {
bottomBarAppearance.shadowColor = .clear
}
}

bottomBarAppearance.shadowColor = appearance.shadowColor
if self.popupBar.isFloating {
bottomBarAppearance.shadowColor = .clear
self.toolbar.standardAppearance = bottomBarAppearance
self.toolbar.compactAppearance = bottomBarAppearance
if #available(iOS 15.0, *) {
self.toolbar.scrollEdgeAppearance = bottomBarAppearance
self.toolbar.compactScrollEdgeAppearance = bottomBarAppearance
}

if self.popupBar.inheritsVisualStyleFromBottomBar == false {
Expand Down Expand Up @@ -1101,7 +1112,6 @@ internal extension UIViewController
@objc func configurePopupBarFromBottomBar()
{
let toolBarAppearance = UIToolbarAppearance()
toolBarAppearance.configureWithDefaultBackground()
self.popupBar.shadowColor = toolBarAppearance.shadowColor

self.popupBar.backgroundColor = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ public extension UIViewController
)
}
}
else {
withUnsafePointer(to: &AssociatedKeys.bottomBarAppearance) {
objc_setAssociatedObject(self, $0, nil, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
}

Expand Down Expand Up @@ -532,8 +537,6 @@ public extension UIViewController
controller.view.setNeedsLayout()
controller.view.layoutIfNeeded()

self.configurePopupBarFromBottomBar()

self.popupController._presentPopupBarAnimated(animated) {
completion?()
}
Expand Down Expand Up @@ -703,7 +706,7 @@ public extension UIViewController
- SeeAlso: `PBPopupBar.inheritsVisualStyleFromBottomBar`.
*/
@objc func updatePopupBarAppearance() {
self.popupBar.inheritsVisualStyleFromBottomBar = true
self.bottomBarAppearance = nil
self.popupBar.updatePopupBarAppearance()
}
}
Expand Down

0 comments on commit da26d42

Please sign in to comment.