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/unsupported_card.dart

53 lines
1.4 KiB
Dart
Raw Normal View History

2018-10-27 17:28:47 +03:00
part of '../main.dart';
class UnsupportedCardWidget extends StatelessWidget {
final HACard card;
const UnsupportedCardWidget({
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 17:28:47 +03:00
return Container(width: 0.0, height: 0.0,);
}
List<Widget> body = [];
body.add(CardHeaderWidget(name: card.name ?? ""));
2018-10-27 17:28:47 +03:00
body.addAll(_buildCardBody(context));
return Card(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: body
)
);
}
List<Widget> _buildCardBody(BuildContext context) {
List<Widget> result = [];
if (card.linkedEntity != null) {
result.addAll(<Widget>[
Padding(
2018-11-12 20:28:10 +02:00
padding: EdgeInsets.fromLTRB(0.0, Sizes.rowPadding, 0.0, Sizes.rowPadding),
2018-11-15 19:08:47 +02:00
child: EntityModel(
entityWrapper: card.linkedEntity,
2018-11-15 19:08:47 +02:00
handleTap: true,
child: card.linkedEntity.entity.buildDefaultWidget(context)
),
)
]);
} else {
result.addAll(<Widget>[
Padding(
2018-11-12 20:28:10 +02:00
padding: EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, Sizes.rowPadding),
child: Text("'${card.type}' card is not supported yet"),
),
]);
}
2018-10-27 17:28:47 +03:00
return result;
}
}