Here is the contents of my view:
HStack {
Banner(items: items)
.layoutPriority(100)
OptionalView()
}
I want to only display the OptionalView
if there is a minimum amount of width left over for it after displaying the items in the Banner
view.
I can use GeometryReader
, but since it's a push-out view, if the OptionalView
is not needed, it takes up some space and pushes the banner items to the left so they are not centered.
HStack {
Banner(items: items)
.layoutPriority(100)
GeometryReader { geometry in
if geometry.size.width >= 70 {
OptionalView()
}
}
}