scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.61k stars 510 forks source link

[SwiftUI] UIViewControllerRepresentable #627

Open Taehyeong-Jo opened 6 months ago

Taehyeong-Jo commented 6 months ago

Description

Currently, we are working on converting to SwiftUI. After wrapping the MyViewController created using FloatingPanelController with UIViewControllerRepresentable When I call it from SwiftUI, it doesn't work properly.


Expected behavior

View should appear properly.


Actual behavior

View is not visible.


Steps to reproduce

https://github.com/Taehyeong-Jo/FloatingPanelTest This is a sample project.



How do you display panel(s)?


How many panels do you displays?


Environment

Library version v 2.8.2


Installation method SPM

iOS version(s) iOS 17.4.1

Xcode version 15.3

scenee commented 6 months ago

We can't use FloatingPanelController with UIViewControllerRepresentable directly in SwiftUI. Because FloatingPanelController needs to be added into a parent view controller.

Maps-SwiftUI sample code is very helpful to use it in SwiftUI. It defines FloatingPanelView to wrap FloatingPanelController with a UIHostingViewController to resolve the restriction.