- Initialize iOS project with 6-tab navigation structure - Configure custom Light/Dark themes and AppColors - Define SwiftData models for Tasks, Tags, Goals, and TrackingRecords - Setup relationships (Super/Sub tags) and cascade delete rules - Implement Observable TrackingEngine for real-time timer updates
44 lines
1.0 KiB
Swift
44 lines
1.0 KiB
Swift
import Foundation
|
|
import SwiftData
|
|
|
|
enum TrackingRecordType: String, Codable {
|
|
case timerSession
|
|
case countLog
|
|
}
|
|
|
|
@Model
|
|
final class TrackingRecord {
|
|
var id: UUID
|
|
var recordType: TrackingRecordType
|
|
var startTime: Date?
|
|
var endTime: Date?
|
|
var timestamp: Date?
|
|
var duration: TimeInterval
|
|
var createdAt: Date
|
|
|
|
// Inverse is declared on TaskItem.trackingRecords
|
|
var task: TaskItem?
|
|
|
|
var isRunning: Bool { recordType == .timerSession && startTime != nil && endTime == nil }
|
|
|
|
init(
|
|
id: UUID = UUID(),
|
|
task: TaskItem? = nil,
|
|
recordType: TrackingRecordType,
|
|
startTime: Date? = nil,
|
|
endTime: Date? = nil,
|
|
timestamp: Date? = nil,
|
|
duration: TimeInterval = 0,
|
|
createdAt: Date = .now
|
|
) {
|
|
self.id = id
|
|
self.task = task
|
|
self.recordType = recordType
|
|
self.startTime = startTime
|
|
self.endTime = endTime
|
|
self.timestamp = timestamp
|
|
self.duration = duration
|
|
self.createdAt = createdAt
|
|
}
|
|
}
|