Skip to content

This project shows how to use SwiftUI's State, Binding, and the Observable Object protocol. In conclusion, you can take a look at how passing the data in the Environment works.

License

Notifications You must be signed in to change notification settings

developer-academy-unina/Lab-Data-Flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lab

Data Flow


Report a Bug · Ask a Question

coverage

Table of Contents


About

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.

Screenshots
Learner List View New Learner View

Getting Started

Installation

  1. Clone the repo

    git clone https://github.com/developer-academy-unina/Lab-Data-Flow
  2. Open the .xcodeproj file

How to

  1. Open the Starter project

  2. Create the NewLearnerView like shown in the picture above

  3. Implement the modal navigation to add a new learner by using the State and Binding mechanism from LearnerListView to NewLearnerView

  4. Pass the function to add new learners in NewLearnerView as a parameter

  5. Add the function to add a new learner and delete them in the LearnerViewModel

  6. Mark the LearnerViewModel as with the @Observable macro to refresh the interface whenever changes in the data occur

  7. Experiment with the Environment by creating the instance of LearnerViewModel in the LearnersApp.swift file (the app entry point), feeding it to the Environment of the TabView (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)

  8. Connect the functions to the buttons' actions

  9. Launch the app on the simulator and check if your version is similar to the Final project


Issues and Discussions

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.

Support

Reach out to the maintainer at one of the following places:


Authors & contributors

The original setup of this repository is by Luca Palmese.

For a full list of all authors and contributors, see the contributors page.


License

This project is licensed under the MIT License.

See LICENSE for more information.

About

This project shows how to use SwiftUI's State, Binding, and the Observable Object protocol. In conclusion, you can take a look at how passing the data in the Environment works.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages