-
-
Couldn't load subscription status.
- Fork 59
Sheet Modifier #219
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
base: main
Are you sure you want to change the base?
Sheet Modifier #219
Conversation
…arent sheet itself on AppKit its probably easier to let users handle this by just setting isPresented to false, as the implementation is quite different than on UIKit using windows instead of views. Maybe potential improvement later/in a different pr
…nformance of WinUIBackend and Gtk3Backend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how much of the SwiftUI sheets API you've managed to implement in this PR! Sorry about all the requested changes; they're generally about the internals rather than the API surface. You've had to use a lot of SwiftCrossUI's more obscure internals like the preferences system and the Gtk bindings signal system, so it's completely understandable 😅 I'll test this out on my own devices locally when I get the time (probably tomorrow).
changed comment in appbackend
…smiss No idea why it doesn't get called on programmatic dismissal. Neither like it is now nor through a completion handler of the programmatic dismiss
|
I'm getting package resolution errors when I try to build this PR locally (due to an issue fixed by #224). I believe that merging in the latest changes from main should fix that issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing those initial requested changes! I've got a few new ones (one of which I should've realised during the first review lol; the background colour one).
| case large | ||
|
|
||
| /// A detent at a custom fractional height of the available space. | ||
| /// falling back to medium on iOS 15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved for the one below but not this one. Please add a full stop at the end of the Falls back to ... sentence as well (in both).
Sources/SwiftCrossUI/Views/Modifiers/PresentationModifiers.swift
Outdated
Show resolved
Hide resolved
|
On macOS it appears that the |
# Conflicts: # Package.resolved
Dismissing a sheet up the graph should now lead to every sheet below it getting dismissed too. |
|
The new sheetParent environment value was added due to UIKitBackend.Sheet not being compatible with UIKitBackend.Window, so environment.with(.window, sheet) couldn’t be used. UIKitBackend is also the only (currently sheet-supporting) platform where Backend.Window can’t be used to add a sheet. It needs a UIViewController, accessible trough UIWindow.rootViewController when creating the first sheet. to avoid compiler flags/UIKitBackend specific code in SCUI I decided to make it Any? and let each backend resolve the property/type it needs to create a sheet. This should also be future proof for any other Backend with Window-Sheet incompatibility. I noticed I created sheets always from the main Window before (definetely AppKit, Gtk I’m not sure). Now using the deepest window to present a sheet should solve this and I was able to switch to a non-critical sheet on AppKitBackend (not sure if it would make a difference with the current implementation). I don’t know how we could test wether the z order issue actually is fixed now, due to it appearing to be non deterministic from the layer we are working on. Another nice side effect is a theoretical slight performance improvement in cases where there is a big stack of sheets, because it gets passed the deepest UIViewController instead of needing to loop like before. I was afraid setting the managedAttachedSheet to nil on scope exiting could cause dismiss animation bugs, this doesn’t seem to be the case, but should be kept in mind just in case. Doing it is important though, because otherwise the root window on GtkBackend and AppKitBackend would keep a reference to the entire last presented Sheet Graph: RootWindow Thus it couldn’t be freed up. Like you suggested an AppKitBackend.Sheet now keeps a reference to its background node, if set. tvOS only accepts UIModalPresentationStyle.formSheet starting on 26+. I decided to fall back to UIModalPresentationStyle.overFullscreen for now to allow developers to decide wether they cover the whole View with opaque content or just part of it (overFullscreen isn't opaque by itself). https://developer.apple.com/documentation/uikit/uimodalpresentationstyle/formsheet CI fails with (formSheet unavailable on tvOS), locally it works, if #available(tvOS 26.0, *) {
sheet.modalPresentationStyle = .formSheet
} else {
sheet.modalPresentationStyle = .overFullScreen
}so I only used .overFullScreen for now. I believe thats everything important to know about todays changes. |
Is it already Christmas? No but I brought you a gift anyway.
Jokes aside.
This PR adds the .sheet Modifier, like we know it from SwiftUI with isPresented Binding and optional onDismiss callback.
Also some sheet modifiers:
presentationBackground
presentationDragIndicatorVisibility
presentationCornerRadius
presentationDetents
interactiveDismissDisabled
and Example usage in WindowingExample
support for the modifiers varies quite a bit. most are ignored if unsupported, interactiveDismissDisabled and presentationBackground are required as both shouldn’t be limited by Framework features.
Currently only UIKitBackend, AppKitBackend and GtkBackend support sheets, as I sadly couldn’t get them to work properly on WinUI. I hope someone else can build on the Foundation.
As was to expect, there are some weird quirks:
on UIKitBackend and AppKitBackend sheet content is placed top-leading. On GtkBackend on Linux Text elements are very small without further modification instead of allocation space. Same thing happened on macOS with GtkBackend in the 2nd and 3rd window (before and after my changes).
I expect those to be fixable through SCUI Frontend Code. If you know how to fix those in the Backends, I’d be happy to do so before a merge.