//
//  ColorSetPicker.swift
//  AuraUtility
//
//  Created by Sunny Uppal on 10/22/24.
//

import Foundation
import SwiftUI
import Adamantium

struct ColorSetPicker: View {
    @Binding var selection: SunoTriColorSet
    
    var body: some View {
        Picker("", selection: $selection) {
            ForEach(SunoTriColorSet.allCases, id: \.stringValue) { colorSet in
                Text(colorSet.stringValue)
                .tag(colorSet)
            }
        }
        .pickerStyle(.wheel)
    }
}

extension SunoTriColorSet: Hashable, Equatable {

    static var allCases: [SunoTriColorSet] {
        return [
            .custom(.arcadeMaroon, .arcadeMaroon, .arcadeMaroon),
            .redLVioletBlue,
            .tanLaserBluePink,
            .cherryYellowMoss,
            .goldMossPink,
            .orangeMauveLime,
            .yellowOrangeBlue,
            .mauveVioletGreen,
            .fadedBlueGoldSand,
            .maroonVioletRed
        ]
    }
    
    public func hash(into hasher: inout Hasher) {
        hasher.combine(stringValue)
    }
    
    var stringValue: String {
        switch self {
        case .custom:
            return "Custom"
        case .redLVioletBlue:
            return "Red Violet Blue"
        case .tanLaserBluePink:
            return "Tan LaserBlue Pink"
        case .cherryYellowMoss:
            return "Cherry Yellow Moss"
        case .goldMossPink:
            return "Gold Moss Pink"
        case .orangeMauveLime:
            return "Orange Mauve Lime"
        case .yellowOrangeBlue:
            return "Yellow Orange Blue"
        case .mauveVioletGreen:
            return "Mauve Violet Green"
        case .fadedBlueGoldSand:
            return "FadedBlue Gold Sand"
        case .maroonVioletRed:
            return "Maroon Violet Red"
        }
    }
    
    func swiftUICodeString(a: String, b: String, c: String) -> String {
        switch self {
        case .custom:
            return ".custom(\n\t\t\t\(a),\n\t\t\t\(b),\n\t\t\t\(c)\n\t\t)"
        case .redLVioletBlue:
            return ".redLVioletBlue"
        case .tanLaserBluePink:
            return ".tanLaserBluePink"
        case .cherryYellowMoss:
            return ".cherryYellowMoss"
        case .goldMossPink:
            return ".goldMossPink"
        case .orangeMauveLime:
            return ".orangeMauveLime"
        case .yellowOrangeBlue:
            return ".yellowOrangeBlue"
        case .mauveVioletGreen:
            return ".mauveVioletGreen"
        case .fadedBlueGoldSand:
            return ".fadedBlueGoldSand"
        case .maroonVioletRed:
            return ".maroonVioletRed"
        }
    }
    
    public static func == (lhs: SunoTriColorSet, rhs: SunoTriColorSet) -> Bool {
        switch lhs {
        case .custom:
            guard case .custom = rhs else { return false }
            return true
        case .redLVioletBlue:
            guard case .redLVioletBlue = rhs else { return false }
            return true
        case .tanLaserBluePink:
            guard case .tanLaserBluePink = rhs else { return false }
            return true
        case .cherryYellowMoss:
            guard case .cherryYellowMoss = rhs else { return false }
            return true
        case .goldMossPink:
            guard case .goldMossPink = rhs else { return false }
            return true
        case .orangeMauveLime:
            guard case .orangeMauveLime = rhs else { return false }
            return true
        case .yellowOrangeBlue:
            guard case .yellowOrangeBlue = rhs else { return false }
            return true
        case .mauveVioletGreen:
            guard case .mauveVioletGreen = rhs else { return false }
            return true
        case .fadedBlueGoldSand:
            guard case .fadedBlueGoldSand = rhs else { return false }
            return true
        case .maroonVioletRed:
            guard case .maroonVioletRed = rhs else { return false }
            return true
        }
    }
}
