I'm using an HStack to layout some elements in my view hierarchy. I'd love to be able to conditionally flip the order of the elements.
HStack {
Text("Hello")
Text("World")
}
The idea is that this will either be layouted as "Hello World" or "World Hello" depending on my view's state.
HStack itself doesn't provide any functionality for this, but it also appears to be pretty much impossible trying to pull this out of the view itself attempting to use other ViewBuilders, ForEach-based approaches, etc.
The only way I can resolve this is by actually specifying both layouts entirely, which is what I'm trying to avoid.
let isFlipped: Bool
HStack {
if isFlipped {
Text("World")
Text("Hello")
} else {
Text("Hello")
Text("World")
}
}
