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/entities/climate/widgets/climate_state.widget.dart

58 lines
2.0 KiB
Dart
Raw Normal View History

2019-08-24 21:22:32 +03:00
part of '../../../main.dart';
2018-10-27 14:27:41 +03:00
class ClimateStateWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final entityModel = EntityModel.of(context);
final ClimateEntity entity = entityModel.entityWrapper.entity;
2018-10-27 14:27:41 +03:00
String targetTemp = "-";
if ((entity.supportTargetTemperature) && (entity.temperature != null)) {
targetTemp = "${entity.temperature}";
2019-08-16 13:29:41 +03:00
} else if ((entity.supportTargetTemperatureRange) &&
(entity.targetLow != null) &&
(entity.targetHigh != null)) {
targetTemp = "${entity.targetLow} - ${entity.targetHigh}";
}
String displayState = '';
if (entity.hvacAction != null) {
displayState = "${entity.hvacAction} (${entity.displayState})";
} else {
displayState = "${entity.displayState}";
}
if (entity.presetMode != null) {
displayState += " - ${entity.presetMode}";
2018-10-27 14:27:41 +03:00
}
return Padding(
padding: EdgeInsets.fromLTRB(
2018-11-12 20:28:10 +02:00
0.0, 0.0, Sizes.rightWidgetPadding, 0.0),
2018-11-24 00:37:55 +02:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
children: <Widget>[
2019-08-16 13:29:41 +03:00
Text("$displayState",
2018-11-24 00:37:55 +02:00
textAlign: TextAlign.right,
style: new TextStyle(
fontWeight: FontWeight.bold,
2018-11-12 20:28:10 +02:00
fontSize: Sizes.stateFontSize,
2018-11-24 00:37:55 +02:00
)),
Text(" $targetTemp",
textAlign: TextAlign.right,
style: new TextStyle(
fontSize: Sizes.stateFontSize,
))
],
),
2019-08-16 13:29:41 +03:00
entity.currentTemperature != null ?
Text("Currently: ${entity.currentTemperature}",
2018-11-24 00:37:55 +02:00
textAlign: TextAlign.right,
style: new TextStyle(
fontSize: Sizes.stateFontSize,
color: Colors.black45)
) :
Container(height: 0.0,)
],
2018-10-27 14:27:41 +03:00
));
}
}