struct TideForecastInfoView: View {
var geometryProxy: GeometryProxy
var body: some View {
VStack {
getHeaders(geometryProxy)
TideForecastEntryView(geometryProxy: geometryProxy)
.padding(2)
}
.background(.white)
.clipShape(RoundedRectangle(cornerRadius: 14))
.shadow(radius: 8)
}
@ViewBuilder
func getHeaders(_ geometryProxy: GeometryProxy) -> some View {
HStack {
HStack {
Text("tide")
.frame(maxWidth: geometryProxy.size.width * 0.25)
Text("time")
.frame(maxWidth: geometryProxy.size.width * 0.5)
Text("height")
.frame(maxWidth: geometryProxy.size.width * 0.25)
}
.padding(8)
}
.frame(maxWidth: .infinity)
.background(.gray)
}
}
struct TideForecastEntryView: View {
var geometryProxy: GeometryProxy
var body: some View {
HStack {
Text("High Tide")
.frame(maxWidth: geometryProxy.size.width * 0.25)
Text("1:08 AM (Tue 03) January")
.frame(maxWidth: geometryProxy.size.width * 0.5, alignment: .leading)
Text("1.31 m (4.3 ft)")
.frame(maxWidth: geometryProxy.size.width * 0.25)
}
}
}
Result looks like this
03 should be on the first line and maybe parts of the January word. is there something else missing in the Text view option that i need to declare?
Also how to vertical align top for text High Tide. it is always vertically centered. I tried to set alignment: .top in the frame but doesnt do anything.
Thoughts?