mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 11:06:32 +00:00
Add support for dark_icon
This commit is contained in:
parent
3b3cd61e3d
commit
0073660bdf
@ -543,6 +543,11 @@ class AddonModel(CoreSysAttributes, ABC):
|
|||||||
"""Return path to add-on icon."""
|
"""Return path to add-on icon."""
|
||||||
return Path(self.path_location, "icon.png")
|
return Path(self.path_location, "icon.png")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_dark_icon(self) -> Path:
|
||||||
|
"""Return path to the dark variant of the add-on icon."""
|
||||||
|
return Path(self.path_location, "dark_icon.png")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_logo(self) -> Path:
|
def path_logo(self) -> Path:
|
||||||
"""Return path to add-on logo."""
|
"""Return path to add-on logo."""
|
||||||
|
@ -69,6 +69,7 @@ from ..const import (
|
|||||||
ATTR_NETWORK_RX,
|
ATTR_NETWORK_RX,
|
||||||
ATTR_NETWORK_TX,
|
ATTR_NETWORK_TX,
|
||||||
ATTR_OPTIONS,
|
ATTR_OPTIONS,
|
||||||
|
ATTR_PREFER_DARK_ICON,
|
||||||
ATTR_PRIVILEGED,
|
ATTR_PRIVILEGED,
|
||||||
ATTR_PROTECTED,
|
ATTR_PROTECTED,
|
||||||
ATTR_PWNED,
|
ATTR_PWNED,
|
||||||
@ -113,6 +114,12 @@ _LOGGER: logging.Logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
SCHEMA_VERSION = vol.Schema({vol.Optional(ATTR_VERSION): str})
|
SCHEMA_VERSION = vol.Schema({vol.Optional(ATTR_VERSION): str})
|
||||||
|
|
||||||
|
SCHEMA_ICON = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_PREFER_DARK_ICON, default=False): bool,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
SCHEMA_OPTIONS = vol.Schema(
|
SCHEMA_OPTIONS = vol.Schema(
|
||||||
{
|
{
|
||||||
@ -463,6 +470,11 @@ class APIAddons(CoreSysAttributes):
|
|||||||
if not addon.with_icon:
|
if not addon.with_icon:
|
||||||
raise APIError(f"No icon found for add-on {addon.slug}!")
|
raise APIError(f"No icon found for add-on {addon.slug}!")
|
||||||
|
|
||||||
|
body = await api_validate(SCHEMA_ICON, request)
|
||||||
|
if body[ATTR_PREFER_DARK_ICON] and addon.path_dark_icon.exists():
|
||||||
|
with addon.path_dark_icon.open("rb") as png:
|
||||||
|
return png.read()
|
||||||
|
|
||||||
with addon.path_icon.open("rb") as png:
|
with addon.path_icon.open("rb") as png:
|
||||||
return png.read()
|
return png.read()
|
||||||
|
|
||||||
|
@ -255,6 +255,7 @@ ATTR_PASSWORD = "password"
|
|||||||
ATTR_PORT = "port"
|
ATTR_PORT = "port"
|
||||||
ATTR_PORTS = "ports"
|
ATTR_PORTS = "ports"
|
||||||
ATTR_PORTS_DESCRIPTION = "ports_description"
|
ATTR_PORTS_DESCRIPTION = "ports_description"
|
||||||
|
ATTR_PREFER_DARK_ICON = "prefer_dark_icon"
|
||||||
ATTR_PREFIX = "prefix"
|
ATTR_PREFIX = "prefix"
|
||||||
ATTR_PRIMARY = "primary"
|
ATTR_PRIMARY = "primary"
|
||||||
ATTR_PRIORITY = "priority"
|
ATTR_PRIORITY = "priority"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user