Tag Model

Definition

struct Tag: Identifiable, Codable, Sendable {
    let id: UUID
    var name: String
    var color: String      // Hex color "#RRGGBB"
    var isArchived: Bool   // Hidden from selection when true
    let createdAt: Date
}

Properties

PropertyTypeDescription
idUUIDUnique identifier
nameStringDisplay name (must not be empty)
colorStringHex color code “#RRGGBB”
isArchivedBoolWhen true, tag is hidden from selection UI
createdAtDateCreation timestamp

Archiving

Archived tags:

  • Hidden from tag selection dropdowns (new timer, edit record)
  • Shown greyed out in History tag filter
  • Can be unarchived via swipe action in Settings
  • Existing records with archived tags still display the tag

JSON Format

{
  "id": "uuid-string",
  "name": "Work",
  "color": "#FF5733",
  "isArchived": false,
  "createdAt": "2024-01-01T00:00:00Z"
}

Note: isArchived defaults to false if not present (backward compatibility).

Storage

Tags stored in tags.json as array wrapper:

{
  "tags": [...]
}

Validation

  • Name must not be empty or whitespace-only
  • Throws TagError.emptyName on validation failure
func validateName() throws {
    guard !name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
        throw TagError.emptyName
    }
}

Related

Data

Services

UI

Reports