Trying to get into macOS development with SwiftUI, and relatively new to programming in general. Being a fan the zoom behaviour in macOS, decided to start with this behaviour, but stuck in understanding how I need to proceed (following lines may sound as a rant, but it is not ).
SwiftUI views take only the minimum amount of space they occupy, right? So logically, without any modifiers, the green zoom button should theoretically resize the window to the size of the view inside the window.
To try it out, I've created a simple application with only a
Text view in it. Applied some padding and border. Still not understandable by me, zooming the window occupies the whole screen, instead of getting the bounds of the
Text view. Why isn't this the standard behaviour?
To solve this issue, I get the
size and the
width of the
Text view via
GeometryReader, and apply it with the
.frame modifier, but it still does not budge. The only way I can get to zoom is setting the
maxHeight options, but then it is not possible to resize the window more than those values.
What do you think? Is this an incorrect behaviour, so that it makes sense to raise an issue? If it is not, can you please guide me through the parts of the language and the API that I need to study more? I would really like to solve this, and see it done in a proper way. I can provide some code examples to elaborate on stuff more.
Thanks for reading!