diff --git a/lib/entity_class/stateful_widgets.dart b/lib/entity_class/stateful_widgets.dart index d286cae..36d1eb5 100644 --- a/lib/entity_class/stateful_widgets.dart +++ b/lib/entity_class/stateful_widgets.dart @@ -404,6 +404,7 @@ class _ClimateControlWidgetState extends State { children: [ _buildOnOffControl(entity), _buildTemperatureControls(entity), + _buildTargetTemperatureControls(entity), _buildHumidityControls(entity), _buildOperationControl(entity), _buildFanControl(entity), @@ -578,139 +579,68 @@ class _ClimateControlWidgetState extends State { } Widget _buildTemperatureControls(ClimateEntity entity) { - List result = []; if ((entity.supportTargetTemperature) && (entity.temperature != null)) { - result.addAll([ - Text( - "$_tmpTemperature", - style: TextStyle( - fontSize: entity.largeFontSize, - color: _showPending ? Colors.red : Colors.black - ), - ), - Column( - children: [ - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-up')), - iconSize: 30.0, - onPressed: () => _temperatureUp(entity, 0.1), - ), - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-down')), - iconSize: 30.0, - onPressed: () => _temperatureDown(entity, 0.1), - ) - ], - ), - Column( - children: [ - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-double-up')), - iconSize: 30.0, - onPressed: () => _temperatureUp(entity, 0.5), - ), - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-double-down')), - iconSize: 30.0, - onPressed: () => _temperatureDown(entity, 0.5), - ) - ], - ) - ]); - } else if (entity.supportTargetTemperatureHigh && entity.supportTargetTemperatureLow && (entity.targetHigh != null) && (entity.targetLow != null)) { - result.addAll([ - Text( - "$_tmpTargetLow", - style: TextStyle( - fontSize: entity.largeFontSize, - color: _showPending ? Colors.red : Colors.black - ), - ), - Column( - children: [ - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-up')), - iconSize: 30.0, - onPressed: () => _targetLowUp(entity, 0.1), - ), - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-down')), - iconSize: 30.0, - onPressed: () => _targetLowDown(entity, 0.1), - ) - ], - ), - Column( - children: [ - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-double-up')), - iconSize: 30.0, - onPressed: () => _targetLowUp(entity, 0.5), - ), - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-double-down')), - iconSize: 30.0, - onPressed: () => _targetLowDown(entity, 0.5), - ) - ], - ), - Expanded( - child: Container(height: 10.0), - ), - Text( - "$_tmpTargetHigh", - style: TextStyle( - fontSize: entity.largeFontSize, - color: _showPending ? Colors.red : Colors.black - ), - ), - Column( - children: [ - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-up')), - iconSize: 30.0, - onPressed: () => _targetHighUp(entity, 0.1), - ), - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-down')), - iconSize: 30.0, - onPressed: () => _targetHighDown(entity, 0.1), - ) - ], - ), - Column( - children: [ - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-double-up')), - iconSize: 30.0, - onPressed: () => _targetHighUp(entity, 0.5), - ), - IconButton( - icon: Icon(MaterialDesignIcons.createIconDataFromIconName('mdi:chevron-double-down')), - iconSize: 30.0, - onPressed: () => _targetHighDown(entity, 0.5), - ) - ], - ) - ]); - } else if (entity.supportTargetTemperatureHigh || entity.supportTargetTemperatureLow) { - result.add(Text("Unsupported temperature control. Please, report an issue.")); - } - if (result.isNotEmpty) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text("Target temperature", style: TextStyle( fontSize: entity.stateFontSize )), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: result, + TemperatureControlWidget( + value: _tmpTemperature, + onLargeDec: () => _temperatureDown(entity, 0.5), + onLargeInc: () => _temperatureUp(entity, 0.5), + onSmallDec: () => _temperatureDown(entity, 0.1), + onSmallInc: () => _temperatureUp(entity, 0.1), ) ], ); } else { - return Container(height: 0.0, width: 0.0,); + return Container(width: 0.0, height: 0.0,); + } + } + + Widget _buildTargetTemperatureControls(ClimateEntity entity) { + List controls = []; + if ((entity.supportTargetTemperatureLow) && (entity.targetLow != null)) { + controls.addAll([ + TemperatureControlWidget( + value: _tmpTargetLow, + onLargeDec: () => _targetLowDown(entity, 0.5), + onLargeInc: () => _targetLowUp(entity, 0.5), + onSmallDec: () => _targetLowDown(entity, 0.1), + onSmallInc: () => _targetLowUp(entity, 0.1), + ), + Expanded( + child: Container(height: 10.0), + ) + ]); + } + if ((entity.supportTargetTemperatureHigh) && (entity.targetHigh != null)) { + controls.add( + TemperatureControlWidget( + value: _tmpTargetHigh, + onLargeDec: () => _targetHighDown(entity, 0.5), + onLargeInc: () => _targetHighUp(entity, 0.5), + onSmallDec: () => _targetHighDown(entity, 0.1), + onSmallInc: () => _targetHighUp(entity, 0.1), + ) + ); + } + if (controls.isNotEmpty) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Target temperature range", style: TextStyle( + fontSize: entity.stateFontSize + )), + Row( + children: controls, + ) + ], + ); + } else { + return Container(width: 0.0, height: 0.0); } } diff --git a/lib/entity_class/stateless_widgets.dart b/lib/entity_class/stateless_widgets.dart index 2b5446f..3d67b1a 100644 --- a/lib/entity_class/stateless_widgets.dart +++ b/lib/entity_class/stateless_widgets.dart @@ -1,11 +1,8 @@ part of '../main.dart'; -class EntityWidgetsSizes { - -} +class EntityWidgetsSizes {} class EntityModel extends InheritedWidget { - const EntityModel({ Key key, @required this.entity, @@ -24,11 +21,9 @@ class EntityModel extends InheritedWidget { bool updateShouldNotify(InheritedWidget oldWidget) { return true; } - } class DefaultEntityContainer extends StatelessWidget { - DefaultEntityContainer({ Key key, @required this.state, @@ -52,11 +47,9 @@ class DefaultEntityContainer extends StatelessWidget { ), ); } - } class EntityPageContainer extends StatelessWidget { - EntityPageContainer({Key key, @required this.children}) : super(key: key); final List children; @@ -67,17 +60,15 @@ class EntityPageContainer extends StatelessWidget { children: children, ); } - } class SimpleEntityState extends StatelessWidget { - @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); return Padding( - padding: - EdgeInsets.fromLTRB(0.0, 0.0, entityModel.entity.rightWidgetPadding, 0.0), + padding: EdgeInsets.fromLTRB( + 0.0, 0.0, entityModel.entity.rightWidgetPadding, 0.0), child: GestureDetector( child: Text( "${entityModel.entity.state}${entityModel.entity.unitOfMeasurement}", @@ -85,15 +76,14 @@ class SimpleEntityState extends StatelessWidget { style: new TextStyle( fontSize: entityModel.entity.stateFontSize, )), - onTap: () => entityModel.handleTap ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) : null, - ) - ); + onTap: () => entityModel.handleTap + ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) + : null, + )); } - } class EntityName extends StatelessWidget { - @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); @@ -107,34 +97,36 @@ class EntityName extends StatelessWidget { style: TextStyle(fontSize: entityModel.entity.nameFontSize), ), ), - onTap: () => entityModel.handleTap ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) : null, + onTap: () => entityModel.handleTap + ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) + : null, ); } - } class EntityIcon extends StatelessWidget { - @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); return GestureDetector( child: Padding( - padding: EdgeInsets.fromLTRB(entityModel.entity.leftWidgetPadding, 0.0, 12.0, 0.0), + padding: EdgeInsets.fromLTRB( + entityModel.entity.leftWidgetPadding, 0.0, 12.0, 0.0), //TODO: move createIconWidgetFromEntityData into this widget child: MaterialDesignIcons.createIconWidgetFromEntityData( entityModel.entity, entityModel.entity.iconSize, - Entity.STATE_ICONS_COLORS[entityModel.entity.state] ?? Entity.STATE_ICONS_COLORS["default"]), + Entity.STATE_ICONS_COLORS[entityModel.entity.state] ?? + Entity.STATE_ICONS_COLORS["default"]), ), - onTap: () => entityModel.handleTap ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) : null, + onTap: () => entityModel.handleTap + ? eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) + : null, ); } - } class LastUpdatedWidget extends StatelessWidget { - @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); @@ -144,35 +136,31 @@ class LastUpdatedWidget extends StatelessWidget { child: Text( '${entityModel.entity.lastUpdated}', textAlign: TextAlign.left, - style: - TextStyle(fontSize: entityModel.entity.smallFontSize, color: Colors.black26), + style: TextStyle( + fontSize: entityModel.entity.smallFontSize, color: Colors.black26), ), ); } - } class EntityAttributesList extends StatelessWidget { - EntityAttributesList({Key key}) : super(key: key); @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); List attrs = []; - if ((entityModel.entity.attributesToShow == null) || (entityModel.entity.attributesToShow.contains("all"))) { - entityModel.entity.attributes.forEach((name, value){ - attrs.add( - _buildSingleAttribute(entityModel.entity, "$name", "$value") - ); + if ((entityModel.entity.attributesToShow == null) || + (entityModel.entity.attributesToShow.contains("all"))) { + entityModel.entity.attributes.forEach((name, value) { + attrs.add(_buildSingleAttribute(entityModel.entity, "$name", "$value")); }); } else { entityModel.entity.attributesToShow.forEach((String attr) { String attrValue = entityModel.entity.getAttribute("$attr"); if (attrValue != null) { attrs.add( - _buildSingleAttribute(entityModel.entity, "$attr", "$attrValue") - ); + _buildSingleAttribute(entityModel.entity, "$attr", "$attrValue")); } }); } @@ -188,7 +176,8 @@ class EntityAttributesList extends StatelessWidget { children: [ Expanded( child: Padding( - padding: EdgeInsets.fromLTRB(entity.leftWidgetPadding, entity.rowPadding, 0.0, 0.0), + padding: EdgeInsets.fromLTRB( + entity.leftWidgetPadding, entity.rowPadding, 0.0, 0.0), child: Text( "$name", textAlign: TextAlign.left, @@ -197,7 +186,8 @@ class EntityAttributesList extends StatelessWidget { ), Expanded( child: Padding( - padding: EdgeInsets.fromLTRB(0.0, entity.rowPadding, entity.rightWidgetPadding, 0.0), + padding: EdgeInsets.fromLTRB( + 0.0, entity.rowPadding, entity.rightWidgetPadding, 0.0), child: Text( "$value", textAlign: TextAlign.right, @@ -210,48 +200,54 @@ class EntityAttributesList extends StatelessWidget { } class Badge extends StatelessWidget { - @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); double iconSize = 26.0; Widget badgeIcon; String onBadgeTextValue; - Color iconColor = Entity.badgeColors[entityModel.entity.domain] ?? Entity.badgeColors["default"]; + Color iconColor = Entity.badgeColors[entityModel.entity.domain] ?? + Entity.badgeColors["default"]; switch (entityModel.entity.domain) { - case "sun": { - badgeIcon = entityModel.entity.state == "below_horizon" ? - Icon( - MaterialDesignIcons.createIconDataFromIconCode(0xf0dc), - size: iconSize, - ) : - Icon( - MaterialDesignIcons.createIconDataFromIconCode(0xf5a8), - size: iconSize, - ); - break; - } - case "sensor": { - onBadgeTextValue = entityModel.entity.unitOfMeasurement; - badgeIcon = Center( - child: Text( - "${entityModel.entity.state}", - overflow: TextOverflow.fade, - softWrap: false, - textAlign: TextAlign.center, - style: TextStyle(fontSize: 17.0), - ), - ); - break; - } - case "device_tracker": { - badgeIcon = MaterialDesignIcons.createIconWidgetFromEntityData(entityModel.entity, iconSize,Colors.black); - onBadgeTextValue = entityModel.entity.state; - break; - } - default: { - badgeIcon = MaterialDesignIcons.createIconWidgetFromEntityData(entityModel.entity, iconSize,Colors.black); - } + case "sun": + { + badgeIcon = entityModel.entity.state == "below_horizon" + ? Icon( + MaterialDesignIcons.createIconDataFromIconCode(0xf0dc), + size: iconSize, + ) + : Icon( + MaterialDesignIcons.createIconDataFromIconCode(0xf5a8), + size: iconSize, + ); + break; + } + case "sensor": + { + onBadgeTextValue = entityModel.entity.unitOfMeasurement; + badgeIcon = Center( + child: Text( + "${entityModel.entity.state}", + overflow: TextOverflow.fade, + softWrap: false, + textAlign: TextAlign.center, + style: TextStyle(fontSize: 17.0), + ), + ); + break; + } + case "device_tracker": + { + badgeIcon = MaterialDesignIcons.createIconWidgetFromEntityData( + entityModel.entity, iconSize, Colors.black); + onBadgeTextValue = entityModel.entity.state; + break; + } + default: + { + badgeIcon = MaterialDesignIcons.createIconWidgetFromEntityData( + entityModel.entity, iconSize, Colors.black); + } } Widget onBadgeText; if (onBadgeTextValue == null || onBadgeTextValue.length == 0) { @@ -261,71 +257,70 @@ class Badge extends StatelessWidget { padding: EdgeInsets.fromLTRB(6.0, 2.0, 6.0, 2.0), child: Text("$onBadgeTextValue", style: TextStyle(fontSize: 12.0, color: Colors.white), - textAlign: TextAlign.center, softWrap: false, overflow: TextOverflow.fade), + textAlign: TextAlign.center, + softWrap: false, + overflow: TextOverflow.fade), decoration: new BoxDecoration( // Circle shape //shape: BoxShape.circle, color: iconColor, borderRadius: BorderRadius.circular(9.0), - ) - ); + )); } return GestureDetector( - child: Column( - children: [ - Container( - margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0), - width: 50.0, - height: 50.0, - decoration: new BoxDecoration( - // Circle shape - shape: BoxShape.circle, - color: Colors.white, - // The border you want - border: new Border.all( - width: 2.0, - color: iconColor, + child: Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0), + width: 50.0, + height: 50.0, + decoration: new BoxDecoration( + // Circle shape + shape: BoxShape.circle, + color: Colors.white, + // The border you want + border: new Border.all( + width: 2.0, + color: iconColor, + ), + ), + child: Stack( + overflow: Overflow.visible, + children: [ + Positioned( + width: 46.0, + height: 46.0, + top: 0.0, + left: 0.0, + child: badgeIcon, + ), + Positioned( + //width: 50.0, + bottom: -9.0, + left: -10.0, + right: -10.0, + child: Center( + child: onBadgeText, + )) + ], ), ), - child: Stack( - overflow: Overflow.visible, - children: [ - Positioned( - width: 46.0, - height: 46.0, - top: 0.0, - left: 0.0, - child: badgeIcon, - ), - Positioned( - //width: 50.0, - bottom: -9.0, - left: -10.0, - right: -10.0, - child: Center( - child: onBadgeText, - ) - ) - ], + Container( + width: 60.0, + child: Text( + "${entityModel.entity.displayName}", + textAlign: TextAlign.center, + style: TextStyle(fontSize: 12.0), + softWrap: true, + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), ), - ), - Container( - width: 60.0, - child: Text( - "${entityModel.entity.displayName}", - textAlign: TextAlign.center, - style: TextStyle(fontSize: 12.0), - softWrap: true, - maxLines: 3, - overflow: TextOverflow.ellipsis, - ), - ), - ], - ), - onTap: () => eventBus.fire(new ShowEntityPageEvent(entityModel.entity)) - ); + ], + ), + onTap: () => + eventBus.fire(new ShowEntityPageEvent(entityModel.entity))); } - } class ClimateStateWidget extends StatelessWidget { @@ -334,73 +329,140 @@ class ClimateStateWidget extends StatelessWidget { final entityModel = EntityModel.of(context); final ClimateEntity entity = entityModel.entity; String targetTemp = "-"; - if ((entity.supportTargetTemperature) && (entity.temperature!=null)) { + if ((entity.supportTargetTemperature) && (entity.temperature != null)) { targetTemp = "${entity.temperature}"; - } else if ((entity.supportTargetTemperatureLow) && (entity.targetLow != null)) { + } else if ((entity.supportTargetTemperatureLow) && + (entity.targetLow != null)) { targetTemp = "${entity.targetLow}"; - if ((entity.supportTargetTemperatureHigh) && (entity.targetHigh != null)) { + if ((entity.supportTargetTemperatureHigh) && + (entity.targetHigh != null)) { targetTemp += " - ${entity.targetHigh}"; } } return Padding( - padding: - EdgeInsets.fromLTRB(0.0, 0.0, entityModel.entity.rightWidgetPadding, 0.0), + padding: EdgeInsets.fromLTRB( + 0.0, 0.0, entityModel.entity.rightWidgetPadding, 0.0), child: GestureDetector( child: Column( crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, children: [ Row( children: [ - Text( - "${entity.state}", + Text("${entity.state}", textAlign: TextAlign.right, style: new TextStyle( fontWeight: FontWeight.bold, fontSize: entityModel.entity.stateFontSize, )), - Text( - " $targetTemp", + Text(" $targetTemp", textAlign: TextAlign.right, style: new TextStyle( fontSize: entityModel.entity.stateFontSize, )) ], ), - Text( - "Currently: ${entity.attributes["current_temperature"]}", + entity.attributes["current_temperature"] != null ? + Text("Currently: ${entity.attributes["current_temperature"]}", textAlign: TextAlign.right, style: new TextStyle( fontSize: entityModel.entity.stateFontSize, - color: Colors.black45 - )) + color: Colors.black45) + ) : + Container(height: 0.0,) ], ), - onTap: () => entityModel.handleTap ? eventBus.fire(new ShowEntityPageEvent(entity)) : null, + onTap: () => entityModel.handleTap + ? eventBus.fire(new ShowEntityPageEvent(entity)) + : null, + )); + } +} + +class TemperatureControlWidget extends StatelessWidget { + final double value; + final double fontSize; + final Color fontColor; + final onSmallInc; + final onLargeInc; + final onSmallDec; + final onLargeDec; + + TemperatureControlWidget( + {Key key, + @required this.value, + @required this.onSmallInc, + @required this.onSmallDec, + @required this.onLargeInc, + @required this.onLargeDec, + this.fontSize, + this.fontColor}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "$value", + style: TextStyle( + fontSize: fontSize ?? 24.0, + color: fontColor ?? Colors.black + ), + ), + Column( + children: [ + IconButton( + icon: Icon(MaterialDesignIcons.createIconDataFromIconName( + 'mdi:chevron-up')), + iconSize: 30.0, + onPressed: () => onSmallInc(), + ), + IconButton( + icon: Icon(MaterialDesignIcons.createIconDataFromIconName( + 'mdi:chevron-down')), + iconSize: 30.0, + onPressed: () => onSmallDec(), + ) + ], + ), + Column( + children: [ + IconButton( + icon: Icon(MaterialDesignIcons.createIconDataFromIconName( + 'mdi:chevron-double-up')), + iconSize: 30.0, + onPressed: () => onLargeInc(), + ), + IconButton( + icon: Icon(MaterialDesignIcons.createIconDataFromIconName( + 'mdi:chevron-double-down')), + iconSize: 30.0, + onPressed: () => onLargeDec(), + ) + ], ) + ], ); } - } class DateTimeStateWidget extends StatelessWidget { - @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); final DateTimeEntity entity = entityModel.entity; return Padding( - padding: - EdgeInsets.fromLTRB(0.0, 0.0, entity.rightWidgetPadding, 0.0), + padding: EdgeInsets.fromLTRB(0.0, 0.0, entity.rightWidgetPadding, 0.0), child: GestureDetector( - child: Text( - "${entity.formattedState}", + child: Text("${entity.formattedState}", textAlign: TextAlign.right, style: new TextStyle( fontSize: entity.stateFontSize, )), onTap: () => _handleStateTap(context, entity), - ) - ); + )); } void _handleStateTap(BuildContext context, DateTimeEntity entity) { @@ -408,18 +470,35 @@ class DateTimeStateWidget extends StatelessWidget { _showDatePicker(context, entity).then((date) { if (date != null) { if (entity.hasTime) { - _showTimePicker(context, entity).then((time){ - entity.setNewState({"date": "${formatDate(date, [yyyy, '-', mm, '-', dd])}", "time": "${formatDate(DateTime(1970, 1, 1, time.hour, time.minute), [HH, ':', nn])}"}); + _showTimePicker(context, entity).then((time) { + entity.setNewState({ + "date": "${formatDate(date, [yyyy, '-', mm, '-', dd])}", + "time": + "${formatDate(DateTime(1970, 1, 1, time.hour, time.minute), [ + HH, + ':', + nn + ])}" + }); }); } else { - entity.setNewState({"date": "${formatDate(date, [yyyy, '-', mm, '-', dd])}"}); + entity.setNewState({ + "date": "${formatDate(date, [yyyy, '-', mm, '-', dd])}" + }); } } }); } else if (entity.hasTime) { - _showTimePicker(context, entity).then((time){ + _showTimePicker(context, entity).then((time) { if (time != null) { - entity.setNewState({"time": "${formatDate(DateTime(1970, 1, 1, time.hour, time.minute), [HH, ':', nn])}"}); + entity.setNewState({ + "time": + "${formatDate(DateTime(1970, 1, 1, time.hour, time.minute), [ + HH, + ':', + nn + ])}" + }); } }); } else { @@ -433,30 +512,30 @@ class DateTimeStateWidget extends StatelessWidget { initialDate: entity.dateTimeState, firstDate: DateTime(1970), lastDate: DateTime(2037) //Unix timestamp will finish at Jan 19, 2038 - ); + ); } Future _showTimePicker(BuildContext context, DateTimeEntity entity) { return showTimePicker( context: context, - initialTime: TimeOfDay.fromDateTime(entity.dateTimeState) - ); + initialTime: TimeOfDay.fromDateTime(entity.dateTimeState)); } - } class CoverEntityControlState extends StatelessWidget { - void _open(CoverEntity entity) { - eventBus.fire(new ServiceCallEvent(entity.domain, "open_cover", entity.entityId, null)); + eventBus.fire(new ServiceCallEvent( + entity.domain, "open_cover", entity.entityId, null)); } void _close(CoverEntity entity) { - eventBus.fire(new ServiceCallEvent(entity.domain, "close_cover", entity.entityId, null)); + eventBus.fire(new ServiceCallEvent( + entity.domain, "close_cover", entity.entityId, null)); } void _stop(CoverEntity entity) { - eventBus.fire(new ServiceCallEvent(entity.domain, "stop_cover", entity.entityId, null)); + eventBus.fire(new ServiceCallEvent( + entity.domain, "stop_cover", entity.entityId, null)); } @override @@ -465,64 +544,62 @@ class CoverEntityControlState extends StatelessWidget { final CoverEntity entity = entityModel.entity; List buttons = []; if (entity.supportOpen) { - buttons.add( - IconButton( - icon: Icon( - MaterialDesignIcons.createIconDataFromIconName("mdi:arrow-up"), - size: entity.iconSize, - ), - onPressed: entity.canBeOpened ? () =>_open(entity) : null - ) - ); + buttons.add(IconButton( + icon: Icon( + MaterialDesignIcons.createIconDataFromIconName("mdi:arrow-up"), + size: entity.iconSize, + ), + onPressed: entity.canBeOpened ? () => _open(entity) : null)); } else { - buttons.add(Container(width: entity.iconSize+20.0,)); + buttons.add(Container( + width: entity.iconSize + 20.0, + )); } if (entity.supportStop) { - buttons.add( - IconButton( - icon: Icon( - MaterialDesignIcons.createIconDataFromIconName("mdi:stop"), - size: entity.iconSize, - ), - onPressed: () => _stop(entity) - ) - ); + buttons.add(IconButton( + icon: Icon( + MaterialDesignIcons.createIconDataFromIconName("mdi:stop"), + size: entity.iconSize, + ), + onPressed: () => _stop(entity))); } else { - buttons.add(Container(width: entity.iconSize+20.0,)); + buttons.add(Container( + width: entity.iconSize + 20.0, + )); } if (entity.supportClose) { - buttons.add( - IconButton( - icon: Icon( - MaterialDesignIcons.createIconDataFromIconName("mdi:arrow-down"), - size: entity.iconSize, - ), - onPressed: entity.canBeClosed ? () => _close(entity) : null - ) - ); + buttons.add(IconButton( + icon: Icon( + MaterialDesignIcons.createIconDataFromIconName("mdi:arrow-down"), + size: entity.iconSize, + ), + onPressed: entity.canBeClosed ? () => _close(entity) : null)); } else { - buttons.add(Container(width: entity.iconSize+20.0,)); + buttons.add(Container( + width: entity.iconSize + 20.0, + )); } return Row( children: buttons, ); } - } class CoverEntityTiltControlButtons extends StatelessWidget { - void _open(CoverEntity entity) { - eventBus.fire(new ServiceCallEvent(entity.domain, "open_cover_tilt", entity.entityId, null)); + eventBus.fire(new ServiceCallEvent( + entity.domain, "open_cover_tilt", entity.entityId, null)); } void _close(CoverEntity entity) { - eventBus.fire(new ServiceCallEvent(entity.domain, "close_cover_tilt", entity.entityId, null)); + eventBus.fire(new ServiceCallEvent( + entity.domain, "close_cover_tilt", entity.entityId, null)); } void _stop(CoverEntity entity) { - eventBus.fire(new ServiceCallEvent(entity.domain, "stop_cover_tilt", entity.entityId, null)); + eventBus.fire(new ServiceCallEvent( + entity.domain, "stop_cover_tilt", entity.entityId, null)); } @override @@ -531,48 +608,46 @@ class CoverEntityTiltControlButtons extends StatelessWidget { final CoverEntity entity = entityModel.entity; List buttons = []; if (entity.supportOpenTilt) { - buttons.add( - IconButton( - icon: Icon( - MaterialDesignIcons.createIconDataFromIconName("mdi:arrow-top-right"), - size: entity.iconSize, - ), - onPressed: entity.canTiltBeOpened ? () =>_open(entity) : null - ) - ); + buttons.add(IconButton( + icon: Icon( + MaterialDesignIcons.createIconDataFromIconName( + "mdi:arrow-top-right"), + size: entity.iconSize, + ), + onPressed: entity.canTiltBeOpened ? () => _open(entity) : null)); } else { - buttons.add(Container(width: entity.iconSize+20.0,)); + buttons.add(Container( + width: entity.iconSize + 20.0, + )); } if (entity.supportStopTilt) { - buttons.add( - IconButton( - icon: Icon( - MaterialDesignIcons.createIconDataFromIconName("mdi:stop"), - size: entity.iconSize, - ), - onPressed: () => _stop(entity) - ) - ); + buttons.add(IconButton( + icon: Icon( + MaterialDesignIcons.createIconDataFromIconName("mdi:stop"), + size: entity.iconSize, + ), + onPressed: () => _stop(entity))); } else { - buttons.add(Container(width: entity.iconSize+20.0,)); + buttons.add(Container( + width: entity.iconSize + 20.0, + )); } if (entity.supportCloseTilt) { - buttons.add( - IconButton( - icon: Icon( - MaterialDesignIcons.createIconDataFromIconName("mdi:arrow-bottom-left"), - size: entity.iconSize, - ), - onPressed: entity.canTiltBeClosed ? () => _close(entity) : null - ) - ); + buttons.add(IconButton( + icon: Icon( + MaterialDesignIcons.createIconDataFromIconName( + "mdi:arrow-bottom-left"), + size: entity.iconSize, + ), + onPressed: entity.canTiltBeClosed ? () => _close(entity) : null)); } else { - buttons.add(Container(width: entity.iconSize+20.0,)); + buttons.add(Container( + width: entity.iconSize + 20.0, + )); } return Row( children: buttons, ); } - -} \ No newline at end of file +}