From 890da650dc56903d2f2023e80e99be40560c3995 Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Fri, 29 Nov 2019 10:12:41 +0000 Subject: [PATCH] Resolves #508 show_name for enriry button card --- lib/cards/card_widget.dart | 4 +++- .../entity_button_card_body.widget.dart | 23 +++++++++++-------- lib/home_assistant.class.dart | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/cards/card_widget.dart b/lib/cards/card_widget.dart index e1d2fe8..8e02e79 100644 --- a/lib/cards/card_widget.dart +++ b/lib/cards/card_widget.dart @@ -285,7 +285,9 @@ class CardWidget extends StatelessWidget { return Card( child: EntityModel( entityWrapper: card.linkedEntityWrapper, - child: EntityButtonCardBody(), + child: EntityButtonCardBody( + showName: card.showName, + ), handleTap: true ) ); diff --git a/lib/cards/widgets/entity_button_card_body.widget.dart b/lib/cards/widgets/entity_button_card_body.widget.dart index 82e4c52..712feec 100644 --- a/lib/cards/widgets/entity_button_card_body.widget.dart +++ b/lib/cards/widgets/entity_button_card_body.widget.dart @@ -2,8 +2,10 @@ part of '../../main.dart'; class EntityButtonCardBody extends StatelessWidget { + final bool showName; + EntityButtonCardBody({ - Key key, + Key key, this.showName: true, }) : super(key: key); @override @@ -39,13 +41,16 @@ class EntityButtonCardBody extends StatelessWidget { } Widget _buildName() { - return EntityName( - padding: EdgeInsets.fromLTRB(Sizes.buttonPadding, 0.0, Sizes.buttonPadding, Sizes.rowPadding), - textOverflow: TextOverflow.ellipsis, - maxLines: 3, - wordsWrap: true, - textAlign: TextAlign.center, - fontSize: Sizes.nameFontSize, - ); + if (showName) { + return EntityName( + padding: EdgeInsets.fromLTRB(Sizes.buttonPadding, 0.0, Sizes.buttonPadding, Sizes.rowPadding), + textOverflow: TextOverflow.ellipsis, + maxLines: 3, + wordsWrap: true, + textAlign: TextAlign.center, + fontSize: Sizes.nameFontSize, + ); + } + return Container(width: 0, height: 0); } } \ No newline at end of file diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart index ff32eb1..7803a80 100644 --- a/lib/home_assistant.class.dart +++ b/lib/home_assistant.class.dart @@ -223,8 +223,8 @@ class HomeAssistant { name: rawCardInfo["title"] ?? rawCardInfo["name"], type: rawCardInfo['type'] ?? CardType.ENTITIES, columnsCount: rawCardInfo['columns'] ?? 4, - showName: rawCardInfo['show_name'] ?? true, - showState: rawCardInfo['show_state'] ?? true, + showName: (rawCardInfo['show_name'] ?? rawCard['show_name']) ?? true, + showState: (rawCardInfo['show_state'] ?? rawCard['show_state']) ?? true, showEmpty: (rawCardInfo['show_empty'] ?? rawCard['show_empty']) ?? true, stateFilter: (rawCard['state_filter'] ?? rawCardInfo['state_filter']) ?? [], states: rawCardInfo['states'],