I wish I had more time to play. Here’s a little SwiftUI thing I threw together in the few moments I had free today. The source code is here.
Interestingly not including Color
for backgrounds seems to kill my poor little sample. I suspect an overload where the type cannot be unambiguously inferred. Adding corner radiuses (shown here on the outside) destroys user interactivity. I have it commented out in the gist.
Originally, I tried to control state extrema (no negative inventory) in my model object but that led to a disconnect with the steppers. Instead, I finally found an initializer that allowed me to specify the valid range (in: range
) to sanitize the user input, and disable the minus button for zero values.
A lot of the time I spent putting this together ended up with “helpful” results that looked like this:
That is to say, it’s really hard to provide a fluent functional framework in a typesafe language that feels like you’re constructing things into type erased collections because you never actually are…if that makes sense.
So far this week, I’ve managed to watch one video (the keynote) and about 20 minutes of another (the first bits introducing SwiftUI). I hope I have a chance to catch up. I’ll try to keep notes here on the website as I work through some of this stuff. It feels weird this year how far behind I am due to work commitments.
I spent today out of the office due to personal commitments and it’s been the first time I could really dive in (well, “dive” meaning for 10-20 minutes at a time here and there during the day). Loving this stuff, can’t wait to do more.
2 Comments
Rather than set the background and corner radius on the `VStack`, embed the `VStack` in a `ZStack` along with a `Rectangle` and set `foregroundColor` and `cornerRadius` on the `Rectangle`
The Zstacks didn’t work…but changing the corner radius of the blue color did! Will post