Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presenting view controller no longer gets safe area updates once a PanModal has been presented on it #139

Open
4 of 9 tasks
kylehickinson opened this issue Mar 22, 2021 · 0 comments · May be fixed by #140
Open
4 of 9 tasks

Comments

@kylehickinson
Copy link

kylehickinson commented Mar 22, 2021

Description

Presenting a pan modal on a view controller will cause iOS to stop updating the safe area insets on the presenting controller while the pan modal is presented.

The root reason for this problem is because PanModal calls appearance transition methods (beginAppearanceTransition and endAppearanceTransition) on the presenting controller which are supposed to be called on child controllers.

You can further see that presenting a view controller using overFullScreen, overCurrentContext or simply presenting using iOS 13+ style sheets do not call appearance transition methods on the presenting controller since it still exists in the view hierarchy and thus are not actually "disappearing" on presentation and "appearing" on dismissal.

I think that PanModal reflects an overFullScreen modal presentation style, therefore should act the same and not call appearance transition methods

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

PanModal version: 1.27

iOS version: 14.4

Note: This is only reproducible where the trait collection does not change since PanModal does not support transitioning between regular & compact width.

Steps to reproduce:

  1. Constrain something on presenting view controller to safe area
  2. Present PanModal
  3. Rotate to different orientation

Expected result:

Safe area of presenting controller should update and constrained views update along with that

Actual result:

Safe area does not update.

Attachments:

Consider this red rectangle constrained to the safeAreaLayoutGuide of the presenting VC

Default Portrait Default Landscape
default-portrait default-landscape

And see what happens when you present a pan modal then rotate it:

Rotated Portrait to Landscape Rotated Landscape to Portrait
rotated-to-landscape rotated-to-portrait

Edit: Updated images to use black bg to make it more obvious on GitHub's light theme

This can be reproduced with this simple code:

import UIKit
import PanModal

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    
    let exampleView = UIView()
    exampleView.backgroundColor = .red
    exampleView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(exampleView)
    
    exampleView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
    exampleView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
    exampleView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
    exampleView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
    
    let tap = UITapGestureRecognizer(target: self, action: #selector(tappedView))
    exampleView.addGestureRecognizer(tap)
  }
  
  @objc private func tappedView() {
    presentPanModal(PanViewController())
  }
}

class PanViewController: UIViewController, PanModalPresentable {
  override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = .white
  }
  var panScrollable: UIScrollView? {
    nil
  }
  var shortFormHeight: PanModalHeight {
    .contentHeight(100)
  }
  var longFormHeight: PanModalHeight {
    .maxHeight
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant