//
//  DefaultAppearance.swift
//  B24PaymentSdk
//
//  Created by visal ny on 19/12/24.
//

import Foundation
import UIKit

class DefaultAppearance{
    static let shared = DefaultAppearance() // Singleton instance

        private init() {}

        // Default color values
        var primaryColor: UIColor = UIColor(hex: "#54A6DB")
        var screenBgColor: UIColor = UIColor(hex: "#F2F0ED")
        var primaryLabelColor: UIColor = UIColor(hex: "#212E3B")
        var secondaryLabelColor: UIColor = UIColor(hex: "#214775")
        var cardColor: UIColor = UIColor(hex: "#FFFFFF")
        var onPrimaryColor: UIColor = UIColor(hex: "#FFFFFF")
        var dangerColor: UIColor = UIColor(hex: "#FF5952")
        var warningColor: UIColor = UIColor(hex: "#FFC668")
        var successColor: UIColor = UIColor(hex: "#17A865")
        var walletCardColor: UIColor = UIColor(hex: "#214775")

        //font name
       var fontEnglish:String? = ""
       var fontKhmer:String? = ""

        // Error Background Color
        static let bgError: UIColor = UIColor(hex: "#FAEEEE")

        // Set appearance based on mode
        func setAppearance(_ appearance: DWalletAppearance, isDarkMode: Bool) {

            fontEnglish =  appearance.fontEnglish
            fontKhmer = appearance.fontKhmer

            if isDarkMode {
                let darkMode = appearance.darkMode ?? DWalletMode.darkModeDefaults()
                primaryColor = UIColor(hex: darkMode.primaryColor)
                screenBgColor = UIColor(hex: darkMode.screenBgColor)
                primaryLabelColor = UIColor(hex: darkMode.primaryLabelColor)
                secondaryLabelColor = UIColor(hex: darkMode.secondaryLabelColor)
                cardColor = UIColor(hex: darkMode.cardColor)
                onPrimaryColor = UIColor(hex: darkMode.onPrimaryColor)
                dangerColor = UIColor(hex: darkMode.dangerColor)
                warningColor = UIColor(hex: darkMode.warningColor)
                successColor = UIColor(hex: darkMode.successColor ?? "#17A865")
                walletCardColor = UIColor(hex: darkMode.walletCardColor ?? "#1A2D4A")
            } else {
                let lightMode = appearance.lightMode ?? DWalletMode()
                primaryColor = UIColor(hex: lightMode.primaryColor)
                screenBgColor = UIColor(hex: lightMode.screenBgColor)
                primaryLabelColor = UIColor(hex: lightMode.primaryLabelColor)
                secondaryLabelColor = UIColor(hex: lightMode.secondaryLabelColor)
                cardColor = UIColor(hex: lightMode.cardColor)
                onPrimaryColor = UIColor(hex: lightMode.onPrimaryColor)
                dangerColor = UIColor(hex: lightMode.dangerColor)
                warningColor = UIColor(hex: lightMode.warningColor)
                successColor = UIColor(hex: lightMode.successColor ?? "#17A865")
                walletCardColor = UIColor(hex: lightMode.walletCardColor ?? "#214775")
            }
        }
}
