Introducci贸n al Patr贸n MVVM
Todo para Uno y Uno para Todos
Arquitectura y Dise帽o en Apps iOS
Patrones MVC y MVP en Apps iOS
Principios SOLID
Patr贸n de arquitectura MVVM
Quiz: Introducci贸n al Patr贸n MVVM
Estructura de un Proyecto con MVVM
Inicio del proyecto y estructura b谩sica MVVM
Paquete Models
Core Data
Paquete Views
ViewModel
Quiz: Estructura de un Proyecto con MVVM
Operaciones CRUD en un proyecto con MVVM
Agregar ToDos (Parte 1)
Agregar ToDos (Parte 2)
Listar ToDos
Actualizar ToDos
Archivar ToDos
Desarchivar ToDos
Eliminar ToDos
Actualizar el estado de los ToDos
Dise帽o y Validaci贸n de Vistas para ToDos
Quiz: Operaciones CRUD en un proyecto con MVVM
Clean Architecture
Introducci贸n a Clean Architecture
Estructura de Clean Architecture
Inicio del proyecto con Clean Architecture
Capa de Datos
Comunicaci贸n de red HTTP con TheMovieDB
Capa de Dominio
Capa de Presentaci贸n
Integraci贸n de Capas
Quiz: Clean Architecture
MVVM y Clean Architecture
Highlights
You don't have access to this class
Keep learning! Join and start boosting your career
The MVVM architecture is a robust approach to building applications by providing an organized schema, similar to building a house. In this context, the view model is the backbone that integrates key functionalities, such as adding tasks to local storage using Core Data. This process involves defining essential parameters such as the title, an optional note, and the creation date, assigning these values to a corresponding entity with a unique identifier.
addTodo
in the view model?The addTodo
function in the view model plays a crucial role because of its ability to add new tasks to the storage. Here are the fundamental steps:
title (title
), an optional note(note
), and the creation date(date
).newTodo
, is initialized and associated to the Core Data context.newTodo
.saveData
function is invoked to ensure persistence in local storage.func addTodo(withTitle title: String, note: String?, date: Date) { let newTodo = TodoEntity(context: storeContainer.viewContext) newTodo.id = UUID() newTodo.title = title newTodo.note = note newTodo.date = date newTodo.isComplete = false newTodo.isArchive = false saveData() }
The view, represented by todoAddView
, is where user interactions are materialized, from entering titles to selecting dates. Its design should be intuitive and functional to enhance the user experience.
When declaring variables, notations are used to enable smooth and efficient state management:
ViewModel
injection: using the @Environment
notation, functionalities such as adding tasks are accessed.
@Environment(viewModel) var viewModel: TodoViewModel
State variables: @State
notations are used to dynamically manage the title, note, and creation date.
@State private var title: String = "" @State private var note: String = "" @State private var date: Date = Date()
The visual design must be consistent and easy to use. Below are the main elements:
TodoTextInput
, input is provided for the title, which is mandatory, and notes, which are optional.DatePicker
: Through DatePicker
, users can select the desired date and time.VStack { TodoTextInput("Enter task name", text: $title, label: "Task") TodoTextInput("Type a description of the task", text: $note, label: "Note") DatePicker("Date and time", selection: $date, in: dateRange, displayedComponents: [.date, .hourAndMinute]) }
In the mobile environment, these visual controls ensure that data entry is straightforward and efficient. Developers can customize these components to further enhance usability.
UUIDs
to avoid storage conflicts by having unique identifiers for each entity.Ultimately, building an application with MVVM architecture provides a robust structure, and through this approach we can effectively manage logic and storage, paving the way for future enhancements and functionality.
Contributions 0
Questions 0
Want to see more contributions, questions and answers from the community?