Re:SwiftUI in 2022
by emehex on Wednesday May 25, 2022 @11:41AM
(#31506119)
Took me 5 minutes. Copy and paste this into a playground: https://gist.github.com/maxhumber/1dbdf0d9c4539a8e145b3c630c...
[ Parent
| on HN ]
Your answer is wrong. You've failed the fizzbuzz :)
Change frame (screen width) to 300, 500 to see why.
Good catch. Fixed with an extra ZStack.
GeometryReader was not part of fizzbuzz. Replace geo.size.width * 0.1 with 10 to see your code break.
Now tell me, why did it break? Do you even know? Because I don't.
I don't know why half the shit works as it does, and I've written non-trivial SwiftUI code for 6 months. I did not have this problem with UIKit and interface builder.
GeometryReader is a pretty critical part of the SwiftUI framework. I'd recommend getting familiar with it!
Saying "you can't use GeometryReader" would be like saying you can't use UIKit's Auto Layout...
Now please see how it looks on a device: https://postimg.cc/crtKHSTG