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

64 lines
1.2 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 = [];
2018-11-25 20:44:19 +02:00
List<HACard> childCards = [];
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;
bool showEmpty;
2018-11-14 19:52:17 +02:00
int columnsCount;
List stateFilter;
2019-01-29 15:00:15 +02:00
List states;
List conditions;
2019-01-23 23:34:45 +02:00
String content;
2019-09-07 15:47:09 +03:00
String unit;
int min;
int max;
Map severity;
2018-10-27 17:28:47 +03:00
HACard({
this.name,
this.id,
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,
this.stateFilter: const [],
this.showEmpty: true,
2019-01-23 23:34:45 +02:00
this.content,
2019-01-29 15:00:15 +02:00
this.states,
this.conditions: const [],
2019-09-07 15:47:09 +03:00
this.unit,
this.min,
this.max,
this.severity,
2018-10-27 17:28:47 +03:00
@required this.type
2019-09-04 23:42:19 +03:00
}) {
if (this.columnsCount <= 0) {
this.columnsCount = 4;
}
}
2018-10-27 17:28:47 +03:00
List<EntityWrapper> getEntitiesToShow() {
return entities.where((entityWrapper) {
2019-10-09 20:45:46 +03:00
if (!ConnectionManager().useLovelace && entityWrapper.entity.isHidden) {
return false;
}
if (stateFilter.isNotEmpty) {
return stateFilter.contains(entityWrapper.entity.state);
2018-10-27 17:28:47 +03:00
}
return true;
}).toList();
}
Widget build(BuildContext context) {
return CardWidget(
card: this,
);
2018-10-27 17:28:47 +03:00
}
}