Day 24
Day 24 ๊ด๋ จ
Project 3, part 2
Albert Einstein once said, โany fool can know; the point is to understand,โ and this project was specifically about giving you a deeper understanding of what makes SwiftUI tick. After all, youโll be spending the next 76 days working with it, so itโs a good idea to make sure your foundations are rock solid before moving on.
I could have said to you โSwiftUI uses structs for viewsโ or โSwiftUI uses some View
a lotโ, and in fact did say exactly that to begin with when it was all you needed to know. But now that youโre progressing beyond the basics, itโs important to feel comfortable with what youโre using โ to eliminate the nagging sense that you donโt quite get what something is for when you look at your code.
So much of Swift was built specifically for SwiftUI, so donโt be worried if youโre looking at some of the features and thinking they are way beyond your level. If you think about it, they were well above everyoneโs level until Swift shipped with them!
Today you should work through the wrap up chapter for project 3, complete its review, then work through all three of its challenges.
Views and modifiers: Wrap up
Views and modifiers: Wrap up
These technique projects are designed to dive deep into specific SwiftUI topics, and I hope youโve learned a lot about views and modifiers here โ why SwiftUI uses structs for views, why some View
is so useful, how modifier order matters, and much more.
Views and modifiers are the fundamental building blocks of any SwiftUI app, which is why I wanted to focus on them so early in this course. View composition is particularly key, as it allows to build small, reusable views that can be assembled like bricks into larger user interfaces.
Review what you learned
Anyone can sit through a tutorial, but it takes actual work to remember what was taught. Itโs my job to make sure you take as much from these tutorials as possible, so Iโve prepared a short review to help you check your learning.
Click here to review what you learned in this project.
Challenge
One of the best ways to learn is to write your own code as often as possible, so here are three ways you should try extending this app to make sure you fully understand whatโs going on:
- Go back to project 1 and use a conditional modifier to change the total amount text view to red if the user selects a 0% tip.
- Go back to project 2 and replace the
Image
view used for flags with a newFlagImage()
view that renders one flag image using the specific set of modifiers we had. - Create a custom
ViewModifier
(and accompanyingView
extension) that makes a view have a large, blue font suitable for prominent titles in a view.
Views and modifiers: Wrap up - Additional
Once youโre done, donโt forget to stay accountable and tell other people about your progress!