Files
Reflect/Shared/Models/MoodImagable.swift

105 lines
2.9 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
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)
}
}
var moodImages: MoodImagable.Type {
switch self {
case .FontAwesome:
return FontAwesomeMoodImages.self
case .Emoji:
return EmojiMoodImages.self
case .HandEmjoi:
return HandEmojiMoodImages.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)
}
}
}