DayByDay/Profiles/Avatar.swift
53 lines · 1574 bytes
2 symbols in this file
1//
2// Avatar.swift
3// DayByDay
4//
5
6import SwiftUI
7
8/// The animal a child picks to stand for their profile.
9enum AvatarAnimal: String, CaseIterable, Identifiable {
10 case cat, dog, bird, fish, teddybear, tortoise, ladybug, hare
11
12 var id: String { rawValue }
13
14 var symbol: String { "\(rawValue).fill" }
15
16 var spokenName: String {
17 switch self {
18 case .cat: "Cat"
19 case .dog: "Dog"
20 case .bird: "Bird"
21 case .fish: "Fish"
22 case .teddybear: "Teddy"
23 case .tortoise: "Turtle"
24 case .ladybug: "Ladybug"
25 case .hare: "Bunny"
26 }
27 }
28}
29
30/// The color a child picks for their profile tile.
31enum ProfileColor: Int, CaseIterable, Identifiable {
32 case red, orange, yellow, green, teal, blue, purple, pink
33
34 var id: Int { rawValue }
35
36 var color: Color {
37 switch self {
38 case .red: Color(red: 0.86, green: 0.20, blue: 0.22)
39 case .orange: Color(red: 0.84, green: 0.40, blue: 0.08)
40 case .yellow: Color(red: 0.95, green: 0.75, blue: 0.15)
41 case .green: Color(red: 0.18, green: 0.56, blue: 0.28)
42 case .teal: Color(red: 0.0, green: 0.53, blue: 0.56)
43 case .blue: Color(red: 0.0, green: 0.42, blue: 0.85)
44 case .purple: Color(red: 0.55, green: 0.4, blue: 0.85)
45 case .pink: Color(red: 0.82, green: 0.25, blue: 0.52)
46 }
47 }
48
49 /// Color for the avatar symbol drawn on `color`.
50 var symbolColor: Color {
51 self == .yellow ? Color(red: 0.19, green: 0.15, blue: 0.03) : .white
52 }
53}