Resolves #443 Lovelace view as panel support
This commit is contained in:
		| @@ -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,11 +24,28 @@ class ViewWidgetState extends State<ViewWidget> { | |||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   Widget build(BuildContext context) { |   Widget build(BuildContext context) { | ||||||
|     return ListView( |     if (widget.view.panel) { | ||||||
|       padding: EdgeInsets.all(0.0), |       return FractionallySizedBox( | ||||||
|       //physics: const AlwaysScrollableScrollPhysics(), |         widthFactor: 1, | ||||||
|       children: _buildChildren(context), |         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) { |   List<Widget> _buildChildren(BuildContext context) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user