Settings icon indicating copy to clipboard operation
Settings copied to clipboard

Animate Window Size based on content change

Open davidwernhart opened this issue 2 years ago • 2 comments

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 avatar Dec 16 '22 08:12 davidwernhart

@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.

DivineDominion avatar Dec 31 '22 10:12 DivineDominion

@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

davidwernhart avatar Dec 31 '22 11:12 davidwernhart