Table of Contents
Mastering the Data Flow
is essential when building your SwiftUI apps. Use this project to learn how to use SwiftUI's State, Binding, and the Observable Object protocol. In conclusion, take a look at how passing the data in the Environment works.
Learner List View | New Learner View |
---|---|
-
Clone the repo
git clone https://github.com/developer-academy-unina/Lab-Data-Flow
-
Open the
.xcodeproj
file
-
Open the Starter project
-
Create the
NewLearnerView
like shown in the picture above -
Implement the modal navigation to add a new learner by using the
State
andBinding
mechanism fromLearnerListView
toNewLearnerView
-
Pass the function to add new learners in
NewLearnerView
as a parameter -
Add the function to add a new learner and delete them in the
LearnerViewModel
-
Mark the LearnerViewModel as with the
@Observable
macro to refresh the interface whenever changes in the data occur -
Experiment with the
Environment
by creating the instance ofLearnerViewModel
in theLearnersApp.swift
file (the app entry point), feeding it to the Environment of theTabView
(by using the.environment(:_)
modifier), and retrieving it from the Environment in the Views that need the data (don't forget to provide the Views' Previews with the environment instance, otherwise the previews will crash) -
Connect the functions to the buttons' actions
-
Launch the app on the simulator and check if your version is similar to the Final project
You've found a bug in the source code, a mistake in the documentation or maybe you'd like a new feature? Take a look at GitHub Discussions to see if it's already being discussed. You can help us by submitting an issue on GitHub. Before you create an issue, make sure to search the issue archive -- your issue may have already been addressed!
Please try to create bug reports that are:
- Reproducible. Include steps to reproduce the problem.
- Specific. Include as much detail as possible: which version, what environment, etc.
- Unique. Do not duplicate existing opened issues.
- Scoped to a Single Bug. One bug per report.
Reach out to the maintainer at one of the following places:
- GitHub Discussions
- GitHub issues
- Contact a Mentor for any other help
The original setup of this repository is by Luca Palmese.
For a full list of all authors and contributors, see the contributors page.
This project is licensed under the MIT License.
See LICENSE for more information.