New task feature (#2)

This PR contains the work done to implement the **New Task** feature, and to integrate it into the main context view of the app.

Reviewed-on: rock-n-code/todos-app#2
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #2.
This commit is contained in:
2026-02-09 17:53:40 +00:00
committed by javier
parent e6e9afe7fa
commit 5506471fe0
11 changed files with 650 additions and 67 deletions
-11
View File
@@ -1,11 +0,0 @@
import Foundation
import SwiftData
@Model
final class Item {
var timestamp: Date
init(timestamp: Date) {
self.timestamp = timestamp
}
}
+42
View File
@@ -0,0 +1,42 @@
import Foundation
import SwiftData
/// Represents a todo task created by a user.
@Model
final class Todo {
// MARK: Properties
/// A date when the todo was completed, if applicable.
var completed: Date?
/// A date by which the todo should be completed.
var due: Date
/// An optional note providing additional details about the todo task.
var note: String?
/// The title of the todo task.
var title: String
// MARK: Initializers
/// Creates a new todo item.
/// - Parameters:
/// - title: The title of the todo item.
/// - note: An optional note providing additional details.
/// - due: The date by which the todo should be completed.
/// - completed: The date when the todo was completed, if applicable.
init(
title: String,
note: String? = nil,
due: Date,
completed: Date? = nil
) {
self.completed = completed
self.due = due
self.note = note
self.title = title
}
}