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/Sticker.swift

30 lines · 765 bytes

1 symbol in this file
 1//
 2//  Sticker.swift
 3//  DayByDay
 4//
 5
 6import Foundation
 7import SwiftData
 8
 9/// A finished Today routine: one per child per day, showing that day's weather.
10/// Points at its child by id, so the Profile entity stays unchanged.
11@Model
12final class Sticker {
13    var profileID: UUID
14    var year: Int
15    var month: Int
16    var day: Int
17    var weatherRaw: Int
18    var createdAt: Date
19
20    init(profileID: UUID, year: Int, month: Int, day: Int, weather: LearnWeather, createdAt: Date = .now) {
21        self.profileID = profileID
22        self.year = year
23        self.month = month
24        self.day = day
25        self.weatherRaw = weather.rawValue
26        self.createdAt = createdAt
27    }
28
29    var weather: LearnWeather { LearnWeather(rawValue: weatherRaw) ?? .sunny }
30}