I want to build a VStack that is only as wide as the widest element is. If there is (horizontally) not enough space, e.g., the screen is too narrow, the content should shrink. Here is a simple example:
VStack {
HStack {
Text("title1")
Spacer()
Text("title2")
Spacer()
Text("title3")
}
HStack {
Text("fo0o0o0o0o0o0o0o0oo0o0o0")
Spacer()
Text("fo0o0o0o0o")
Spacer()
Text("fo0")
}
HStack {
Text("fo0o0o0o0o")
Spacer()
Text("fo0o")
Spacer()
Text("fo0")
}
}.fixedSize()
How it should look like, if the VStack does not have to shrink.

How it should look like, if the VStack has to shrink.

If fixedSize is applied, the content obviously does not shrink and goes over the edges of the screen. If fixedSize is not applied, the spacers use all (horizontally) available space and the table is too wide. Hard coding the width is not an option because the content is dynamic and, therefore, unknown.
Basically: if there is enough space, apply fixedSize. If not, don't apply fixedSize and leave it as it is.
How can I archive that behavior with SwiftUI?

