DayByDay/Speech/Lines.swift
71 lines · 2763 bytes
10 symbols in this file
1//
2// Lines.swift
3// DayByDay
4//
5
6import Foundation
7
8/// Spoken lines that views build, kept here so the views and the voice clip
9/// catalog (`SpokenLines`) produce exactly the same text.
10nonisolated enum Lines {
11 static let greeting = "Hi there!"
12
13 /// Names with a recorded greeting. Any other name is greeted without it.
14 static let spokenNames = [
15 "Gianna", "Gigi", "Ashlynn", "Ash", "Olive", "Ollie", "Elijah", "Arthur", "Noah",
16 "Thad", "Thadeus", "Izzy", "Isabella", "Sam", "Sammy", "Frankie", "Franklin",
17 ]
18
19 static func greeting(for name: String?) -> String {
20 let typed = name?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
21 guard let match = spokenNames.first(where: { $0.caseInsensitiveCompare(typed) == .orderedSame }) else {
22 return greeting
23 }
24 return "Hi, \(match)!"
25 }
26 static let whoIsPlaying = "Who's playing?"
27 static let youDidIt = "You did it!"
28 static let lookAndListen = "Look and listen"
29 static let spinPrompt = "Spin the wheel! Or tap a month."
30 static let weatherQuestion = "What's the weather like today?"
31 static let itsRaining = "It's raining!"
32
33 /// Weathers a child can pick for a sticker.
34 static let stickerWeathers: [LearnWeather] = [.sunny, .cloudy, .rainy, .snowy, .windy]
35
36 static func sticker(_ weather: LearnWeather) -> String {
37 "It's \(weather.name.lowercased()) today! Here's your sticker!"
38 }
39
40 static func calendarDay(_ month: MonthOfYear, _ day: Int, weather: LearnWeather?) -> String {
41 let date = "\(month.name) \(ordinal(day))"
42 return weather.map { "On \(date), it was \($0.name.lowercased())." } ?? "\(date)."
43 }
44
45 /// 1st, 2nd, 3rd, 4th, …, 11th, 12th, 13th, 21st, …
46 static func ordinal(_ n: Int) -> String {
47 let suffix = (11...13).contains(n % 100) ? "th" : ["th", "st", "nd", "rd"][n % 10 < 4 ? n % 10 : 0]
48 return "\(n)\(suffix)"
49 }
50
51 static func dayCard(_ day: DayOfWeek, picture: DayPictureKind?) -> String {
52 picture.map { "\(day.name). It's \($0.name)!" } ?? day.name
53 }
54
55 static func countPrompt(_ thing: CountingRound.Thing) -> String {
56 "Tap each \(thing.singular) to count."
57 }
58
59 /// "the letter a" or "the circle".
60 static func traceLabel(_ item: QuizItem) -> String {
61 item.category == .alphabet ? "the letter \(item.name)" : "the \(item.name.lowercased())"
62 }
63
64 static func tracePrompt(_ item: QuizItem) -> String {
65 "Trace \(traceLabel(item)) with your finger."
66 }
67
68 static func traceSuccess(_ item: QuizItem) -> String { "You traced \(traceLabel(item))!" }
69
70 static func traceMiss(_ item: QuizItem) -> String { "Stay on \(traceLabel(item)). Let's try again." }
71}