david-swift / SettingsKit-macOS

Add a settings window to a SwiftUI macOS app
https://david-swift.github.io/SettingsKit-macOS/
MIT License
87 stars 2 forks source link

Quick question: is it possible to have "flexible" height? #2

Closed longseespace closed 1 year ago

longseespace commented 1 year ago

Problem

The SettingTab always have a fixed height. Is it possible to have it automatically adjust based on the inside content?

SettingsKit:

CleanShot 2023-07-09 at 12 14 37@2x

Preview app:

CleanShot 2023-07-09 at 12 17 49@2x

Thanks for the good work.

david-swift commented 1 year ago

I've added three new modifiers for changing the width and height of a settings tab in SettingsKit 0.1.7:

frame(width:height:)

If you want to have the width and height of the tab's content (or resizable if the content's width and height is resizable), use:

settingsTab
    .frame()

For specifying another width and/or height, use the width and/or height arguments. If you omit one of the arguments, it will take that value from the content:

settingsTab
    .frame(width: 500, height: 200)

width(_:) and height(_:)

If you want to only change the width without affecting the height or only change the height without affecting the width, use width(_:) or height(_:).


In your case, @longseespace, if you want to make the height adapt to the content, but the width to stay the default width of the settings window, use:

settingsTab
    .height()
longseespace commented 1 year ago

Fantastic work, @david-swift. Can you enable git tip/sponsor? I wanted to sponsor your works (not much anyway, but I hope it helps)

david-swift commented 1 year ago

Thank you very much for the kind offer, @longseespace, however, I currently prefer not to accept tips/sponsorships. Thanks for taking the time to open issues and for your valuable suggestions, that is incredibly helpful!