slackhq / PanModal

An elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.
MIT License
3.68k stars 531 forks source link

Present view controller without animation doesn't work #130

Open ton252 opened 3 years ago

ton252 commented 3 years ago

I've tried to present panviewcontroller without animation in example project and it doesn't work. For example if we change animated: true

present(viewControllerToPresent, animated: true, completion: completion)

to animated: false

present(viewControllerToPresent, animated: false, completion: completion)

it stops working

lauraweaver commented 3 years ago

Hi @ton252! I will look into this early next week. Thank you for reporting!

ton252 commented 3 years ago

May be It will help you. The problem is in presentationTransitionWillBegin method and in adjustPresentedViewFrame. If for example wrap this method in DispatchQueue.main.async this will fix the bug. Something like this:

override public func presentationTransitionWillBegin() {
        guard let containerView = containerView else { return }

        layoutBackgroundView(in: containerView)
        layoutPresentedView(in: containerView)
        configureScrollViewInsets()

        guard let coordinator = presentedViewController.transitionCoordinator else {
            backgroundView.dimState = .max
            return
        }

        coordinator.animate(alongsideTransition: { [weak self] _ in
            self?.backgroundView.dimState = .max
            self?.presentedViewController.setNeedsStatusBarAppearanceUpdate()
        })

        // HotFix
        DispatchQueue.main.asyncAfter(deadline: .now()) { [weak self] in
            self?.adjustPresentedViewFrame()
        }
    }

I think the problem is in layout calculation cycle. Maybe adjustPresentedViewFrame needs to be called again in other places. I hope this will help you to find the bug

Albert-Jr commented 3 years ago

I've encountered the same issue. Have you guys already have a solution on this one?

BeingCode commented 2 years ago

@ton252 @lauraweaver Has the problem been solved