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

feat: impl "Sheets" like behavior #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PanModal/Controller/PanModalPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private extension PanModalPresentationController {
in the presentation animator instead of here
*/
containerView.addSubview(presentedView)
containerView.addGestureRecognizer(panGestureRecognizer)
presentedView.addGestureRecognizer(panGestureRecognizer)
Copy link
Author

@toshi0383 toshi0383 Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required but breaking change here.
IMO this makes more sense though, because the background area shouldn't be pull-to-dismissable.


if presentable.showDragIndicator {
addDragIndicatorView(to: presentedView)
Expand Down
25 changes: 24 additions & 1 deletion Sample/SampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,29 @@

import UIKit

/// Allow touches to go through containerView which `isUserInteractionEnabled` is false.
private class HitTestView: UITableView {
weak var hitTestDelegateView: UIView?

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let delegateView = hitTestDelegateView, delegateView.superview != nil {
if let view = delegateView.hitTest(convert(point, to: delegateView), with: event) {
return view
}
}

return super.hitTest(point, with: event)
}
}

class SampleViewController: UITableViewController {

private let hitTestView = HitTestView()

override func loadView() {
self.tableView = hitTestView
}

override func viewDidLoad() {
super.viewDidLoad()
setupView()
Expand Down Expand Up @@ -54,7 +75,9 @@ class SampleViewController: UITableViewController {
return
}
dismiss(animated: true, completion: nil)
presentPanModal(rowType.presentable.rowVC)
let vc = rowType.presentable.rowVC
hitTestView.hitTestDelegateView = vc.view
Copy link
Author

@toshi0383 toshi0383 Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containerView have to be isUserInteractionEnabled: false to enable user interaction in presentingVC, so this did the trick to also enable it in presentedVC.

presentPanModal(vc)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class UserGroupViewController: UITableViewController, PanModalPresentable {
return false
}

let panModalBackgroundColor: UIColor = .clear
let isUserInteractionEnabled: Bool = false

func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool {
let location = panModalGestureRecognizer.location(in: view)
return headerView.frame.contains(location)
Expand Down