Add state_color support

This commit is contained in:
Yegor Vialov
2020-04-28 21:03:00 +00:00
parent b029146bf3
commit 96b3e7c739
3 changed files with 29 additions and 11 deletions

View File

@ -60,11 +60,19 @@ class EntityIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
final EntityWrapper entityWrapper = EntityModel.of(context).entityWrapper;
Color iconColor;
if (color != null) {
iconColor = color;
} else if (entityWrapper.stateColor) {
iconColor = HAClientTheme().getColorByEntityState(entityWrapper.entity.state, context);
} else {
iconColor = HAClientTheme().getOffStateColor(context);
}
return Padding(
padding: padding,
child: buildIcon(
entityWrapper,
color ?? HAClientTheme().getColorByEntityState(entityWrapper.entity.state, context)
iconColor
),
);
}