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/ui_widgets/entities_card.dart

43 lines
1.1 KiB
Dart
Raw Normal View History

2018-10-27 14:27:41 +03:00
part of '../main.dart';
2018-10-27 17:28:47 +03:00
class EntitiesCardWidget extends StatelessWidget {
2018-10-27 14:27:41 +03:00
final HACard card;
2018-10-27 17:28:47 +03:00
const EntitiesCardWidget({
2018-10-27 14:27:41 +03:00
Key key,
this.card
}) : super(key: key);
@override
Widget build(BuildContext context) {
2018-11-15 19:08:47 +02:00
if ((card.linkedEntity!= null) && (card.linkedEntity.entity.isHidden)) {
2018-10-27 14:27:41 +03:00
return Container(width: 0.0, height: 0.0,);
}
List<Widget> body = [];
body.add(CardHeaderWidget(name: card.name));
2018-10-27 14:27:41 +03:00
body.addAll(_buildCardBody(context));
return Card(
child: new Column(mainAxisSize: MainAxisSize.min, children: body)
);
}
List<Widget> _buildCardBody(BuildContext context) {
List<Widget> result = [];
2018-11-15 19:08:47 +02:00
card.entities.forEach((EntityWrapper entity) {
if (!entity.entity.isHidden) {
2018-10-27 14:27:41 +03:00
result.add(
Padding(
2018-11-14 19:52:17 +02:00
padding: EdgeInsets.fromLTRB(0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding),
2018-11-15 19:08:47 +02:00
child: EntityModel(
entityWrapper: entity,
2018-11-15 19:08:47 +02:00
handleTap: true,
child: entity.entity.buildDefaultWidget(context)
),
2018-10-27 14:27:41 +03:00
));
}
});
return result;
}
}