//
//  SQIcon.swift
//
//
//  Created by Victor on 01/08/2024.
//

import SwiftUI

enum SQIconSize: CGFloat {
    /// 13px
    case xs = 13
    /// 14px
    case s = 14
    /// 16px
    case m = 16
    /// 20px
    case l = 20
    /// 24px
    case xl = 24
    /// 32px
    case xxl = 32
}

enum SQIconType {
    case regular
    case solid
}

enum SQIconName: String {
    case address_card
    case apple_brand
    case arrow_down_arrow_up
    case arrow_down
    case arrow_left
    case arrow_right
    case arrow_up
    case award
    case badge_check
    case ballot_check
    case ban
    case bars
    case bell_on
    case bell
    case bolt_lightning
    case bolt_slash
    case bolt
    case bookmark
    case box_archive
    case box
    case briefcase
    case building_columns
    case bullseye_arrow
    case calculator
    case calendar_days
    case calendar
    case camera_plus
    case camera_rotate
    case camera
    case chart_line_up
    case chart_user
    case check
    case chevron_down
    case chevron_left
    case chevron_right
    case chevron_up
    case circle_check
    case circle_exclamation
    case circle_info
    case circle_plus
    case circle_question
    case circle_user
    case circle_xmark
    case clipboard_list_check
    case clipboard
    case clock_rotate_left
    case clock
    case clone
    case coins
    case coupon
    case comment_dots_circle_play
    case comment_dots
    case comments
    case credit_card
    case crosshairs
    case demander_avis
    case demander_paiement
    case display
    case dolly
    case earth_americas
    case ellipsis_horizontal
    case ellipsis_vertical
    case envelope
    case euro_sign
    case evaluer
    case eye_slash
    case eye
    case face_smile_beam
    case facebook_f_brand
    case facebook_messenger_brand
    case fast_stopwatch
    case file_contract
    case file_export
    case file_invoice
    case file_pdf
    case file_pen
    case file_signature
    case files
    case film
    case flag
    case floppy_disk
    case gear
    case gen_euro_sign
    case google_brand
    case grid
    case handhsake
    case heart
    case hourglass_half
    case hourglass_start
    case house_chimney
    case house
    case image
    case images
    case inbox_in
    case inbox_out
    case lightbulb_on
    case link
    case location_dot
    case lock_keyhole_open
    case lock_keyhole
    case magnifying_glass
    case map
    case megaphone
    case message_dots
    case message
    case microphone_slash
    case microphone
    case minus
    case money_check_dollar_pen
    case palette
    case paper_plane_top
    case paper_plane
    case paperclip
    case payer
    case pen_to_square
    case phone_flip
    case phone
    case play_store_brand
    case plus
    case print
    case rocket_launch
    case share
    case shield_keyhole
    case signature
    case siren_on
    case sliders_up
    case sliders
    case spinner
    case stamp
    case star_half_stroke
    case star_shooting
    case star_trustpilot_brand
    case star
    case stopwatch
    case tag
    case thumbs_up
    case thumbstack_slash
    case thumbstack
    case ticket_simple
    case toolbox
    case trash_can
    case triangle_exclamation
    case umbrella_slash
    case umbrella
    case user_check
    case user_clock
    case user_group
    case user_plus
    case user_xmark
    case user
    case users
    case video
    case whatsapp_brand
    case xmark
    case x_twitter_brand
}

struct SQIcon: View {
    var name: SQIconName
    var size: SQIconSize
    var customSize: CGFloat?
    var type: SQIconType
    var color: Color

    init(_ name: SQIconName, size: SQIconSize = .m, customSize: CGFloat? = nil, type: SQIconType = .regular, color: Color = .sqNeutral(100)) {
        self.name = name
        self.size = size
        self.customSize = customSize
        self.type = type
        self.color = color
    }

    var body: some View {
        Image(type == .solid ? "\(name.rawValue)_solid" : name.rawValue)
            .resizable()
            .scaledToFit()
            .frame(height: customSize ?? size.rawValue)
            .foregroundColor(color)
    }
}

#Preview {
    VStack(spacing: 16) {
        HStack {
            SQIcon(.calendar_days, size: .xs)
            SQIcon(.calendar_days, size: .s)
            SQIcon(.calendar_days)
            SQIcon(.calendar_days, size: .l)
            SQIcon(.calendar_days, size: .xl)
            SQIcon(.calendar_days, size: .xxl)
        }
        HStack {
            SQIcon(.calendar_days, size: .xs, type: .solid)
            SQIcon(.calendar_days, size: .s, type: .solid)
            SQIcon(.calendar_days, type: .solid)
            SQIcon(.calendar_days, size: .l, type: .solid)
            SQIcon(.calendar_days, size: .xl, type: .solid)
            SQIcon(.calendar_days, size: .xxl, type: .solid)
        }
        HStack {
            SQIcon(.calendar_days, size: .xs, color: .sqGreen())
            SQIcon(.calendar_days, size: .s, color: .sqGreen())
            SQIcon(.calendar_days, color: .sqGreen())
            SQIcon(.calendar_days, size: .l, color: .sqGreen())
            SQIcon(.calendar_days, size: .xl, color: .sqGreen())
            SQIcon(.calendar_days, size: .xxl, color: .sqGreen())
        }
        HStack {
            SQIcon(.calendar_days, size: .xs, type: .solid, color: .sqGreen())
            SQIcon(.calendar_days, size: .s, type: .solid, color: .sqGreen())
            SQIcon(.calendar_days, type: .solid, color: .sqGreen())
            SQIcon(.calendar_days, size: .l, type: .solid, color: .sqGreen())
            SQIcon(.calendar_days, size: .xl, type: .solid, color: .sqGreen())
            SQIcon(.calendar_days, size: .xxl, type: .solid, color: .sqGreen())
        }
    }
}
