This used to work, but seeing this problem with Xcode 15.0.1
This view works as expected:
#Preview {
VStack {
Text("Header")
GeometryReader { geometry in
ScrollView(.vertical) {
VStack {
Text("Top").background(Color.red)
Spacer().background(Color.orange)
Text("Bottom").background(Color.blue)
}
.frame(width: geometry.size.width)
.frame(minHeight: geometry.size.height)
}
}
}
}
Resulting in: Top and Bottom are in the right spot
But then adding either something below the Geometry Reader or a .safeAreaInset as so:
#Preview {
VStack {
Text("Header")
GeometryReader { geometry in
ScrollView(.vertical) {
VStack {
Text("Top").background(Color.red)
Spacer().background(Color.orange)
Text("Bottom").background(Color.blue)
}
.frame(width: geometry.size.width)
.frame(minHeight: geometry.size.height)
}
}
}
.safeAreaInset(edge: .bottom) {
Text("Footer")
}
}
Results in the Spacer() not taking up any space (Top and Bottom are then centred in the middle of the scrollview. Spacer not taking up any space, so Top and Bottom are in the centre
As I mentioned at the top, this was working previously. Any clues to if this is a SwiftUI bug or something I'm doing wrong?