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 = [];
|
2018-11-25 20:44:19 +02:00
|
|
|
List<HACard> childCards = [];
|
2018-11-25 18:09:06 +02:00
|
|
|
EntityWrapper linkedEntityWrapper;
|
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,
|
2018-11-25 18:09:06 +02:00
|
|
|
this.linkedEntityWrapper,
|
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) {
|
|
|
|
|
2018-11-23 16:03:38 +02:00
|
|
|
case CardType.entities: {
|
2018-10-27 17:28:47 +03:00
|
|
|
return EntitiesCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-23 16:03:38 +02:00
|
|
|
case CardType.glance: {
|
2018-11-14 19:52:17 +02:00
|
|
|
return GlanceCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-23 16:03:38 +02:00
|
|
|
case CardType.mediaControl: {
|
2018-11-11 18:36:49 +02:00
|
|
|
return MediaControlCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-25 17:33:33 +02:00
|
|
|
case CardType.entityButton: {
|
|
|
|
return EntityButtonCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-25 20:44:19 +02:00
|
|
|
case CardType.horizontalStack: {
|
|
|
|
if (childCards.isNotEmpty) {
|
|
|
|
List<Widget> children = [];
|
|
|
|
childCards.forEach((card) {
|
|
|
|
children.add(
|
|
|
|
Flexible(
|
|
|
|
fit: FlexFit.tight,
|
|
|
|
child: card.build(context),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
return Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: children,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container(height: 0.0, width: 0.0,);
|
|
|
|
}
|
|
|
|
|
2018-11-23 16:03:38 +02:00
|
|
|
case CardType.weatherForecast:
|
|
|
|
case CardType.thermostat:
|
|
|
|
case CardType.sensor:
|
|
|
|
case CardType.plantStatus:
|
|
|
|
case CardType.pictureEntity:
|
|
|
|
case CardType.pictureElements:
|
|
|
|
case CardType.picture:
|
|
|
|
case CardType.map:
|
|
|
|
case CardType.iframe:
|
|
|
|
case CardType.gauge:
|
|
|
|
case CardType.conditional:
|
|
|
|
case CardType.alarmPanel: {
|
2018-10-27 17:28:47 +03:00
|
|
|
return UnsupportedCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
2018-11-25 18:09:06 +02:00
|
|
|
if ((linkedEntityWrapper == null) && (entities.isNotEmpty)) {
|
2018-10-27 17:28:47 +03:00
|
|
|
return EntitiesCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return UnsupportedCardWidget(
|
|
|
|
card: this,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|