"Phi is the name of a number that is roughly: 1.6
This number goes on but let’s keep it simple. It’s a measurement that has been observed in all kinds of nature. More accurately it is a ratio. Meaning you have the length of something in nature and something else connected to it is either 1.6 times bigger or 1.6 times smaller depending on which direction you go. Or 1.6 times longer or 1.6 times shorter."
struct GettingSizeWithGeometryReader: View {
var body: some View {
GeometryReader { gr in
VStack {
Text("Height: \(gr.size.height)")
Text("Width: \(gr.size.width)")
}
}
.font(.largeTitle)
.edgesIgnoringSafeArea(.vertical)
}
}
struct LayingOutUsingPhi: View {
var body: some View {
VStack {
Rectangle()
.fill(Color.blue)
Rectangle()
.fill(Color.purple)
}.edgesIgnoringSafeArea(.vertical)
}
}
struct LayingOutUsingPhi: View {
var body: some View {
GeometryReader { gr in
VStack {
Rectangle()
.fill(Color.blue)
// Adjust the height to be 38% of the device height
.frame(height: gr.size.height * 0.38)
Rectangle()
.fill(Color.purple)
}.edgesIgnoringSafeArea(.vertical)
}
}
}
struct LayingOutUsingPhi: View {
var body: some View {
GeometryReader { gr in
VStack {
Rectangle()
.fill(Color.blue)
// Adjust the height to be 38% of the device height
.frame(height: gr.size.height * 0.38)
.overlay(Text("Height: \(gr.size.height * 0.38)"))
Rectangle()
.fill(Color.purple)
.overlay(Text("Height: \(gr.size.height * 0.62)"))
}
.edgesIgnoringSafeArea(.vertical)
.font(.largeTitle)
}
}
}
struct LayingOutUsingPhi: View {
var body: some View {
GeometryReader { gr in
VStack {
Rectangle()
.fill(Color.blue)
// Adjust the height to be 38% of the device height
.frame(height: gr.size.height * 0.38)
.overlay(Text("Height: \(gr.size.height * 0.38)"))
Rectangle()
.fill(Color.purple)
.overlay(Text("Height: \(gr.size.height * 0.62)"))
}.font(.largeTitle)
}.edgesIgnoringSafeArea(.vertical)
}
}
.fill((gr.size.height * 0.62) > 600 ? Color.pink : Color.purple)
GeometryReader { inner_gr in
Rectangle()
.fill(inner_gr.size.height > 600 ? Color.pink : Color.purple)
.overlay(Text("Height: \(inner_gr.size.height)"))
}