from omegaconf import OmegaConf, DictConfig
from typing import Optional


class Icons:
    _config: Optional[DictConfig] = None

    def __init__(self):
        self._config = OmegaConf.load("icons/icons.yaml")
        self.config_path = "icons/config.yaml"

    def save(self):
        OmegaConf.save(self._config, self.config_path)

    @property
    def icons(self):
        return self._config.icons

    def get_icon(self, name: str):
        return self.icons[name]

    def set_icon(self, name: str, value: str):
        self._config.icons[name] = value

    @property
    def path(self):
        return self._config.icon_path

    @property
    def colors(self):
        return self._config.colors

    @colors.setter
    def colors(self, value):
        self._config.colors = value

    @property
    def dark(self):
        return self._config.colors.dark

    @property
    def light(self):
        return self._config.colors.light

    @property
    def warning(self):
        return self._config.colors.warning

    @property
    def success(self):
        return self._config.colors.success

    def set_color(self, name: str, value: str):
        self._config.colors[name] = value

    @icons.setter
    def icons(self, value):
        self._config.icons = value
