Chapter 8
Displaying Alerts and Handling List View Selection

There is no learning without trying lots of ideas and failing lots of times.

- Jonathan Ive

Are you able to complete the previous exercise and create the redesigned row layout? No worries if you can't. I will go through the solution with you in this chapter and introduce some new layout techniques. Up till now, we only focus on displaying data in a list view. I guess you may wonder how we can interact with the list view and detect row selections. This is what we will also discuss in this chapter.

To begin, first download the complete project we built in the previous chapter. We will continue to enhance the app and make it even better. In brief, here are what we are going to implement:

  • Add an alternate design of the row layout
  • Bring up a menu when a user taps one of the items in the list view. The menu offers two options: Reserve a table and Mark as favorite.
  • Display a heart icon when the user selects the Mark as favorite option.

Through implementing these new features, you will also learn how to better organize the SwiftUI code and use actions sheets to display alerts in iOS.

Figure 8-1. Sample alerts in Shortcut and Medium apps
Figure 8-1. Sample alerts in Shortcut and Medium apps

To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.

results matching ""

    No results matching ""