sindresorhus/Preferences

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Animate Window Size based on content change #89

davidwernhart posted onGitHub

Is there a possibility to animate the change in window size, when the size of the content changes? Specifically, it would be useful in SwiftUI.

Thank you and kind regards, David


@davidwernhart The latest release (v2.6.0) animates transitions when you pass animated: true to the PreferencesWindowController initializer. (Which is the default value.) The Example app in the repo also works for the current main here.

I haven't tried to host SwiftUI views inside, though. Could be the content size isn't available at the correct time?

If you could whip up a 4th pane for the Example app that uses SwiftUI and open a PR, that'd be super helpful 🙏


Edit: I just noticed that Settings.Pane is using a SwiftUI NSHostingController already for macOS 10.15, and that's being used in the example app already.

posted by DivineDominion about 2 years ago

@DivineDominion Hey, thank you for your response! :)

I have looked at the example app and it seems like the "accounts" pane is already implemented in SwiftUI. I have added another demo setting that expands/collapses another section in the same pane. Even though the window does animate when switching panes, it does not when the content size changes. I have created a pull request: https://github.com/sindresorhus/Preferences/pull/91

Again, thank you for your help and kind regards

posted by davidwernhart about 2 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests