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