Files
Reflect/Shared/Models/Mood.swift
Trey t be84825aba Fix widget layout clipping and add comprehensive widget previews
- Fix LargeVotingView mood icons getting clipped at edges by using
  flexible HStack spacing with maxWidth: .infinity
- Fix VotingView medium layout with smaller icons and even distribution
- Add comprehensive #Preview macros for all widget states:
  - Vote widget: small/medium, voted/not voted, all mood states
  - Timeline widget: small/medium/large with various data states
- Reduce icon sizes and padding to fit within widget bounds
- Update accessibility labels and hints across views

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 09:53:40 -06:00

102 lines
2.6 KiB
Swift

//
// Mood.swift
// Feels
//
// Created by Trey Tartt on 1/5/22.
//
import Foundation
import SwiftUI
enum Mood: Int {
case horrible
case bad
case average
case good
case great
case missing
case placeholder
var next: Mood {
var moodValue = self.rawValue
moodValue -= 1
if moodValue < 0 {
moodValue = 4
}
return Mood.init(rawValue: moodValue) ?? Mood.horrible
}
var strValue: String {
switch self {
case .horrible:
return String(localized: "mood_value_horrible")
case .bad:
return String(localized: "mood_value_bad")
case .average:
return String(localized: "mood_value_average")
case .good:
return String(localized: "mood_value_good")
case .great:
return String(localized: "mood_value_great")
case .missing:
return String(localized: "mood_value_missing")
case .placeholder:
return String("placeholder")
}
}
/// Non-localized display name for use in widgets (which don't have access to app's localization)
var widgetDisplayName: String {
switch self {
case .horrible: return "Horrible"
case .bad: return "Bad"
case .average: return "Average"
case .good: return "Good"
case .great: return "Great"
case .missing: return "Missing"
case .placeholder: return "Placeholder"
}
}
static var allValues: [Mood] {
return [Mood.horrible, Mood.bad, Mood.average, Mood.good, Mood.great].reversed()
}
#if !os(watchOS)
var color: Color {
let moodTint: MoodTintable.Type = UserDefaultsStore.moodTintable()
return moodTint.color(forMood: self)
}
var icon: Image {
let moodImages: MoodImagable.Type = UserDefaultsStore.moodMoodImagable()
return moodImages.icon(forMood: self)
}
var graphic: Image {
switch self {
case .horrible:
return Image("HorribleGraphic", bundle: .main)
case .bad:
return Image("BadGraphic", bundle: .main)
case .average:
return Image("AverageGraphic", bundle: .main)
case .good:
return Image("GoodGraphic", bundle: .main)
case .great:
return Image("GreatGraphic", bundle: .main)
case .missing:
return Image("MissingGraphic", bundle: .main)
case .placeholder:
return Image("MissingGraphic", bundle: .main)
}
}
#endif
}
extension Mood: Identifiable {
var id: Int {
rawValue
}
}