Hi everyone i just ended the challenges for Layout and Geometry and achieved the desire end result but got confused because even though i used max() and min() like Paul suggested us to use, I think they're not doing anything in the code. Maybe I'm missing something or the way I did the challenges kind of makes max() and min() not needed?
Code below:
GeometryReader { fullView in
ScrollView(.vertical) {
ForEach(0..<50) { index in
GeometryReader { geo in
Text("Row #\(index)")
.font(.title)
.frame(maxWidth: .infinity)
.background(Color(hue: min(geo.frame(in: .global).minY / fullView.frame(in: .global).maxY, 1.0), saturation: 1, brightness: 1))
.rotation3DEffect(.degrees(geo.frame(in: .global).minY - fullView.size.height / 2) / 5, axis: (x: 0, y: 1, z: 0))
.opacity(geo.frame(in: .global).minY / 200)
.scaleEffect(max(geo.frame(in: .global).minY / fullView.frame(in: .global).maxY + 0.5, 0.5))
}
.frame(height: 40)
}
}
}
For example, in the scaleEffect modifier, the way I calculate the number, it will go from 1.0 to 0 + 0.5, so it will never go below half the size of the Text view, but Paul asked us to use max() there to prevent exactly that...
The same thing for the Color hue, i used the same logic, so it will go from 1.0 to 0 but Paul asked to use min() to prevent the number from going beyond 1.0.
I still used both min and max but I'm afraid I'm missing something and don't want to get through this challenges thinking I did the correct thing but in reality did wrong.
Thanks.