LeoNatan / LNPopupController

A framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
MIT License
3.04k stars 342 forks source link

PopupBar is disappearing after hidesBottomBarWhenPushed #530

Closed STIFFMEISTER-UA closed 1 year ago

STIFFMEISTER-UA commented 1 year ago

Describe the Bug The idea behind this bug is pretty simple. I have the following navigation stack: UITabbarController -> UINavigationController -> UIViewController -> UIViewController. Presenting PopupController from the UITabbarController. For the last UIViewController I must hide both tab bar and popup bar.

Tab bar I'm hiding via hidesBottomBarWhenPushed = true, when pushing the vc. Popup bar via dismissPopupBar in the tab bar controller from the viewWillAppear of the last vc. By this moment everything works as expected. The hitch here is that when I go back I need to show them both again. Tab bar is showing automatically. For showing popupBar I call presentPopupBar(withContentViewController: vc, animated: false) in the tabBar from the viewWillDisappear of the vc. For a second the popupBar appears and then it vanishes leaving an empty space. Any ideas about what is going on here?

To Reproduce UITabbarController -> UINavigationController -> UIViewController -> UIViewController. Push the last vc with hidesBottomBarWhenPushed enabled and popupBar hidden. Try to present popupBar again on going back.

Expected Behavior Popupbar should not disappear.

Additional Context I have created a pet project to reproduce the issue. GitHub

LeoNatan commented 1 year ago

Hello, Presenting/dismissing the popup bar during toolbar or tab bar hiding/showing transition. I suggest you present the popup bar either in viewDidAppear/viewDidDisappear, or, preferably, using

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    transitionCoordinator?.animate(alongsideTransition: nil, completion: { context in
        guard context.isCancelled == false else { return }

        self.tabBarController?.presentPopupBar(withContentViewController: UIViewController(), animated: true)
    })
}