54 lines
1.7 KiB
Swift
54 lines
1.7 KiB
Swift
import Foundation
|
|
|
|
class SuggestionManager {
|
|
static let shared = SuggestionManager()
|
|
|
|
private var suggestions: [String] = [
|
|
"Breathe for a few",
|
|
"Get up and walk around a minute",
|
|
"Do some pushups or something",
|
|
"Bodyweight squats, let's go",
|
|
"Maybe some crunches",
|
|
"Drink some water",
|
|
"Stretch your neck and shoulders",
|
|
"Rest your eyes, look at something far away",
|
|
"Stand up and touch your toes",
|
|
"Roll your wrists and ankles",
|
|
"Take a few deep breaths",
|
|
"Go get some water",
|
|
"Do some lunges",
|
|
"Stretch your hip flexors",
|
|
"Give your eyes a break",
|
|
"Straighten your posture, your back will thank you",
|
|
"Smile — it actually helps your mood",
|
|
"Clear your desk, clear your mind",
|
|
"Take a moment to appreciate how far you've come",
|
|
"Eat something fresh and nourishing today",
|
|
"Step outside for a minute of fresh air",
|
|
"Unclench your jaw and relax your shoulders"
|
|
]
|
|
|
|
private var dismissed: Set<Int> = []
|
|
private var currentIndex: Int = 0
|
|
|
|
func next() -> String {
|
|
var attempts = 0
|
|
while dismissed.contains(currentIndex) && attempts < suggestions.count {
|
|
currentIndex = (currentIndex + 1) % suggestions.count
|
|
attempts += 1
|
|
}
|
|
if attempts >= suggestions.count {
|
|
dismissed.removeAll()
|
|
}
|
|
let suggestion = suggestions[currentIndex]
|
|
currentIndex = (currentIndex + 1) % suggestions.count
|
|
return suggestion
|
|
}
|
|
|
|
func dismiss(suggestion: String) {
|
|
if let idx = suggestions.firstIndex(of: suggestion) {
|
|
dismissed.insert(idx)
|
|
}
|
|
}
|
|
}
|