58

Your Second iOS and SwiftUI App [SUBSCRIBER]

 4 years ago
source link: https://www.tuicool.com/articles/f6VJbmM
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.

Models

4:53

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!

List Views

2:28

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.

Conclusion

0:41

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.

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.

Edit Mode

3:05

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!

Conclusion

0:25

Review the interactivity that you've given your app using your NewTaskView and Edit Mode, powered by SwiftUI and Combine.

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.

Extensions

6:03

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.

Binding

4:01

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.

Conclusion

0:50

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.

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.

Conclusion

1:27

Let's review some of what you've accomplished along the journey of creating Your Second iOS and SwiftUI App.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK