Skip to content

Commit

Permalink
Improved the presentation animation of floating popup bars.
Browse files Browse the repository at this point in the history
  • Loading branch information
iDevelopper committed Jan 22, 2024
1 parent b91d914 commit a07a316
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ internal class PBPopupPresentationController: UIPresentationController
self.popupContentView.frame = self.popupContentViewFrameForPopupStateClosed(finish: true, isInteractive: true)
}
presentedView.frame = self.presentedViewFrame()
self.popupBarForPresentation?.center.x = self.popupContentView.contentView.center.x
self.popupBarForPresentation?.center.x = self.popupContentView.bounds.center.x
self.animateBottomBarToHidden(false)
self.animateBackingViewToDeck(false, animated: true)
self.animateImageViewInFinalPosition()
Expand Down Expand Up @@ -476,9 +476,7 @@ extension PBPopupPresentationController: UIViewControllerAnimatedTransitioning
self.popupContentView.frame = self.popupContentViewFrameForPopupStateClosed(finish: false)
}
presentedView?.frame = self.presentedViewFrame()

self.popupBarForPresentation?.center.x = self.popupContentView.contentView.center.x


self.containerView?.layoutIfNeeded()

self.popupContentView.isHidden = false
Expand All @@ -489,8 +487,6 @@ extension PBPopupPresentationController: UIViewControllerAnimatedTransitioning
self.popupContentView.frame = self.popupContentViewFrameForPopupStateOpen()
presentedView?.frame = self.presentedViewFrame()

self.popupBarForPresentation?.center.x = self.popupContentView.contentView.center.x

self.animateBottomBarToHidden(true)

self.animateBottomModuleInFinalPosition()
Expand All @@ -514,8 +510,8 @@ extension PBPopupPresentationController: UIViewControllerAnimatedTransitioning
self.popupContentView.frame = self.popupContentViewFrameForPopupStateOpen()
presentedView?.frame = self.presentedViewFrame()

self.popupBarForPresentation?.center.x = self.popupContentView.contentView.center.x
self.popupBarForPresentation?.center.x = self.popupContentView.bounds.center.x

self.containerView?.layoutIfNeeded()

self.animateBottomBarToHidden(true)
Expand All @@ -529,7 +525,7 @@ extension PBPopupPresentationController: UIViewControllerAnimatedTransitioning
}
presentedView?.frame = self.presentedViewFrame()

self.popupBarForPresentation?.center.x = self.popupContentView.contentView.center.x
self.popupBarForPresentation?.center.x = self.popupContentView.bounds.center.x

if !transitionContext.isInteractive {
self.animateBottomBarToHidden(false)
Expand Down Expand Up @@ -979,7 +975,7 @@ extension PBPopupPresentationController
imageRect.size.width += x
}

//for debug
// TODO: For debug
//let image = presentingVC.view.makeSnapshot(from: imageRect)

var snapshotView = self.presentingVC.view!
Expand Down Expand Up @@ -1062,13 +1058,13 @@ extension PBPopupPresentationController

let rect = self.popupContentViewFrameForPopupStateClosed(finish: true)

//for debug
// TODO: For debug
//let image = self.presentingVC.view.makeSnapshot(from: rect)

let view = self.presentingVC.view.resizableSnapshotView(from: rect, afterScreenUpdates: true, withCapInsets: .zero)

if popupBar.popupBarStyle == .prominent {
self.presentingVC.popupBar.shadowImageView.isHidden = false
popupBar.shadowImageView.isHidden = false
}

if isFloating, let view = view {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,6 @@ class FirstTableViewController: UITableViewController, PBPopupControllerDataSour
}
}
#endif
/*
if let popupContentView = self.containerVC.popupContentView {
popupContentView.popupIgnoreDropShadowView = false
popupContentView.popupPresentationDuration = 0.4
popupContentView.popupCanDismissOnPassthroughViews = true
//popupContentView.popupContentDraggingView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 200))
}
self.containerVC.popupController.containerPreferredStatusBarStyle = .default
self.containerVC.popupController.popupPreferredStatusBarStyle = .lightContent
*/
self.tableView.reloadData()
}
}
Expand Down Expand Up @@ -448,8 +437,10 @@ class FirstTableViewController: UITableViewController, PBPopupControllerDataSour
//containerVC.popupBar.titleTextAttributes = [NSAttributedString.Key.paragraphStyle: paragraphStyle, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 24)]

if let popupContentView = self.containerVC.popupContentView {
// TODO:
//popupContentView.popupEffectView.effect = nil
popupContentView.popupIgnoreDropShadowView = false
popupContentView.popupPresentationDuration = 0.4
//popupContentView.popupPresentationDuration = 0.4
popupContentView.popupCanDismissOnPassthroughViews = true
//popupContentView.popupContentDraggingView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 200))
}
Expand Down

0 comments on commit a07a316

Please sign in to comment.