Files
Reflect/Shared/Models/MoodImagable.swift
Trey t 2a703a8969 Add 4 new mood icon styles and improve widget layouts
New mood icon styles:
- Weather (☀️⛈️)
- Garden (🌸🥀)
- Hearts (💖💔)
- Cosmic (🕳️)

Widget improvements:
- Small vote widget: 3-over-2 grid layout
- Medium vote widget: single horizontal row
- Redesigned voted stats view with checkmark badge
- Fixed text truncation on non-subscriber view
- Added comprehensive previews for all widget types

Bug fix:
- Voting header now updates when mood image style changes

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 19:06:05 -06:00

208 lines
6.2 KiB
Swift

//
// MoodImagable.swift
// Feels (iOS)
//
// Created by Trey Tartt on 2/19/22.
//
import SwiftUI
protocol MoodImagable {
static func icon(forMood mood: Mood) -> Image
}
enum MoodImages: Int, CaseIterable {
case FontAwesome
case Emoji
case HandEmjoi
case Weather
case Garden
case Hearts
case Cosmic
func icon(forMood mood: Mood) -> Image {
switch self {
case .FontAwesome:
return FontAwesomeMoodImages.icon(forMood: mood)
case .Emoji:
return EmojiMoodImages.icon(forMood: mood)
case .HandEmjoi:
return HandEmojiMoodImages.icon(forMood: mood)
case .Weather:
return WeatherMoodImages.icon(forMood: mood)
case .Garden:
return GardenMoodImages.icon(forMood: mood)
case .Hearts:
return HeartsMoodImages.icon(forMood: mood)
case .Cosmic:
return CosmicMoodImages.icon(forMood: mood)
}
}
var moodImages: MoodImagable.Type {
switch self {
case .FontAwesome:
return FontAwesomeMoodImages.self
case .Emoji:
return EmojiMoodImages.self
case .HandEmjoi:
return HandEmojiMoodImages.self
case .Weather:
return WeatherMoodImages.self
case .Garden:
return GardenMoodImages.self
case .Hearts:
return HeartsMoodImages.self
case .Cosmic:
return CosmicMoodImages.self
}
}
}
final class FontAwesomeMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image("horrible", bundle: .main)
case .bad:
return Image("bad", bundle: .main)
case .average:
return Image("average", bundle: .main)
case .good:
return Image("good", bundle: .main)
case .great:
return Image("great", bundle: .main)
case .missing:
return Image("xmark-solid", bundle: .main)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}
final class EmojiMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image(uiImage: "💩".textToImage()!)
case .bad:
return Image(uiImage: "😕".textToImage()!)
case .average:
return Image(uiImage: "😑".textToImage()!)
case .good:
return Image(uiImage: "🙂".textToImage()!)
case .great:
return Image(uiImage: "😀".textToImage()!)
case .missing:
return Image("xmark-solid", bundle: .main)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}
final class HandEmojiMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image(uiImage: "🖕".textToImage()!)
case .bad:
return Image(uiImage: "👎".textToImage()!)
case .average:
return Image(uiImage: "🖖".textToImage()!)
case .good:
return Image(uiImage: "👍".textToImage()!)
case .great:
return Image(uiImage: "🙏".textToImage()!)
case .missing:
return Image("xmark-solid", bundle: .main)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}
final class WeatherMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image(uiImage: "⛈️".textToImage()!)
case .bad:
return Image(uiImage: "🌧️".textToImage()!)
case .average:
return Image(uiImage: "☁️".textToImage()!)
case .good:
return Image(uiImage: "".textToImage()!)
case .great:
return Image(uiImage: "☀️".textToImage()!)
case .missing:
return Image(uiImage: "🌫️".textToImage()!)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}
final class GardenMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image(uiImage: "🥀".textToImage()!)
case .bad:
return Image(uiImage: "🍂".textToImage()!)
case .average:
return Image(uiImage: "🌱".textToImage()!)
case .good:
return Image(uiImage: "🌿".textToImage()!)
case .great:
return Image(uiImage: "🌸".textToImage()!)
case .missing:
return Image(uiImage: "🕳️".textToImage()!)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}
final class HeartsMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image(uiImage: "💔".textToImage()!)
case .bad:
return Image(uiImage: "🩶".textToImage()!)
case .average:
return Image(uiImage: "🤍".textToImage()!)
case .good:
return Image(uiImage: "🩷".textToImage()!)
case .great:
return Image(uiImage: "💖".textToImage()!)
case .missing:
return Image(uiImage: "🖤".textToImage()!)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}
final class CosmicMoodImages: MoodImagable {
static func icon(forMood mood: Mood) -> Image {
switch mood {
case .horrible:
return Image(uiImage: "🕳️".textToImage()!)
case .bad:
return Image(uiImage: "🌑".textToImage()!)
case .average:
return Image(uiImage: "🌓".textToImage()!)
case .good:
return Image(uiImage: "🌕".textToImage()!)
case .great:
return Image(uiImage: "".textToImage()!)
case .missing:
return Image(uiImage: "".textToImage()!)
case .placeholder:
return Image("xmark-solid", bundle: .main)
}
}
}