43 lines
1023 B
Swift
43 lines
1023 B
Swift
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
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|