We’ve arrived day 90 of the 100 Days of SwiftUI! Yesterday, we learned about using and watching a timer and coloring views as we swipe. Today, we’re finishing the Flashzilla app by adding the functionality to add and remove cards, vibrations and fixing the final bugs. Let’s dive in!
Adding and deleting cards
Everything we’ve worked on so far has used a fixed set of sample cards, but of course this app only becomes useful if users can actually customize the list of cards they see. This means adding a new view that lists all existing cards and lets the user add a new one, which is all stuff you’ve seen before. However, there’s an interesting catch this time that will require something new to fix, so it’s worth working through this.
Hacking with Swift, Paul Hudson (@twostraws)
As always, Paul’s got us covered.
Making iPhones vibrate with UINotificationFeedbackGenerator in SwiftUI
iOS comes with a number of options for generating haptic feedback, and they are all available for us to use in SwiftUI. In its simplest form, this is as simple as creating an instance of one of the subclasses of
Hacking with Swift, Paul Hudson (@twostraws)UIFeedbackGenerator
then triggering it when you’re ready, but for more precise control over feedback you should first call itsprepare()
method to give the Taptic Engine chance to warm up.
Since iOS features many options when it comes to using haptics, it’s up to us as the developer to chose the most fitting implementation for our apps.
Wrap up
And that’s it for day 90 and the Flashzilla app! We’ve yet another SwiftUI project under our belt and we can really see the finish line coming closer now. We’re not quite there yet though, so keep your focus and we’re going to move on tomorrow!
100 Days of SwiftUI – Day 90