36 lines
798 B
Swift
36 lines
798 B
Swift
import Foundation
|
|
import SwiftData
|
|
|
|
enum GoalFrequency: String, Codable {
|
|
case daily
|
|
case weekly
|
|
case monthly
|
|
}
|
|
|
|
@Model
|
|
final class Goal {
|
|
@Attribute(.unique) var id: UUID
|
|
var targetType: String // "count" or "duration"
|
|
var conditions: Double // threshold value to meet the goal
|
|
var frequency: GoalFrequency
|
|
|
|
var task: TaskItem?
|
|
var category: Category?
|
|
|
|
init(
|
|
id: UUID = UUID(),
|
|
targetType: String,
|
|
conditions: Double,
|
|
frequency: GoalFrequency,
|
|
task: TaskItem? = nil,
|
|
category: Category? = nil
|
|
) {
|
|
self.id = id
|
|
self.targetType = targetType
|
|
self.conditions = conditions
|
|
self.frequency = frequency
|
|
self.task = task
|
|
self.category = category
|
|
}
|
|
}
|