//
//  ThemeManager.swift
//  1Weather
//
//  Created by Dmitry Stepanets on 28.11.2020.
//

import UIKit

public enum AppTheme {
    case light
    case dark
    case system
}

public struct ThemeManager {
    struct Colors {
        static let locationBlue = UIColor(hex: 0x1071F0)
        static let temperatureLabelBG = UIColor(hex: 0x5F5F5F)
        static let citySelected = UIColor(hex: 0x599A0E)
        static let cityNoSelected = UIColor(hex: 0xC5C5C5).withAlphaComponent(0.5)
        static let cityAddButtonBG = UIColor(hex: 0x131315)
        static let searchBarTint = UIColor(hex: 0xEBEBF5).withAlphaComponent(0.6)
    }
    
    static var currentTheme:ThemeProtocol {
        return DefaultTheme()
    }
    
    static func refreshAppearance() {
        //Navigation bar
        UINavigationBar.appearance().barTintColor = currentTheme.navigationBarBackgroundColor
        UINavigationBar.appearance().isTranslucent = false
        UINavigationBar.appearance().tintColor = currentTheme.navigationTintColor
        UINavigationBar.appearance().shadowImage = UIImage()
        
        //Tab bar
        UITabBar.appearance().shadowImage = UIImage()
        UITabBar.appearance().backgroundImage = UIImage()
        UITabBar.appearance().isTranslucent = false
        UITabBar.appearance().barTintColor = currentTheme.tabBarBackgroundColor
        UITabBarItem.appearance().setTitleTextAttributes([.font : AppFont.SFPro.regular(size: 14),
                                                          .foregroundColor : currentTheme.tabBarNormalColor],
                                                         for: .normal)
        UITabBarItem.appearance().setTitleTextAttributes([.font : AppFont.SFPro.bold(size: 14),
                                                          .foregroundColor : currentTheme.tabBarTintColor],
                                                         for: .selected)
    }
}
