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_class/card.class.dart

77 lines
1.5 KiB
Dart
Raw Normal View History

2018-10-27 17:28:47 +03:00
part of '../main.dart';
class HACard {
2018-11-15 19:08:47 +02:00
List<EntityWrapper> entities = [];
EntityWrapper linkedEntity;
2018-10-27 17:28:47 +03:00
String name;
String id;
String type;
2018-11-15 19:08:47 +02:00
bool showName;
bool showState;
2018-11-14 19:52:17 +02:00
int columnsCount;
2018-10-27 17:28:47 +03:00
HACard({
this.name,
this.id,
this.linkedEntity,
2018-11-14 19:52:17 +02:00
this.columnsCount: 4,
2018-11-15 19:08:47 +02:00
this.showName: true,
this.showState: true,
2018-10-27 17:28:47 +03:00
@required this.type
});
Widget build(BuildContext context) {
switch (type) {
case "entities": {
return EntitiesCardWidget(
card: this,
);
}
2018-11-14 19:52:17 +02:00
case "glance": {
return GlanceCardWidget(
card: this,
);
}
2018-11-11 18:36:49 +02:00
case "media-control": {
return MediaControlCardWidget(
card: this,
);
}
case "weather-forecast":
case "thermostat":
case "sensor":
case "plant-status":
case "picture-entity":
case "picture-elements":
case "picture":
case "map":
case "iframe":
case "gauge":
case "entity-button":
case "conditional":
2018-11-11 18:36:49 +02:00
case "alarm-panel": {
2018-10-27 17:28:47 +03:00
return UnsupportedCardWidget(
card: this,
);
}
default: {
if ((linkedEntity == null) && (entities.isNotEmpty)) {
return EntitiesCardWidget(
card: this,
);
} else {
return UnsupportedCardWidget(
card: this,
);
}
}
}
}
}