Your Second iOS and SwiftUI App
Use the knowledge you've gained from creating a SwiftUI app, and learning the fundamentals of Swift, to create a more complex app: a task list! By Jessy Catterwaul.
Who is this for?
This course is part of our iOS and Swift for Beginners learning path. You're ready for this course if you're working through that learning path in order, or you're someone who has just a little bit of iOS and Swift experience.
You'll build an entire task list app in this course, using SwiftUI.
Starting off, you'll design a data model that supports a SwiftUI List. Then, you'll build up the visual components of the List, learning how to use Swift Arrays to power your UI.
Because the app will have multiple screens, you'll apply new techniques for sharing data throughout a SwiftUI app. Along the way, you'll get experience organizing your code using a variety of tools available to you in Swift and Xcode.
This course isn’t suited for intermediate or advanced developers. If that’s you, check out our intermediate or advanced video courses for more ways to level-up your developer skills!
Covered concepts
- List Views
- Data Models
- Modal Sheets
- Identifiable Protocol
- SwiftUI Environment
- SwiftUI Bindings
- SwiftUI Edit Mode
- Combine: Published and Observable Objects
- Dependency Injection
- Swift Extensions
- Enumerations
- Custom Types
- Nested Types
- Multiline Editing
- Initialization using map
- CaseIterable Protocol
Part 1: SwiftUI Lists
Learn what's in store for you as you build Your Second iOS and SwiftUI App. This course builds on the Your First iOS and SwiftUI App and Programming in Swift: Fundamentals courses.
Set up a new Xcode project, and populate it with two Swift files: one to model a task, and another to store a collection of tasks.
Create a collection of tasks that you'd like to complete. And maybe pick up an Xcode and Swift trick!
Explore SwiftUI's List view, which displays data in a column, with a row for each entry. You'll use a range of integers for row indices.
Use the array indices supplied by List to access the correct task names, and display them in your rows.
Your Task type is ready to become Identifiable, relying on a UUID to become unique in the eyes of your List.
Prepare for using multiple screens in the upcoming parts by supplying your ContentView with a TaskStore, externally – a process known as dependency injection.
Review what you're able to do with lists already, and get a couple of ideas for what you can start thinking about in order to apply SwiftUI Lists in the future.
Part 2: Adding and Deleting Tasks
Have a look at the modal sheet (complete with Form styling), and Edit Mode, that you'll be adding to the app.
Create the SwiftUI view that you'll be using to create new tasks. The key components are a TextField, and some String-State.
Present your New Task View using a modal sheet. Launch it using a Button that resides in the Navigation Bar.
Using Form styling, more dependency injection, and SwiftUI's Environment, you'll add a Task to your model.
Solve the problem of your UI not updating to reflect your model with the power of Published and Observable Object from the Combine framework.
In order to delete tasks from your store, you will need to Encapsulate a ForEach inside of your List.
Incorporate an Edit Button to get into Edit Mode: where you'll have access to an alternative way of deleting tasks, and a way to move them too!
Review the interactivity that you've given your app using your NewTaskView and Edit Mode, powered by SwiftUI and Combine.
Part 3: Editing Tasks
This part of the course is all about editing your tasks. By the end of it, you'll be able to change tasks' names, and mark them as completed.
Make use of Xcode's Extract Subview capability to prepare for the UI complexity that's coming in this part.
Bindings are about to make things a little more complicated. But you can abstract away some complexity using the power of custom types and extensions.
Use SwiftUI Bindings to complete a flow of Tasks all the way to a new view, where you can edit them.
Make changes to the completion status of your tasks, and have those changes made visible with a checkmark and strikethrough text.
Review not only your app, but the fact that the developer community is eager to help each other out with exciting new technology like SwiftUI.
Part 4: Priority Sections
Some tasks are more important to get done than others, and your UI should reflect that. In this final part of the the course, you'll incorporate task priority.
To assign priority values to your tasks, you'll use two nested types: one an Identifiable structure, and the other, an enumeration.
Use the new model types from the last episode to help you organize your tasks using priority levels.
In one final SwiftUI View file for your TaskList app, group your tasks into sections, using the priorities you've set up.
Add headers to your sections, using SwiftUI's Section structure. That way, you'll finally be able to visualize priority!
Fix the bug preventing you from adding prioritized tasks. You can do that by adding more State to NewTaskView and a method to TaskStore.
Add a Picker control, so you can choose what priority a new task receives. Then style it with segmentation.
Let's review some of what you've accomplished along the journey of creating Your Second iOS and SwiftUI App.