//
//  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("missing", bundle: .main)
        case .placeholder:
            return Image("missing", 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("x-solid", bundle: .main)
        case .placeholder:
            return Image("x-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("x-solid", bundle: .main)
        case .placeholder:
            return Image("x-solid", bundle: .main)
        }
    }
}
