WIP #183 tap_action support. State change event fix

This commit is contained in:
Yegor Vialov
2018-11-16 22:32:43 +02:00
parent 1bd04abd37
commit 82c9bd26d1
29 changed files with 89 additions and 50 deletions

View File

@ -15,14 +15,29 @@ class EntityIcon extends StatelessWidget {
child: Padding(
padding: padding,
child: MaterialDesignIcons.createIconWidgetFromEntityData(
entityModel.entity,
entityModel.entityWrapper,
iconSize,
EntityColor.stateColor(entityModel.entity.entity.state)
EntityColor.stateColor(entityModel.entityWrapper.entity.state)
),
),
onTap: () => entityModel.handleTap
? eventBus.fire(new ShowEntityPageEvent(entityModel.entity.entity))
: null,
onTap: () {
if (entityModel.handleTap) {
switch (entityModel.entityWrapper.tapAction) {
case EntityTapAction.moreInfo: {
eventBus.fire(
new ShowEntityPageEvent(entityModel.entityWrapper.entity));
break;
}
case EntityTapAction.toggle: {
eventBus.fire(
ServiceCallEvent("homeassistant", "toggle", entityModel.entityWrapper.entity.entityId, null));
break;
}
}
}
}
);
}
}