Small Victories With SwiftUI (Dev Log #2)
(Read the previous Dev Log here)
Swift UI is amazing. It clicked right away, and I was able to quickly make my app’s basic UI look exactly the way I had imagined. It was super amazing, until I started attempting to actually attach data to it.
Here’s the thing: SwiftUI changes everything about how apps are structured. And while I know it must be really hard for experienced developers to make that switch after years of doing it the old way — just imagine how out-of-depth I felt when SwiftUI seemed to only be explained in terms of how it was different from that old way, when I didn’t even know how that old way worked!
But, just the other day I found this amazing Apple Developer talk called “Data Flow Through SwiftUI” which helped me tremendously. It even happened to show me how to make a play/pause button, which was exactly what I had been struggling with for hours weeks ago! Turns out, literally the only thing that I was missing was putting @State in front of my boolean, to show that it was going to change somewhere during the app’s run. It was super encouraging that I was so close to figuring out the problem on my own.
Anyway, I still don’t fully understand half of what they talked about in that presentation, but I am starting to feel like I have a bit a grasp of what I don’t know. That simple @State solution was like a little donut-shaped lifesaver. I am still in the middle of an ocean with no land in sight, but at least I am not quite drowning.
So, here is what I have so far:
So, let me explain. I copy and pasted some code that I don’t fully understand yet and was surprised when it gave me not only a canvas surface but a crappy default pen tool as well. Let me tell you — I hate not being able to understand the code that I’m using. But I know that it’s an important part of the process, and happy accidents like these really encourage me to expand my mindset.
All that the play button does right now is toggle a bool that links back to give the play/pause images. SF Symbols for the win!
All the frames right now are hard-coded in. The add frame button can be pressed (yayyy!) but doesn’t actually do anything.
I think that’s all for now, folks! I am feeling super encouraged about this process now, and although I still don’t have as much time as I’d like to just sit down and code, I really feel like every time I do, I make a tiny breakthrough. Coding does NOT come naturally to me, but I think that’s part of what makes it so rewarding.
Talk to you soon!
-Zoe