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/state/simple_state.dart

35 lines
952 B
Dart
Raw Normal View History

2018-10-27 14:27:41 +03:00
part of '../../main.dart';
class SimpleEntityState extends StatelessWidget {
2018-11-05 20:21:44 +02:00
final bool expanded;
const SimpleEntityState({Key key, this.expanded: true}) : super(key: key);
2018-10-27 14:27:41 +03:00
@override
Widget build(BuildContext context) {
final entityModel = EntityModel.of(context);
2018-11-05 20:21:44 +02:00
Widget result = Padding(
2018-11-12 20:28:10 +02:00
padding: EdgeInsets.fromLTRB(0.0, 0.0, Sizes.rightWidgetPadding, 0.0),
2018-11-05 20:21:44 +02:00
child: GestureDetector(
child: Text(
"${entityModel.entity.state}${entityModel.entity.unitOfMeasurement}",
textAlign: TextAlign.right,
style: new TextStyle(
2018-11-12 20:28:10 +02:00
fontSize: Sizes.stateFontSize,
2018-11-05 20:21:44 +02:00
)),
onTap: () => entityModel.handleTap
? eventBus.fire(new ShowEntityPageEvent(entityModel.entity))
: null,
)
2018-11-04 22:55:09 +02:00
);
2018-11-05 20:21:44 +02:00
if (expanded) {
return Expanded(
child: result
);
} else {
return result;
}
2018-10-27 14:27:41 +03:00
}
2018-11-04 22:55:09 +02:00
}