This repository has been archived on 2023-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/lib/entity_widgets/entity_icon.dart

36 lines
957 B
Dart
Raw Normal View History

2018-10-27 14:27:41 +03:00
part of '../main.dart';
class EntityIcon extends StatelessWidget {
2018-11-14 19:52:17 +02:00
final EdgeInsetsGeometry padding;
final double iconSize;
const EntityIcon({Key key, this.iconSize: Sizes.iconSize, this.padding: const EdgeInsets.fromLTRB(
Sizes.leftWidgetPadding, 0.0, 12.0, 0.0)}) : super(key: key);
2018-10-27 14:27:41 +03:00
@override
Widget build(BuildContext context) {
final entityModel = EntityModel.of(context);
2018-11-23 16:03:38 +02:00
return InkWell(
2018-10-27 14:27:41 +03:00
child: Padding(
2018-11-14 19:52:17 +02:00
padding: padding,
2018-10-27 14:27:41 +03:00
child: MaterialDesignIcons.createIconWidgetFromEntityData(
entityModel.entityWrapper,
2018-11-14 19:52:17 +02:00
iconSize,
EntityColor.stateColor(entityModel.entityWrapper.entity.state)
2018-10-28 18:07:52 +02:00
),
2018-10-27 14:27:41 +03:00
),
onLongPress: () {
if (entityModel.handleTap) {
entityModel.entityWrapper.handleHold();
}
},
onTap: () {
if (entityModel.handleTap) {
entityModel.entityWrapper.handleTap();
}
}
2018-10-27 14:27:41 +03:00
);
}
}