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

Default splitter #35

Open
aehlke opened this issue Feb 27, 2024 · 2 comments
Open

Default splitter #35

aehlke opened this issue Feb 27, 2024 · 2 comments

Comments

@aehlke
Copy link

aehlke commented Feb 27, 2024

I believe these splitter specs are reasonably close to the iOS system default:

bar color: Color.secondary.opacity(colorScheme == .dark ? 0.7 : 0.5)
bar thickness: 5
bar invisible thickness (but also as padding, not just an unclipped ZStack): I'm not sure but the default has some padding typically of approximately 16 or so on either side, could measure this
Shape: Capsule rather than RoundedRectangle

On macOS I believe it's simply a Divider() by default, with some tolerance on either side.

Secondly, there's no precedence for split views on iOS. Even iPad splitters are static and unmovable Divider()s. So I recommend (if you wanted to make this view fully native feeling out of the box) having something that behaves more like a sheet/popover on iOS, at least in "compact" mode, such as that it has rounded corners at one end, or perhaps even in fact using the new presentationDetent APIs with the very new API for allowing interaction with an undimmed background. However that's less flexible than this currently so some visual stand-in can work.

It's trivial at least to have a groupbox for a view, and a clear background so that the divider floats between rounded groupbox containers. That would feel native on iOS and not require library changes

@stevengharris
Copy link
Owner

Although everything works on iOS, I only have expectations of it being useful on an iPad. I my own usage, I just drop back to navigation to full screen views on an iPhone when I'm using a SplitView on the Mac (using Catalyst). As you say, I don't think there is any precedence for a splitter on iOS, so I am just avoiding it myself to avoid confusing users and cramping the screen. For these reasons, I don't really feel motivated to invest in a more native default for iOS, although if you created one that could be made visible via Splitter+Extensions.swift, I would love to take a PR on it.

On the Mac, where I'm not using a custom Splitter, I have just been using .splitter { Splitter.line() }. I wonder if I could something more like Splitter.macOS that used Divider, so that it automatically gets the right color. Did you find Color.secondary.opacity(colorScheme == .dark ? 0.7 : 0.5) at some reputable source, or it it just a guess, and do you know if that applies to Dividers? I'd still need to force a default width so that the mechanics of splitting the view works properly.

Altho I'm using a RoundedRectangle for the default splitter, it should be the same as Capsule since the radius is always half the width.

@aehlke
Copy link
Author

aehlke commented Feb 29, 2024

Thanks for your thoughts! I can contribute my experiments a bit later

The opacity is just from eyeballing it, I can measure more exactly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants