Chapter 6: Presenting Extra Information to the User
When interacting with mobile applications, users require a certain level of handholding. For example, suppose they are about to perform an irreversible action such as permanently deleting a file. In that case, they should probably be shown an alert asking for confirmation if they want to proceed with the action. Then, depending on the user's response, the file would be deleted or left alone.
Since SwiftUI is a declarative programming language, presenting extra information to the user mainly involves adding modifiers to already existing views. It is possible to add one or several such modifiers to a View
and set the conditions for each trigger. In this chapter, we will learn how to present extra information to the user using alerts, modals, context menus, and popovers.
The recipes we'll cover in this chapter are as follows:
- Presenting alerts
- Adding actions to alert buttons
- Presenting confirmation dialogs...