Resolves #443 Lovelace view as panel support
This commit is contained in:
parent
d2049b726a
commit
c90c40c046
@ -162,7 +162,8 @@ class HomeAssistant {
|
||||
count: viewCounter,
|
||||
id: "${rawView['id']}",
|
||||
name: rawView['title'],
|
||||
iconName: rawView['icon']
|
||||
iconName: rawView['icon'],
|
||||
panel: rawView['panel'] ?? false,
|
||||
);
|
||||
|
||||
if (rawView['badges'] != null && rawView['badges'] is List) {
|
||||
|
@ -4,16 +4,18 @@ class HAView {
|
||||
List<HACard> cards = [];
|
||||
List<Entity> badges = [];
|
||||
Entity linkedEntity;
|
||||
String name;
|
||||
String id;
|
||||
String iconName;
|
||||
int count;
|
||||
final String name;
|
||||
final String id;
|
||||
final String iconName;
|
||||
final int count;
|
||||
final bool panel;
|
||||
|
||||
HAView({
|
||||
this.name,
|
||||
this.id,
|
||||
this.count,
|
||||
this.iconName,
|
||||
this.panel: false,
|
||||
List<Entity> childEntities
|
||||
}) {
|
||||
if (childEntities != null) {
|
||||
|
@ -24,11 +24,28 @@ class ViewWidgetState extends State<ViewWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
//physics: const AlwaysScrollableScrollPhysics(),
|
||||
children: _buildChildren(context),
|
||||
);
|
||||
if (widget.view.panel) {
|
||||
return FractionallySizedBox(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: _buildPanelChild(context),
|
||||
);
|
||||
} else {
|
||||
return ListView(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
//physics: const AlwaysScrollableScrollPhysics(),
|
||||
children: _buildChildren(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildPanelChild(BuildContext context) {
|
||||
if (widget.view.cards != null && widget.view.cards.isNotEmpty) {
|
||||
Logger.d("Building panel view. Card ${widget.view.cards[0].type}");
|
||||
return widget.view.cards[0].build(context);
|
||||
} else {
|
||||
return Container(width: 0, height: 0);
|
||||
}
|
||||
}
|
||||
|
||||
List<Widget> _buildChildren(BuildContext context) {
|
||||
|
Reference in New Issue
Block a user