Closed aehlke closed 1 year ago
I'm using SplitView in an app that I think resembles Xcode in presentation (whether that's a good thing or not, I'm not sure!). In my app, I use the .invisible
style of splitter in SplitView to separate the main work area from the content in the right sidebar using a .invisible
style splitter, so it behaves mostly like Xcode separating code from the Navigator area on the right. On the bottom, I use a custom splitter that has a hide/show button in it, which also looks a lot like the way Xcode separates the Console from the code. When you hide the Console, it still shows the splitter, so you have an easy way to show it again, and so it can still be used to display relevant information in the splitter. When you hide the Console in Xcode, the splitter is still visible.
The splitter is invisible (it's not actually present) when the a view it splits is hidden and the corresponding minPFraction
or minSFraction
is set. You can see the effect by removing the .invisible
splitter in the InvisibleSplitter demo case:
case .invisibleSplitter:
Split(
primary: { Color.green },
secondary: { Color.red }
)
.constraints(minPFraction: 0.2, minSFraction: 0.2)
.layout(demo.holders[0].layout)
.hide(demo.holders[0].hide)
When you hide the side, the splitter disappears, but you also cannot drag from the edge to expose the hidden view.
The bottom line is that if the splitter is visible, it means you can drag it, which is why it's left visible when you hide a view. I didn't want to have a situation where the splitter itself becomes hidden but is still draggable.
If neither the .invisible
splitter nor use of minPFraction
/minSFraction
constraints works, maybe you could put together a custom splitter that meets your needs.
Thanks for the response. I'm using a toolbar button to show/hide the split view, similar to Xcode, because I think that's more in line with user expectations on Apple platforms vs a collapsed yet pullable splitter. I'll look into making a custom splitter; I wasn't able to set the splitter dynamically because the hide holder doesn't seem to publish its changes such that the parent view re-renders. Hopefully I can listen to "hide" state in the custom splitter.
I might also be able to achieve this via the invisible splitter + a border added to the hide-able view itself.
See Xcode for example: when an assistant is collapsed, it has no additional splitter line visible; however with SplitView, the sidebar line thickness "doubles".