Unsupported lovelace cards showing entities
This commit is contained in:
parent
e25162f7b5
commit
a3adb72cf8
@ -62,9 +62,6 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
|
||||
listener: (model) => _onSelectionChanged(model),
|
||||
)
|
||||
],
|
||||
behaviors: [
|
||||
charts.PanAndZoomBehavior(),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -60,9 +60,6 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
|
||||
listener: (model) => _onSelectionChanged(model),
|
||||
)
|
||||
],
|
||||
behaviors: [
|
||||
charts.PanAndZoomBehavior(),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -64,9 +64,6 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
|
||||
// ID used to link series to this renderer.
|
||||
customRendererId: 'endValuePoints')
|
||||
],
|
||||
behaviors: [
|
||||
charts.PanAndZoomBehavior(),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -68,6 +68,8 @@ part 'ui_widgets/view.dart';
|
||||
part 'ui_widgets/entities_card.dart';
|
||||
part 'ui_widgets/unsupported_card.dart';
|
||||
part 'ui_widgets/media_control_card.dart';
|
||||
part 'ui_widgets/card_header_widget.dart';
|
||||
|
||||
|
||||
EventBus eventBus = new EventBus();
|
||||
const String appName = "HA Client";
|
||||
|
@ -23,6 +23,19 @@ class HACard {
|
||||
);
|
||||
}
|
||||
|
||||
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":
|
||||
case "alarm-panel":
|
||||
case "media-control": {
|
||||
return UnsupportedCardWidget(
|
||||
card: this,
|
||||
|
25
lib/ui_widgets/card_header_widget.dart
Normal file
25
lib/ui_widgets/card_header_widget.dart
Normal file
@ -0,0 +1,25 @@
|
||||
part of '../main.dart';
|
||||
|
||||
class CardHeaderWidget extends StatelessWidget {
|
||||
|
||||
final String name;
|
||||
|
||||
const CardHeaderWidget({Key key, this.name}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var result;
|
||||
if ((name != null) && (name.trim().length > 0)) {
|
||||
result = new ListTile(
|
||||
title: Text("$name",
|
||||
textAlign: TextAlign.left,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 25.0)),
|
||||
);
|
||||
} else {
|
||||
result = new Container(width: 0.0, height: 0.0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -15,28 +15,13 @@ class EntitiesCardWidget extends StatelessWidget {
|
||||
return Container(width: 0.0, height: 0.0,);
|
||||
}
|
||||
List<Widget> body = [];
|
||||
body.add(_buildCardHeader());
|
||||
body.add(CardHeaderWidget(name: card.name));
|
||||
body.addAll(_buildCardBody(context));
|
||||
return Card(
|
||||
child: new Column(mainAxisSize: MainAxisSize.min, children: body)
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCardHeader() {
|
||||
var result;
|
||||
if ((card.name != null) && (card.name.trim().length > 0)) {
|
||||
result = new ListTile(
|
||||
title: Text("${card.name}",
|
||||
textAlign: TextAlign.left,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 25.0)),
|
||||
);
|
||||
} else {
|
||||
result = new Container(width: 0.0, height: 0.0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Widget> _buildCardBody(BuildContext context) {
|
||||
List<Widget> result = [];
|
||||
card.entities.forEach((Entity entity) {
|
||||
|
@ -15,7 +15,7 @@ class UnsupportedCardWidget extends StatelessWidget {
|
||||
return Container(width: 0.0, height: 0.0,);
|
||||
}
|
||||
List<Widget> body = [];
|
||||
body.add(_buildCardHeader());
|
||||
body.add(CardHeaderWidget(name: card.name ?? ""));
|
||||
body.addAll(_buildCardBody(context));
|
||||
return Card(
|
||||
child: new Column(
|
||||
@ -26,31 +26,27 @@ class UnsupportedCardWidget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCardHeader() {
|
||||
return ListTile(
|
||||
title: Text("${card.name ?? card.type}",
|
||||
textAlign: TextAlign.left,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 25.0)),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildCardBody(BuildContext context) {
|
||||
List<Widget> result = [];
|
||||
if (card.linkedEntity != null) {
|
||||
result.addAll(<Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(Entity.leftWidgetPadding, 0.0, Entity.rightWidgetPadding, 0.0),
|
||||
child: Text("Card type '${card.type}' is not supported yet"),
|
||||
padding: EdgeInsets.fromLTRB(Entity.leftWidgetPadding, Entity.rowPadding, Entity.rightWidgetPadding, 0.0),
|
||||
child: Text("'${card.type}' card is not supported yet"),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(Entity.leftWidgetPadding, Entity.rowPadding, Entity.rightWidgetPadding, 0.0),
|
||||
child: Text("Linked entity: ${card.linkedEntity?.entityId}"),
|
||||
),
|
||||
padding: EdgeInsets.fromLTRB(0.0, Entity.rowPadding, 0.0, Entity.rowPadding),
|
||||
child: card.linkedEntity.buildDefaultWidget(context),
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
result.addAll(<Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(Entity.leftWidgetPadding, Entity.rowPadding, Entity.rightWidgetPadding, Entity.rowPadding),
|
||||
child: Text("Child entities: ${card.entities}"),
|
||||
child: Text("'${card.type}' card is not supported yet"),
|
||||
),
|
||||
]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user