stevengharris / SplitView

A flexible way to split SwiftUI views with a draggable splitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom splitter using drag-to-hide

stevengharris opened this issue · comments

The new drag-to-hide feature does not work properly with custom splitters, or at least with the DemoSplitter provided with the package. That's because drag-to-hide depends on the previewHide published property of SplitStyling, and there really isn't an easy way to observe the change to styling.previewHide. Further, the visibleThickness of SplitDivider protocol - which was the way the Split view and custom splitters communicate what the visibleThickness is to separate the split views - is already held in SplitSettings, making dealing with previewHide more difficult.

To fix the situation, SplitDivider protocol needs to provide access to styling, and the default Splitter needs to hold onto styling, not the Split view. Basically, SplitStyling - which really only applies to how the splitter itself is styled - has to be part of the Splitter itself (and any custom splitter), not the Split view. The various view modifiers all need to be updated to reflect the refactoring.

This change will be compatible with previous versions unless you were using a custom splitter. If you were using a custom splitter, then the SplitDivider protocol you used before has changed to expose styling instead of visibleThickness. The visibleThickness is accessible via the styling (and internally is accommodated in changes to Split view itself). Refer to changes in DemoSplitter if you want a guide to how to adapt any existing custom splitter.