//
//  CustomIcon.swift
//  Feels (iOS)
//
//  Created by Trey Tartt on 2/20/22.
//

import SwiftUI

class IconViewModel: ObservableObject {
    static let numberOfBGItems = 109
    
    static let great = IconViewModel(backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
                                     bgColor: Color(hex: "31d158"),
                                     bgOverlayColor: Color(hex: "208939"),
                                     centerImage: MoodImages.FontAwesome.icon(forMood: .great),
                                     innerColor: Color(hex: "31d158"))
    
    static let good = IconViewModel(backgroundImage:  MoodImages.FontAwesome.icon(forMood: .good),
                                    bgColor: Color(hex: "ffd709"),
                                    bgOverlayColor: Color(hex: "9d8405"),
                                    centerImage: MoodImages.FontAwesome.icon(forMood: .good),
                                    innerColor: Color(hex: "ffd709"))
    
    static let average = IconViewModel(backgroundImage:  MoodImages.FontAwesome.icon(forMood: .average),
                                       bgColor: Color(hex: "0b84ff"),
                                       bgOverlayColor: Color(hex: "074f9a"),
                                       centerImage: MoodImages.FontAwesome.icon(forMood: .average),
                                       innerColor: Color(hex: "0b84ff"))
    
    static let bad = IconViewModel(backgroundImage:  MoodImages.FontAwesome.icon(forMood: .bad),
                                   bgColor: Color(hex: "ff9f0b"),
                                   bgOverlayColor: Color(hex: "a06407"),
                                   centerImage: MoodImages.FontAwesome.icon(forMood: .bad),
                                   innerColor: Color(hex: "ff9f0b"))
    
    static let horrible = IconViewModel(backgroundImage:  MoodImages.FontAwesome.icon(forMood: .horrible),
                                        bgColor: Color(hex: "fe5257"),
                                        bgOverlayColor: Color(hex: "a92b26"),
                                        centerImage: MoodImages.FontAwesome.icon(forMood: .horrible),
                                        innerColor: Color(hex: "fe5257"))
    
    init(backgroundImage: Image,
         bgColor: Color,
         bgOverlayColor: Color,
         centerImage: Image,
         innerColor: Color
    ) {
        
        var blah = [(Image, UUID)]()
        for _ in 0...IconViewModel.numberOfBGItems {
            blah.append((backgroundImage, UUID()))
        }
        
        self.background = blah
        self.bgColor = bgColor
        self.bgOverlayColor = bgOverlayColor
        self.centerImage = centerImage
        self.innerColor = innerColor
    }
    
    @Published var background: [(Image, UUID)]
    @Published var bgColor: Color
    @Published var bgOverlayColor: Color
    @Published var centerImage: Image
    @Published var innerColor: Color
}

enum CustomIconBackGroundOptions: String, CaseIterable, Codable {
    case horrible
    case bad
    case average
    case good
    case great
    case random
    
    static var selectable: [CustomIconBackGroundOptions] {
        return [.great, .good, .average, .bad, .horrible]
    }
    
    static public var defaultOption: CustomIconBackGroundOptions {
        CustomIconBackGroundOptions.random
    }
    
    public var image: Image {
        return Image(self.rawValue, bundle: .main)
    }
}
