faberNovel / DynamicOverlay

A SwiftUI library that makes easier to develop overlay based interfaces, such as the one presented in the Apple Maps app.
MIT License
210 stars 20 forks source link

Allow gestures on the background view #6

Closed ivopintodasilva closed 3 years ago

ivopintodasilva commented 3 years ago

Hello ๐Ÿ‘‹ First of all, thanks a lot for creating and maintaining this library! ๐Ÿ™

Problem

The issue is described in #2 and #3. When having an overlay view, we are not able to tap or drag the background view.

Solution

Picking up on @matthewcheok's investigation, I created an extra view controller to wrap both the background and overlay views. This way, SwiftUI does not generate the view (between the background and overlay) that prevents gestures from getting to the background view.

In the video below we can see the proposed solution working. It's composed of a view that has one List as the background and another one as the overlay. The video shows that it is possible with this solution to tap and drag the list in the background view as well as maintaining the current overlay behavior.

https://user-images.githubusercontent.com/4477378/110162963-b6a73800-7def-11eb-93b5-014790818efd.mov

Description

If this approach seems sensible to you, I can maybe improve OverlayContainerDynamicOverlayView's naming (or wrap it in a different SwiftUI view) to make it more usable from the caller's perspective and place in the Public folder.

EDIT: Added DynamicOverlay public wrapper SwiftUI component.

Let me know if you have other suggestions as well ๐Ÿ˜ƒ

gaetanzanella commented 3 years ago

Hi @ivopintodasilva, thank u very much for this detailed PR!

I prefer the dynamicOverlay modifier approach but it looks its dead end for nowโ€ฆ I commented your PR.

I should add a CI action.

gaetanzanella commented 3 years ago

Done, please rebase on top of the main branch

gaetanzanella commented 3 years ago

I decided to manage the background in the container view controller directly. It should fix the original issue.