krz/daybyday

iOS learning games for young children: days, months, seasons, numbers, letters, animals and more. education ios kids swift https://krz.sh/apps/daybyday/

DayByDay/Profiles/DayPicture.swift

062549ad26607ce9e973ed2a9a7ef6f853885f83
daybyday/DayByDay/Profiles/DayPicture.swift history · blame · raw

45 lines · 1179 bytes

1 symbol in this file
 1//
 2//  DayPicture.swift
 3//  DayByDay
 4//
 5
 6import Foundation
 7import SwiftData
 8
 9/// Something special a child does on a weekday, set by a grown-up.
10nonisolated enum DayPictureKind: String, CaseIterable, Identifiable {
11    case swim, school, grandma, park, music, soccer, library, dance
12
13    var id: String { rawValue }
14
15    var name: String { "\(rawValue) day" }
16
17    var symbol: String {
18        switch self {
19        case .swim:    "figure.pool.swim"
20        case .school:  "backpack.fill"
21        case .grandma: "house.fill"
22        case .park:    "tree.fill"
23        case .music:   "music.note"
24        case .soccer:  "soccerball"
25        case .library: "books.vertical.fill"
26        case .dance:   "figure.socialdance"
27        }
28    }
29}
30
31/// A day picture for one child and weekday. Points at its child by id.
32@Model
33final class DayPicture {
34    var profileID: UUID
35    var weekdayRaw: Int
36    var kindRaw: String
37
38    init(profileID: UUID, weekday: DayOfWeek, kind: DayPictureKind) {
39        self.profileID = profileID
40        self.weekdayRaw = weekday.rawValue
41        self.kindRaw = kind.rawValue
42    }
43
44    var kind: DayPictureKind? { DayPictureKind(rawValue: kindRaw) }
45}